raft/etcd: recover node

This commit is contained in:
Yicheng Qin
2014-08-22 14:00:46 -07:00
parent 63489b9ef5
commit a28dc4559b
5 changed files with 21 additions and 21 deletions

View File

@@ -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 {