github.com/matrixorigin/matrixone@v1.2.0/pkg/vm/engine/tae/options/cfg.go (about)

     1  // Copyright 2021 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 options
    16  
    17  import (
    18  	"time"
    19  
    20  	"github.com/matrixorigin/matrixone/pkg/common/mpool"
    21  )
    22  
    23  const (
    24  	defaultRpcMaxMessageSize      = 16 * mpool.KB
    25  	defaultRpcEnableChecksum      = true
    26  	defaultLogtailCollectInterval = 50 * time.Millisecond
    27  	defaultResponseSendTimeout    = 10 * time.Second
    28  	defaultRpcStreamPoisonTime    = 5 * time.Second
    29  )
    30  
    31  type StorageCfg struct {
    32  	BlockMaxRows    uint32 `toml:"block-max-rows"`
    33  	ObjectMaxBlocks uint16 `toml:"object-max-blocks"`
    34  }
    35  
    36  type CheckpointCfg struct {
    37  	FlushInterval             time.Duration `toml:"flush-inerterval"`
    38  	MinCount                  int64         `toml:"checkpoint-min-count"`
    39  	ScanInterval              time.Duration `toml:"scan-interval"`
    40  	IncrementalInterval       time.Duration `toml:"checkpoint-incremental-interval"`
    41  	GlobalMinCount            int64         `toml:"checkpoint-global-interval"`
    42  	OverallFlushMemControl    uint64        `toml:"overall-flush-mem-control"`
    43  	ForceUpdateGlobalInterval bool
    44  	GlobalVersionInterval     time.Duration
    45  	GCCheckpointInterval      time.Duration
    46  	DisableGCCheckpoint       bool
    47  	ReservedWALEntryCount     uint64
    48  
    49  	// only for test
    50  	// it is used to control the block rows of the checkpoint
    51  	BlockRows int
    52  	Size      int
    53  }
    54  
    55  type GCCfg struct {
    56  	GCTTL          time.Duration `toml:"gc-ttl"`
    57  	ScanGCInterval time.Duration `toml:"scan-gc-interval"`
    58  	DisableGC      bool          `toml:"disable-gc"`
    59  }
    60  
    61  type CatalogCfg struct {
    62  	GCInterval time.Duration
    63  	DisableGC  bool
    64  }
    65  
    66  type SchedulerCfg struct {
    67  	IOWorkers    int `toml:"io-workers"`
    68  	AsyncWorkers int `toml:"async-workers"`
    69  }
    70  
    71  type LogtailCfg struct {
    72  	PageSize int32 `toml:"page-size"`
    73  }
    74  
    75  type MergeConfig struct {
    76  	CNMergeMemControlHint uint64
    77  	CNTakeOverAll         bool
    78  	CNTakeOverExceed      uint64
    79  	CNStandaloneTake      bool
    80  }
    81  
    82  type LogtailServerCfg struct {
    83  	RpcMaxMessageSize      int64
    84  	RpcEnableChecksum      bool
    85  	RPCStreamPoisonTime    time.Duration
    86  	LogtailCollectInterval time.Duration
    87  	ResponseSendTimeout    time.Duration
    88  }
    89  
    90  func NewDefaultLogtailServerCfg() *LogtailServerCfg {
    91  	return &LogtailServerCfg{
    92  		RpcMaxMessageSize:      defaultRpcMaxMessageSize,
    93  		RpcEnableChecksum:      defaultRpcEnableChecksum,
    94  		RPCStreamPoisonTime:    defaultRpcStreamPoisonTime,
    95  		LogtailCollectInterval: defaultLogtailCollectInterval,
    96  		ResponseSendTimeout:    defaultResponseSendTimeout,
    97  	}
    98  }
    99  
   100  func (l *LogtailServerCfg) Validate() {
   101  	if l.RpcMaxMessageSize <= 0 {
   102  		l.RpcMaxMessageSize = defaultRpcMaxMessageSize
   103  	}
   104  	if l.RPCStreamPoisonTime <= 0 {
   105  		l.RPCStreamPoisonTime = defaultRpcStreamPoisonTime
   106  	}
   107  	if l.LogtailCollectInterval <= 0 {
   108  		l.LogtailCollectInterval = defaultLogtailCollectInterval
   109  	}
   110  	if l.ResponseSendTimeout <= 0 {
   111  		l.ResponseSendTimeout = defaultResponseSendTimeout
   112  	}
   113  }