fix(server): set joinIndex when recovered

This commit is contained in:
Yicheng Qin
2014-05-31 10:03:39 -07:00
parent 37796ed84c
commit d7768635fd
3 changed files with 11 additions and 3 deletions

View File

@@ -214,6 +214,7 @@ func (s *PeerServer) FindCluster(discoverURL string, peers []string) (toStart bo
// TODO(yichengq): Think about the action that should be done
// if it cannot connect any of the previous known node.
log.Debugf("%s is restarting the cluster %v", name, possiblePeers)
s.SetJoinIndex(s.raftServer.CommitIndex())
toStart = true
return
}

View File

@@ -36,8 +36,9 @@ type standbyInfo struct {
}
type StandbyServer struct {
Config StandbyServerConfig
client *Client
Config StandbyServerConfig
client *Client
raftServer raft.Server
standbyInfo
joinIndex uint64
@@ -62,6 +63,10 @@ func NewStandbyServer(config StandbyServerConfig, client *Client) *StandbyServer
return s
}
func (s *StandbyServer) SetRaftServer(raftServer raft.Server) {
s.raftServer = raftServer
}
func (s *StandbyServer) Start() {
s.Lock()
defer s.Unlock()
@@ -237,7 +242,7 @@ func (s *StandbyServer) syncCluster(peerURLs []string) error {
func (s *StandbyServer) join(peer string) error {
for _, url := range s.ClusterURLs() {
if s.Config.PeerURL == url {
s.joinIndex = 0
s.joinIndex = s.raftServer.CommitIndex()
return nil
}
}