server: save correct nodeId for participant

This commit is contained in:
Yicheng Qin 2014-07-28 15:58:28 -07:00
parent 12dd380d26
commit a6132d459f

View File

@ -113,14 +113,16 @@ func newParticipant(id int64, pubAddr string, raftPubAddr string, dir string, cl
if !os.IsNotExist(err) {
return nil, err
}
p.id = id
p.pubAddr = pubAddr
p.raftPubAddr = raftPubAddr
if w, err = wal.New(walPath); err != nil {
return nil, err
}
w.SaveInfo(p.id)
p.id = id
p.pubAddr = pubAddr
p.raftPubAddr = raftPubAddr
p.node.Node = raft.New(p.id, defaultHeartbeat, defaultElection)
log.Printf("id=%x participant.new path=%s\n", p.id, walPath)
} else {
n, err := w.LoadNode()
if err != nil {
@ -128,6 +130,7 @@ func newParticipant(id int64, pubAddr string, raftPubAddr string, dir string, cl
}
p.id = n.Id
p.node.Node = raft.Recover(n.Id, n.Ents, n.State, defaultHeartbeat, defaultElection)
log.Printf("id=%x participant.load path=%s\n", p.id, walPath)
}
p.w = w