config

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2021 License: Apache-2.0 Imports: 13 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	RaftAddr   string     `toml:"addr-raft"`
	ClientAddr string     `toml:"addr-client"`
	DataPath   string     `toml:"dir-data"`
	DeployPath string     `toml:"dir-deploy"`
	Version    string     `toml:"version"`
	GitHash    string     `toml:"githash"`
	Labels     [][]string `toml:"labels"`
	// Capacity max capacity can use
	Capacity           typeutil.ByteSize `toml:"capacity"`
	UseMemoryAsStorage bool              `toml:"use-memory-as-storage"`
	ShardGroups        uint64            `toml:"shard-groups"`
	Replication        ReplicationConfig `toml:"replication"`
	Snapshot           SnapshotConfig    `toml:"snapshot"`
	// Raft raft config
	Raft RaftConfig `toml:"raft"`
	// Worker worker config
	Worker WorkerConfig `toml:"worker"`
	// Prophet prophet config
	Prophet pconfig.Config `toml:"prophet"`
	// Storage config
	Storage StorageConfig
	// Customize config
	Customize CustomizeConfig
	// Metric Config
	Metric metric.Cfg `toml:"metric"`
	// FS used in MatrixCube
	FS vfs.FS
	// Test only used in testing
	Test TestConfig
}

Config matrixcube config

func (*Config) Adjust

func (c *Config) Adjust()

Adjust adjust

func (*Config) GetLabels

func (c *Config) GetLabels() []metapb.Pair

GetLabels returns lables

func (*Config) SnapshotDir

func (c *Config) SnapshotDir() string

SnapshotDir returns snapshot dir

type CustomizeConfig

type CustomizeConfig struct {
	// CustomShardStateAwareFactory is a factory func to create aware.ShardStateAware to handled shard life cycle.
	CustomShardStateAwareFactory func() aware.ShardStateAware
	// CustomInitShardsFactory is a factory func to provide init shards to cube to bootstrap the cluster.
	CustomInitShardsFactory func() []bhmetapb.Shard
	// CustomSnapshotManagerFactory is a factory func to create a snapshot.SnapshotManager to handle snapshot by youself.
	CustomSnapshotManagerFactory func() snapshot.SnapshotManager
	// CustomTransportFactory is a factory func to create a transport.Transport to handle raft rpc by youself.
	CustomTransportFactory func() transport.Transport
	// CustomSnapshotDataCreateFuncFactory is factory create a func which called by cube if a snapshot need to create.
	CustomSnapshotDataCreateFuncFactory func(group uint64) func(dataPath string, shard bhmetapb.Shard) error
	// CustomSnapshotDataApplyFuncFactory is factory create a func which called by cube if a snapshot need to apply.
	CustomSnapshotDataApplyFuncFactory func(group uint64) func(dataPath string, shard bhmetapb.Shard) error
	// CustomSplitCheckFuncFactory  is factory create a func which called periodically by cube to check if the shard needs to be split
	CustomSplitCheckFuncFactory func(group uint64) func(bhmetapb.Shard) (totalSize uint64, totalKeys uint64, splitKeys [][]byte, err error)
	// CustomSplitCompletedFuncFactory  is factory create a func which called by cube when the split operation of the shard is completed.
	// We can update the attributes of old and news shards in this func
	CustomSplitCompletedFuncFactory func(group uint64) func(old *bhmetapb.Shard, news []bhmetapb.Shard)
	// CustomCanReadLocalFunc returns true if the shard can read without raft
	CustomCanReadLocalFunc func(bhmetapb.Shard) bool
	// CustomAdjustCompactFunc is factory create a func which used to adjust raft log compactIdx
	CustomAdjustCompactFuncFactory func(group uint64) func(shard bhmetapb.Shard, compactIndex uint64) (newCompactIdx uint64, err error)
	// CustomAdjustInitAppliedIndexFactory is factory create a func which used to adjust init applied raft log index
	CustomAdjustInitAppliedIndexFactory func(group uint64) func(shard bhmetapb.Shard, initAppliedIndex uint64) (adjustAppliedIndex uint64)
	// CustomStoreHeartbeatDataProcessor process store heartbeat data, collect, store and process customize data
	CustomStoreHeartbeatDataProcessor StoreHeartbeatDataProcessor
	// CustomShardPoolShardFactory is factory create a shard used by shard pool, `start, end and unique` is created by
	// `ShardPool` based on `offsetInPool`, these can be modified, provided that the only non-conflict.
	CustomShardPoolShardFactory func(g uint64, start, end []byte, unique string, offsetInPool uint64) bhmetapb.Shard
}

CustomizeConfig customize config

type RaftConfig

type RaftConfig struct {
	// TickInterval raft tick interval
	TickInterval typeutil.Duration `toml:"tick-interval"`
	// HeartbeatTicks how many ticks to send raft heartbeat message
	HeartbeatTicks int `toml:"heartbeat-ticks"`
	// ElectionTimeoutTicks how many ticks to send election message
	ElectionTimeoutTicks int `toml:"election-timeout-ticks"`
	// MaxSizePerMsg max bytes per raft message
	MaxSizePerMsg typeutil.ByteSize `toml:"max-size-per-msg"`
	// MaxInflightMsgs max raft message count in a raft rpc
	MaxInflightMsgs int `toml:"max-inflight-msgs"`
	// MaxEntryBytes max bytes of entry in a proposal message
	MaxEntryBytes typeutil.ByteSize `toml:"max-entry-bytes"`
	// SendRaftBatchSize raft message sender count
	SendRaftBatchSize uint64 `toml:"send-raft-batch-size"`
	// RaftLog raft log 配置
	RaftLog RaftLogConfig `toml:"raft-log"`
}

