Documentation
¶
Index ¶
- Constants
- Variables
- func ClassifyClusterReConfig(currentConfig, updatedConfig *types.ClusterConfig) (nodes bool, consensus bool, ca bool, admins bool)
- func ListSnapshots(logger *logger.SugarLogger, snapDir string) []uint64
- type BlockLedgerReader
- type BlockReplicator
- func (br *BlockReplicator) Close() (err error)
- func (br *BlockReplicator) GetLeaderID() uint64
- func (br *BlockReplicator) IsIDRemoved(id uint64) bool
- func (br *BlockReplicator) IsLeader() *ierrors.NotLeaderError
- func (br *BlockReplicator) Process(ctx context.Context, m raftpb.Message) error
- func (br *BlockReplicator) RaftID() uint64
- func (br *BlockReplicator) ReportSnapshot(id uint64, status raft.SnapshotStatus)
- func (br *BlockReplicator) ReportUnreachable(id uint64)
- func (br *BlockReplicator) Start()
- func (br *BlockReplicator) Submit(block *types.Block) error
- type Config
- type PendingTxsReleaser
- type RaftStorage
- func (rs *RaftStorage) ApplySnapshot(snap raftpb.Snapshot)
- func (rs *RaftStorage) Close() error
- func (rs *RaftStorage) Snapshot() raftpb.Snapshot
- func (rs *RaftStorage) Store(entries []raftpb.Entry, hardstate raftpb.HardState, snapshot raftpb.Snapshot) error
- func (rs *RaftStorage) TakeSnapshot(i uint64, cs raftpb.ConfState, data []byte) error
Constants ¶
const ( // DefaultSnapshotCatchUpEntries is the default number of entries // to preserve in memory when a snapshot is taken. This is for // slow followers to catch up. DefaultSnapshotCatchUpEntries = uint64(4) )
Variables ¶
var MaxSnapshotFiles = 4
MaxSnapshotFiles defines max number of etcd/raft snapshot files to retain on filesystem. Snapshot files are read from newest to oldest, until first intact file is found. The more snapshot files we keep around, the more we mitigate the impact of a corrupted snapshots. This is exported for testing purpose. This MUST be greater equal than 1.
Functions ¶
func ClassifyClusterReConfig ¶
func ClassifyClusterReConfig(currentConfig, updatedConfig *types.ClusterConfig) (nodes bool, consensus bool, ca bool, admins bool)
ClassifyClusterReConfig detects the kind of changes that happened in the ClusterConfig.
func ListSnapshots ¶
func ListSnapshots(logger *logger.SugarLogger, snapDir string) []uint64
ListSnapshots returns a list of RaftIndex of snapshots stored on disk. If a file is corrupted, rename the file.
Types ¶
type BlockLedgerReader ¶
type BlockReplicator ¶
type BlockReplicator struct {
// contains filtered or unexported fields
}
func NewBlockReplicator ¶
func NewBlockReplicator(conf *Config) (*BlockReplicator, error)
NewBlockReplicator creates a new BlockReplicator.
func (*BlockReplicator) Close ¶
func (br *BlockReplicator) Close() (err error)
Close signals the internal go-routine to stop and waits for it to exit. If the component is already closed, and error is returned.
func (*BlockReplicator) GetLeaderID ¶
func (br *BlockReplicator) GetLeaderID() uint64
func (*BlockReplicator) IsIDRemoved ¶
func (br *BlockReplicator) IsIDRemoved(id uint64) bool
func (*BlockReplicator) IsLeader ¶
func (br *BlockReplicator) IsLeader() *ierrors.NotLeaderError
func (*BlockReplicator) RaftID ¶
func (br *BlockReplicator) RaftID() uint64
func (*BlockReplicator) ReportSnapshot ¶
func (br *BlockReplicator) ReportSnapshot(id uint64, status raft.SnapshotStatus)
func (*BlockReplicator) ReportUnreachable ¶
func (br *BlockReplicator) ReportUnreachable(id uint64)
func (*BlockReplicator) Start ¶
func (br *BlockReplicator) Start()
Start an internal go-routine to serve the main replication loop.
type Config ¶
type Config struct { LocalConf *config.LocalConfiguration ClusterConfig *types.ClusterConfig LedgerReader BlockLedgerReader Transport *comm.HTTPTransport BlockOneQueueBarrier *queue.OneQueueBarrier PendingTxs PendingTxsReleaser Logger *logger.SugarLogger }
Config holds the configuration information required to initialize the block replicator.
type PendingTxsReleaser ¶
type RaftStorage ¶
type RaftStorage struct { SnapshotCatchUpEntries uint64 MemoryStorage *raft.MemoryStorage // contains filtered or unexported fields }
RaftStorage encapsulates storages needed for etcd/raft data, i.e. memory, wal
func CreateStorage ¶
func CreateStorage(lg *logger.SugarLogger, walDir string, snapDir string) (*RaftStorage, error)
CreateStorage attempts to create a storage to persist etcd/raft data. If data presents in specified disk, they are loaded to reconstruct storage state.
func (*RaftStorage) ApplySnapshot ¶
func (rs *RaftStorage) ApplySnapshot(snap raftpb.Snapshot)
ApplySnapshot applies snapshot to local memory storage
func (*RaftStorage) Snapshot ¶
func (rs *RaftStorage) Snapshot() raftpb.Snapshot
Snapshot returns the latest snapshot stored in memory
func (*RaftStorage) Store ¶
func (rs *RaftStorage) Store(entries []raftpb.Entry, hardstate raftpb.HardState, snapshot raftpb.Snapshot) error
Store persists etcd/raft data
func (*RaftStorage) TakeSnapshot ¶
TakeSnapshot takes a snapshot at index i from MemoryStorage, and persists it to wal and disk.