Documentation ¶
Index ¶
- Variables
- func GenerateRaftPeers(config *order.Config) ([]raft.Peer, error)
- func ListSnapshots(logger raft.Logger, snapDir string) []uint64
- func NewNode(opts ...order.Option) (order.Order, error)
- type MemoryStorage
- type Node
- func (n *Node) Commit() chan *pb.Block
- func (n *Node) IsLeader() bool
- func (n *Node) Prepare(tx *pb.Transaction) error
- func (n *Node) Quorum() uint64
- func (n *Node) Ready() bool
- func (n *Node) ReportState(height uint64, hash types.Hash)
- func (n *Node) Start() error
- func (n *Node) Step(ctx context.Context, msg []byte) error
- func (n *Node) Stop()
- type RAFT
- type RAFTConfig
- 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
- type TxPoolConfig
Constants ¶
This section is empty.
Variables ¶
var MaxSnapshotFiles = 5
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 ListSnapshots ¶
ListSnapshots returns a list of RaftIndex of snapshots stored on disk. If a file is corrupted, rename the file.
Types ¶
type MemoryStorage ¶
type MemoryStorage interface { raft.Storage Append(entries []raftpb.Entry) error SetHardState(st raftpb.HardState) error CreateSnapshot(i uint64, cs *raftpb.ConfState, data []byte) (raftpb.Snapshot, error) Compact(compactIndex uint64) error ApplySnapshot(snap raftpb.Snapshot) error }
MemoryStorage is currently backed by etcd/raft.MemoryStorage. This interface is defined to expose dependencies of fsm so that it may be swapped in the future. TODO(jay) Add other necessary methods to this interface once we need them in implementation, e.g. ApplySnapshot.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
type RAFT ¶
type RAFT struct { ElectionTick int `mapstructure:"election_tick"` HeartbeatTick int `mapstructure:"heartbeat_tick"` MaxSizePerMsg uint64 `mapstructure:"max_size_per_msg"` MaxInflightMsgs int `mapstructure:"max_inflight_msgs"` CheckQuorum bool `mapstructure:"check_quorum"` PreVote bool `mapstructure:"pre_vote"` DisableProposalForwarding bool `mapstructure:"disable_proposal_forwarding"` TxPoolConfig TxPoolConfig `mapstructure:"tx_pool"` }
type RAFTConfig ¶
type RAFTConfig struct {
RAFT RAFT
}
type RaftStorage ¶
type RaftStorage struct { SnapshotCatchUpEntries uint64 // contains filtered or unexported fields }
RaftStorage encapsulates storages needed for etcd/raft data, i.e. memory, wal
func CreateStorage ¶
func CreateStorage( lg raft.Logger, walDir string, snapDir string, dbDir string, ram MemoryStorage, ) (*RaftStorage, storage.Storage, 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.