github.com/matrixorigin/matrixone@v0.7.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  	defaultRpcPayloadCopyBufferSize = 16 * mpool.KB
    26  	defaultRpcEnableChecksum        = true
    27  	defaultLogtailCollectInterval   = 50 * time.Millisecond
    28  	defaultResponseSendTimeout      = 10 * time.Second
    29  	defaultMaxLogtailFetchFailure   = 5
    30  )
    31  
    32  type CacheCfg struct {
    33  	IndexCapacity  uint64 `toml:"index-cache-size"`
    34  	InsertCapacity uint64 `toml:"insert-cache-size"`
    35  	TxnCapacity    uint64 `toml:"txn-cache-size"`
    36  }
    37  
    38  type StorageCfg struct {
    39  	BlockMaxRows     uint32 `toml:"block-max-rows"`
    40  	SegmentMaxBlocks uint16 `toml:"segment-max-blocks"`
    41  }
    42  
    43  type CheckpointCfg struct {
    44  	FlushInterval             time.Duration `toml:"flush-inerterval"`
    45  	MinCount                  int64         `toml:"checkpoint-min-count"`
    46  	ScanInterval              time.Duration `toml:"scan-interval"`
    47  	IncrementalInterval       time.Duration `toml:"checkpoint-incremental-interval"`
    48  	GlobalMinCount            int64         `toml:"checkpoint-global-interval"`
    49  	ForceUpdateGlobalInterval bool
    50  	GlobalVersionInterval     time.Duration
    51  	GCCheckpointInterval      time.Duration
    52  	DisableGCCheckpoint       bool
    53  }
    54  
    55  type GCCfg struct {
    56  	GCTTL          time.Duration
    57  	ScanGCInterval time.Duration
    58  }
    59  
    60  type CatalogCfg struct {
    61  	GCInterval time.Duration
    62  	DisableGC  bool
    63  }
    64  
    65  type SchedulerCfg struct {
    66  	IOWorkers    int `toml:"io-workers"`
    67  	AsyncWorkers int `toml:"async-workers"`
    68  }
    69  
    70  type LogtailCfg struct {
    71  	PageSize int32 `toml:"page-size"`
    72  }
    73  
    74  type LogtailServerCfg struct {
    75  	RpcMaxMessageSize        int64
    76  	RpcPayloadCopyBufferSize int64
    77  	RpcEnableChecksum        bool
    78  	LogtailCollectInterval   time.Duration
    79  	ResponseSendTimeout      time.Duration
    80  	MaxLogtailFetchFailure   int
    81  }
    82  
    83  func NewDefaultLogtailServerCfg() *LogtailServerCfg {
    84  	return &LogtailServerCfg{
    85  		RpcMaxMessageSize:        defaultRpcMaxMessageSize,
    86  		RpcPayloadCopyBufferSize: defaultRpcPayloadCopyBufferSize,
    87  		RpcEnableChecksum:        defaultRpcEnableChecksum,
    88  		LogtailCollectInterval:   defaultLogtailCollectInterval,
    89  		ResponseSendTimeout:      defaultResponseSendTimeout,
    90  		MaxLogtailFetchFailure:   defaultMaxLogtailFetchFailure,
    91  	}
    92  }
    93  
    94  func (l *LogtailServerCfg) Validate() {
    95  	if l.RpcMaxMessageSize <= 0 {
    96  		l.RpcMaxMessageSize = defaultRpcMaxMessageSize
    97  	}
    98  	if l.RpcPayloadCopyBufferSize <= 0 {
    99  		l.RpcPayloadCopyBufferSize = defaultRpcPayloadCopyBufferSize
   100  	}
   101  	if l.LogtailCollectInterval <= 0 {
   102  		l.LogtailCollectInterval = defaultLogtailCollectInterval
   103  	}
   104  	if l.ResponseSendTimeout <= 0 {
   105  		l.ResponseSendTimeout = defaultResponseSendTimeout
   106  	}
   107  	if l.MaxLogtailFetchFailure <= 0 {
   108  		l.MaxLogtailFetchFailure = defaultMaxLogtailFetchFailure
   109  	}
   110  }