RaftConfig raft config

func (*RaftConfig) GetElectionTimeoutDuration

func (c *RaftConfig) GetElectionTimeoutDuration() time.Duration

GetElectionTimeoutDuration returns ElectionTimeoutTicks * TickInterval

func (*RaftConfig) GetHeartbeatDuration

func (c *RaftConfig) GetHeartbeatDuration() time.Duration

GetHeartbeatDuration returns HeartbeatTicks * TickInterval

type RaftLogConfig

type RaftLogConfig struct {
	DisableSync           bool              `toml:"disable-sync"`
	CompactDuration       typeutil.Duration `toml:"compact-duration"`
	CompactThreshold      uint64            `toml:"compact-threshold"`
	DisableCompactProtect []uint64          `toml:"disable-compact-protect"`
	MaxAllowTransferLag   uint64            `toml:"max-allow-transfer-lag"`
	ForceCompactCount     uint64
	ForceCompactBytes     uint64
	CompactProtectLag     uint64
}

RaftLogConfig raft log config

type ReplicationConfig

type ReplicationConfig struct {
	MaxPeerDownTime         typeutil.Duration `toml:"max-peer-down-time"`
	ShardHeartbeatDuration  typeutil.Duration `toml:"shard-heartbeat-duration"`
	StoreHeartbeatDuration  typeutil.Duration `toml:"store-heartbeat-duration"`
	ShardSplitCheckDuration typeutil.Duration `toml:"shard-split-check-duration"`
	ShardStateCheckDuration typeutil.Duration `toml:"shard-state-check-duration"`
	DisableShardSplit       bool              `toml:"disable-shard-split"`
	AllowRemoveLeader       bool              `toml:"allow-remove-leader"`
	ShardCapacityBytes      typeutil.ByteSize `toml:"shard-capacity-bytes"`
	ShardSplitCheckBytes    typeutil.ByteSize `toml:"shard-split-check-bytes"`
}

ReplicationConfig replication config

type ShardConfig

type ShardConfig struct {
	// SplitCheckInterval interval to check shard whether need to be split or not.
	SplitCheckInterval typeutil.Duration `toml:"split-check-interval"`
	// SplitCheckDiff when size change of shard exceed the diff since last check, it
	// will be checked again whether it should be split.
	SplitCheckDiff uint64 `toml:"split-check-diff"`
}

ShardConfig shard config

type SnapshotConfig

type SnapshotConfig struct {
	MaxConcurrencySnapChunks uint64            `toml:"max-concurrency-snap-chunks"`
	SnapChunkSize            typeutil.ByteSize `toml:"snap-chunk-size"`
}

SnapshotConfig snapshot config

type StorageConfig

type StorageConfig struct {
	// MetaStorage used to store raft, shards and store's metadata
	MetaStorage storage.MetadataStorage
	// DataStorageFactory is a storage factory  to store application's data
	DataStorageFactory func(group uint64, shardID uint64) storage.DataStorage
	// DataMoveFunc move data from a storage to others
	DataMoveFunc func(bhmetapb.Shard, []bhmetapb.Shard) error
	// ForeachDataStorageFunc do in every storage
	ForeachDataStorageFunc func(cb func(storage.DataStorage))
}

StorageConfig storage config

type StoreHeartbeatDataProcessor

type StoreHeartbeatDataProcessor interface {
	pconfig.ContainerHeartbeatDataProcessor

	// HandleHeartbeatRsp handle the data from store heartbeat at the each worker node
	HandleHeartbeatRsp(data []byte) error
	// CollectData collect data at every heartbeat
	CollectData() []byte
}

StoreHeartbeatDataProcessor process store heartbeat data, collect, store and process customize data

type TestConfig

type TestConfig struct {
	// ShardStateAware is a ShardStateAware wrapper for the aware which created by
	// `CustomizeConfig.CustomShardStateAwareFactory`
	ShardStateAware aware.TestShardStateAware
	// PeerReplicaSetSnapshotJobWait sleep before set snapshot job
	PeerReplicaSetSnapshotJobWait time.Duration
	// SaveDynamicallyShardInitStateWait wait before save dynamically shard init state
	SaveDynamicallyShardInitStateWait time.Duration
	// ShardPoolCreateWaitC waiting delay for shard creation
	ShardPoolCreateWaitC chan struct{}
	// Shards test config for shards
	Shards map[uint64]*TestShardConfig
}

TestConfig all test config

type TestShardConfig

type TestShardConfig struct {
	// SkipSaveRaftApplyState skip save raft apply state to metastorage after applied a raft log
	SkipSaveRaftApplyState bool
	// SkipApply skip apply any raft log
	SkipApply bool
}

TestShardConfig shard test config

type WorkerConfig

type WorkerConfig struct {
	ApplyWorkerCount       uint64 `toml:"raft-apply-worker"`
	SendRaftMsgWorkerCount uint64 `toml:"raft-msg-worker"`
	RaftEventWorkers       uint64 `toml:"raft-event-workers"`
}

WorkerConfig worker config

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL