Documentation
¶
Index ¶
- Variables
- func IsEmptyRaftReady(rd raft.Ready) bool
- type KVLogDB
- func (l *KVLogDB) Close() error
- func (l *KVLogDB) GetAllSnapshots(shardID uint64) ([]raftpb.Snapshot, error)
- func (l *KVLogDB) GetSnapshot(shardID uint64) (raftpb.Snapshot, error)
- func (l *KVLogDB) IterateEntries(ents []raftpb.Entry, size uint64, shardID uint64, replicaID uint64, low uint64, ...) ([]raftpb.Entry, uint64, error)
- func (l *KVLogDB) Name() string
- func (l *KVLogDB) NewWorkerContext() *WorkerContext
- func (l *KVLogDB) ReadRaftState(shardID uint64, replicaID uint64, snapshotIndex uint64) (RaftState, error)
- func (l *KVLogDB) RemoveEntriesTo(shardID uint64, replicaID uint64, index uint64) error
- func (l *KVLogDB) RemoveReplicaData(shardID uint64) error
- func (l *KVLogDB) RemoveSnapshot(shardID uint64, index uint64) error
- func (l *KVLogDB) SaveRaftState(shardID uint64, replicaID uint64, rd raft.Ready, ctx *WorkerContext) error
- type LogDB
- type RaftState
- type WorkerContext
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func IsEmptyRaftReady ¶
func IsEmptyRaftReady(rd raft.Ready) bool
Types ¶
type KVLogDB ¶
type KVLogDB struct {
// contains filtered or unexported fields
}
KVLogDB is a LogDB implementation built on top of a Key-Value store.
func NewKVLogDB ¶
func NewKVLogDB(ms storage.KVMetadataStore, logger *zap.Logger) *KVLogDB
func (*KVLogDB) GetAllSnapshots ¶
func (*KVLogDB) GetSnapshot ¶
func (*KVLogDB) IterateEntries ¶
func (*KVLogDB) NewWorkerContext ¶
func (l *KVLogDB) NewWorkerContext() *WorkerContext
func (*KVLogDB) ReadRaftState ¶
func (*KVLogDB) RemoveEntriesTo ¶
TODO: check whether index below is larger than the max index RemoveEntriesTo deletes all raft log entries between [0, index].
func (*KVLogDB) RemoveReplicaData ¶
func (*KVLogDB) RemoveSnapshot ¶
func (*KVLogDB) SaveRaftState ¶
func (l *KVLogDB) SaveRaftState(shardID uint64, replicaID uint64, rd raft.Ready, ctx *WorkerContext) error
type LogDB ¶
type LogDB interface {
// Name returns the type name of the ILogDB instance.
Name() string
// Close closes the ILogDB instance.
Close() error
// NewWorkerContext creates a new worker context which used by `SaveRaftState`.
NewWorkerContext() *WorkerContext
// SaveRaftState atomically saves the Raft states, log entries and snapshots
// metadata found in the pb.Update list to the log DB. shardID is a 1-based
// ID of the worker invoking the SaveRaftState method, as each worker
// accesses the log DB from its own thread, SaveRaftState will never be
// concurrently called with the same shardID.
SaveRaftState(shardID uint64,
replicaID uint64, rd raft.Ready, ctx *WorkerContext) error
// IterateEntries returns the continuous Raft log entries of the specified
// Raft node between the index value range of [low, high) up to a max size
// limit of maxSize bytes. It returns the located log entries, their total
// size in bytes and the occurred error.
IterateEntries(ents []raftpb.Entry,
size uint64, shardID uint64, replicaID uint64, low uint64,
high uint64, maxSize uint64) ([]raftpb.Entry, uint64, error)
// ReadRaftState returns the persistented raft state found in Log DB.
ReadRaftState(shardID uint64, replicaID uint64, snapshotIndex uint64) (RaftState, error)
// RemoveEntriesTo removes entries with indexes between (0, index].
RemoveEntriesTo(shardID uint64, replicaID uint64, index uint64) error
// GetSnapshot returns the most recent snapshot metadata for the specified
// replica.
GetSnapshot(shardID uint64) (raftpb.Snapshot, error)
// GetAllSnapshots returns all snapshots known to the LogDB.
GetAllSnapshots(shardID uint64) ([]raftpb.Snapshot, error)
// RemoveSnapshot removes the specified snapshot.
RemoveSnapshot(shardID uint64, index uint64) error
// RemoveReplicaData removes all LogDB data that belongs to the specified
// replica.
RemoveReplicaData(shardID uint64) error
}
LogDB is the interface to be implemented for concrete LogDB types used for saving raft logs and states.
type RaftState ¶
type RaftState struct {
// State is the Raft state persistent to the disk
State raftpb.HardState
// FirstIndex is the index of the first entry to iterate
FirstIndex uint64
// EntryCount is the number of entries to iterate
EntryCount uint64
}
RaftState is the persistent Raft state found in the LogDB.
type WorkerContext ¶
type WorkerContext struct {
// contains filtered or unexported fields
}
WorkerContext is the per worker context owned and used by each raft worker. It contains write batch and buffers that can be reused across iterations.
func (*WorkerContext) Close ¶
func (w *WorkerContext) Close()
func (*WorkerContext) Reset ¶
func (w *WorkerContext) Reset()
Reset resets the worker context so it can be reused.
Click to show internal directories.
Click to hide internal directories.