github.com/matrixorigin/matrixone@v0.7.0/pkg/cnservice/distributed_tae.go (about)

     1  // Copyright 2021 - 2022 Matrix Origin
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package cnservice
    16  
    17  import (
    18  	"context"
    19  
    20  	"github.com/matrixorigin/matrixone/pkg/common/mpool"
    21  	"github.com/matrixorigin/matrixone/pkg/config"
    22  	"github.com/matrixorigin/matrixone/pkg/defines"
    23  	"github.com/matrixorigin/matrixone/pkg/fileservice"
    24  	"github.com/matrixorigin/matrixone/pkg/sql/colexec"
    25  	"github.com/matrixorigin/matrixone/pkg/vm/engine/disttae"
    26  )
    27  
    28  func (s *service) initDistributedTAE(
    29  	ctx context.Context,
    30  	pu *config.ParameterUnit,
    31  ) error {
    32  
    33  	// txn client
    34  	client, err := s.getTxnClient()
    35  	if err != nil {
    36  		return err
    37  	}
    38  	pu.TxnClient = client
    39  
    40  	// hakeeper
    41  	hakeeper, err := s.getHAKeeperClient()
    42  	if err != nil {
    43  		return err
    44  	}
    45  
    46  	// Should be no fixed or some size?
    47  	mp, err := mpool.NewMPool("distributed_tae", 0, mpool.NoFixed)
    48  	if err != nil {
    49  		return err
    50  	}
    51  
    52  	// use s3 as main fs
    53  	fs, err := fileservice.Get[fileservice.FileService](s.fileService, defines.SharedFileServiceName)
    54  	if err != nil {
    55  		return err
    56  	}
    57  	colexec.Srv = colexec.NewServer(hakeeper)
    58  	// engine
    59  	pu.StorageEngine = disttae.New(
    60  		ctx,
    61  		mp,
    62  		fs,
    63  		client,
    64  		hakeeper,
    65  		pu.GetClusterDetails,
    66  	)
    67  	return nil
    68  }