mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
raft/etcd: recover node
This commit is contained in:
13
raft/node.go
13
raft/node.go
@@ -52,10 +52,15 @@ func New(id int64, heartbeat, election tick) *Node {
|
||||
return n
|
||||
}
|
||||
|
||||
func Recover(id int64, ents []Entry, state State, heartbeat, election tick) *Node {
|
||||
func Recover(s *Snapshot, id int64, ents []Entry, state State, heartbeat, election tick) *Node {
|
||||
n := New(id, heartbeat, election)
|
||||
if s != nil {
|
||||
n.sm.restore(*s)
|
||||
}
|
||||
n.sm.loadEnts(ents)
|
||||
n.sm.loadState(state)
|
||||
if !state.IsEmpty() {
|
||||
n.sm.loadState(state)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
@@ -231,10 +236,6 @@ func (n *Node) UpdateConf(t int64, c *Config) {
|
||||
n.propose(t, data)
|
||||
}
|
||||
|
||||
func (n *Node) Restore(s Snapshot) bool {
|
||||
return n.sm.restore(s)
|
||||
}
|
||||
|
||||
// UnstableEnts retuens all the entries that need to be persistent.
|
||||
// The first return value is offset, and the second one is unstable entries.
|
||||
func (n *Node) UnstableEnts() []Entry {
|
||||
|
||||
Reference in New Issue
Block a user