Documentation ¶
Index ¶
- func AdvanceTicks(n etcdraft.Node, electionTicks int)
- func MustGetAppliedIndex(s storage.Storage) uint64
- type ApplyEntry
- type Node
- func (r *Node) Apply() chan ApplyEntry
- func (r *Node) DoneC() chan struct{}
- func (r *Node) GetAppliedIndex() uint64
- func (r *Node) GetCommittedIndex() uint64
- func (r *Node) GetTerm() uint64
- func (r *Node) MsgSnapC() chan raftpb.Message
- func (r *Node) NewPeerListener(peerURLs types.URLs) (err error)
- func (r *Node) PeerHandlerServe()
- func (r *Node) Run(rh *ReadyHandler)
- func (r *Node) SetAppliedIndex(v uint64)
- func (r *Node) SetCommittedIndex(v uint64)
- func (r *Node) SetPeerHandler()
- func (r *Node) SetTerm(v uint64)
- func (r *Node) Stop()
- func (r *Node) StopPeerListener() error
- type NodeConfig
- type ReadyHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AdvanceTicks ¶
AdvanceTicks advances ticks of Raft node. This can be used for fast-forwarding election ticks in multi data-center deployments, thus speeding up election process.
func MustGetAppliedIndex ¶
MustGetAppliedIndex get the applied raft index, if occur error, fatal
Types ¶
type ApplyEntry ¶
type ApplyEntry struct { Entries []raftpb.Entry Snapshot raftpb.Snapshot // Notifyc synchronizes etcd server applies with the raft node Notifyc chan struct{} }
ApplyEntry contains entries, Snapshot to be applied. Once an ApplyEntry is consumed, the entries will be persisted to to raft storage concurrently; the application must read raftDone before assuming the raft messages are stable.
type Node ¶
type Node struct { NodeConfig // contains filtered or unexported fields }
Node represents a raft node
func (*Node) GetAppliedIndex ¶
GetAppliedIndex get the applied raft index
func (*Node) GetCommittedIndex ¶
GetCommittedIndex get the committed raft index
func (*Node) NewPeerListener ¶
NewPeerListener create listener of peer
func (*Node) Run ¶
func (r *Node) Run(rh *ReadyHandler)
Run must keep run as fast as possible If execution is too slow, ticker will suffer, then tickHeartbeat(tickElection) will be influenced
func (*Node) SetAppliedIndex ¶
SetAppliedIndex set the applied raft index, not used
func (*Node) SetCommittedIndex ¶
SetCommittedIndex set the committed raft index
func (*Node) SetPeerHandler ¶
func (r *Node) SetPeerHandler()
SetPeerHandler set the handler of raft transport
func (*Node) StopPeerListener ¶
StopPeerListener stop the listener of peer
type NodeConfig ¶
type NodeConfig struct { // to check if msg receiver is removed from cluster IsIDRemoved func(id uint64) bool etcdraft.Node //raftStorage *raft.MemoryStorage //storage Storage //store raft log Storage storage.Storage //MetadataStorage MetadataStorage Heartbeat time.Duration // for logging // Transport specifies the Transport to send and receive msgs to members. // Sending messages MUST NOT block. It is okay to drop messages, since // clients should timeout and reissue their messages. // If Transport is nil, server will panic. Transport rafthttp.Transporter PeerListener []*peerListener }
NodeConfig is the config of raft node
type ReadyHandler ¶
type ReadyHandler struct { GetLead func() (lead uint64) UpdateLead func(lead uint64) UpdateLeadership func(leadChange bool) UpdateCommittedIndex func(uint64) }
ReadyHandler contains a set of EtcdServer operations to be called by Node, and helps decouple state machine logic from Raft algorithms. TODO: add a state machine interface to ApplyEntry the commit entries and do Snapshot/recover