Documentation ¶
Index ¶
- Variables
- func EncodeProposeInfo(module string, operType int32, data []byte, ctx ProposeContext) []byte
- func EncodeSnapshotData(src *SnapshotData) ([]byte, error)
- type ProposeContext
- type ProposeInfo
- type RaftApplier
- type RaftMember
- type RaftMembers
- type RaftNode
- func (r *RaftNode) ApplyRaftSnapshot(ctx context.Context, st raftserver.Snapshot) error
- func (r *RaftNode) CreateRaftSnapshot(patchNum int) raftserver.Snapshot
- func (r *RaftNode) GetCurrentApplyIndex() uint64
- func (r *RaftNode) GetLeaderHost() string
- func (r *RaftNode) GetNodes() map[uint64]string
- func (r *RaftNode) GetRaftMembers(ctx context.Context) ([]RaftMember, error)
- func (r *RaftNode) GetStableApplyIndex() uint64
- func (r *RaftNode) ModuleApply(ctx context.Context, module string, operTypes []int32, datas [][]byte, ...) error
- func (r *RaftNode) NotifyLeaderChange(ctx context.Context, leader uint64, host string)
- func (r *RaftNode) RecordApplyIndex(ctx context.Context, index uint64, isFlush bool) (err error)
- func (r *RaftNode) RecordRaftMember(ctx context.Context, member RaftMember, isDelete bool) error
- func (r *RaftNode) RegistRaftApplier(target interface{})
- func (r *RaftNode) SetLeaderHost(idx uint64, host string)
- func (r *RaftNode) SetRaftServer(raftServer raftserver.RaftServer)
- func (r *RaftNode) Start()
- func (r *RaftNode) Stop()
- type RaftNodeConfig
- type SnapshotDB
- type SnapshotData
- type SnapshotItem
- type TaskDistribution
- type VolumeTaskType
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ApplyIndexKey = []byte("raft_apply_index") RaftMemberKey = []byte("#raft_members") )
Functions ¶
func EncodeProposeInfo ¶
func EncodeProposeInfo(module string, operType int32, data []byte, ctx ProposeContext) []byte
EncodeProposeInfo encode propose info into []byte
func EncodeSnapshotData ¶
func EncodeSnapshotData(src *SnapshotData) ([]byte, error)
Types ¶
type ProposeContext ¶
type ProposeContext struct {
ReqID string
}
ProposeContext hold propose context info during the request life cycle
func (ProposeContext) Marshal ¶
func (p ProposeContext) Marshal() (ret []byte, err error)
type ProposeInfo ¶
type ProposeInfo struct { Module string OperType int32 Data []byte Context ProposeContext }
raft propose info
func DecodeProposeInfo ¶
func DecodeProposeInfo(src []byte) *ProposeInfo
DecodeProposeInfo decode propose info from []byte
type RaftApplier ¶
type RaftApplier interface { GetModuleName() string SetModuleName(module string) // Apply apply specified data into module manager Apply(ctx context.Context, operTypes []int32, data [][]byte, contexts []ProposeContext) error // Flush should flush all memory data into persistent storage ,like rocksdb etc Flush(ctx context.Context) error // NotifyLeaderChange notify leader host change NotifyLeaderChange(ctx context.Context, leader uint64, host string) // LoadData load data from applier's db LoadData(ctx context.Context) error }
type RaftMember ¶
type RaftMembers ¶
type RaftMembers struct {
Mbs []RaftMember `json:"members"`
}
type RaftNode ¶
type RaftNode struct { raftserver.RaftServer *RaftNodeConfig // contains filtered or unexported fields }
func NewRaftNode ¶
func NewRaftNode(cfg *RaftNodeConfig, raftDB *raftdb.RaftDB, snapshotDBs map[string]SnapshotDB) (*RaftNode, error)
func (*RaftNode) ApplyRaftSnapshot ¶
ApplyRaftSnapshot apply snapshot's data into db
func (*RaftNode) CreateRaftSnapshot ¶
func (r *RaftNode) CreateRaftSnapshot(patchNum int) raftserver.Snapshot
func (*RaftNode) GetCurrentApplyIndex ¶
func (*RaftNode) GetLeaderHost ¶
func (*RaftNode) GetRaftMembers ¶
func (r *RaftNode) GetRaftMembers(ctx context.Context) ([]RaftMember, error)
func (*RaftNode) GetStableApplyIndex ¶
func (*RaftNode) ModuleApply ¶
func (*RaftNode) NotifyLeaderChange ¶
func (*RaftNode) RecordApplyIndex ¶
func (*RaftNode) RecordRaftMember ¶
func (*RaftNode) RegistRaftApplier ¶
func (r *RaftNode) RegistRaftApplier(target interface{})
registRaftApplier use reflect to find out all RaftApplier and register
func (*RaftNode) SetLeaderHost ¶
func (*RaftNode) SetRaftServer ¶
func (r *RaftNode) SetRaftServer(raftServer raftserver.RaftServer)
type RaftNodeConfig ¶
type RaftNodeConfig struct { FlushNumInterval uint64 `json:"flush_num_interval"` FlushTimeIntervalS int `json:"flush_time_interval_s"` TruncateNumInterval uint64 `json:"truncate_num_interval"` NodeProtocol string `json:"node_protocol"` Members []RaftMember `json:"members"` ApplyFlush bool `json:"apply_flush"` ApplyIndex uint64 `json:"-"` }
type SnapshotDB ¶
type SnapshotData ¶
type SnapshotData struct { Header SnapshotItem Key []byte Value []byte }
func DecodeSnapshotData ¶
func DecodeSnapshotData(reader io.Reader) (ret *SnapshotData, err error)
type SnapshotItem ¶
type TaskDistribution ¶
type TaskDistribution struct {
// contains filtered or unexported fields
}
func NewTaskDistribution ¶
func NewTaskDistribution(concurrency int, taskBuffLength int) *TaskDistribution
func (*TaskDistribution) Close ¶
func (t *TaskDistribution) Close()
func (*TaskDistribution) Run ¶
func (t *TaskDistribution) Run(taskIdx int, task func())
type VolumeTaskType ¶
type VolumeTaskType uint8
volume task type
const ( VolumeTaskTypeLock VolumeTaskType = VolumeTaskType(iota + 1) VolumeTaskTypeUnlock )
func (VolumeTaskType) String ¶
func (t VolumeTaskType) String() string
Click to show internal directories.
Click to hide internal directories.