etcd: clean up sync

This commit is contained in:
Xiang Li 2014-07-16 23:17:08 -07:00 committed by Yicheng Qin
parent a922947bb0
commit 6f481af383

View File

@ -333,7 +333,6 @@ func (s *Server) run() {
case s.modeC <- s.mode:
default:
}
switch s.mode {
case participant:
s.runParticipant()
@ -389,20 +388,15 @@ func (s *Server) runParticipant() {
s.apply(node.Next())
s.send(node.Msgs())
if node.IsRemoved() {
break
}
}
log.Printf("Node: %d removed to standby mode\n", s.id)
s.initStandby()
return
}
}
}
func (s *Server) runStandby() {
syncDuration := time.Duration(int64(s.clusterConf.SyncInterval * float64(time.Second)))
if err := s.syncCluster(); err != nil {
log.Println("standby sync:", err)
}
syncDuration := time.Duration(0)
for {
select {
case <-time.After(syncDuration):
@ -422,9 +416,6 @@ func (s *Server) runStandby() {
log.Println("standby join:", err)
continue
}
break
}
log.Printf("Node: %d removed to participant mode\n", s.id)
// TODO(yichengq): use old v2Raft
// 1. reject proposal in leader state when sm is removed
@ -437,6 +428,7 @@ func (s *Server) runStandby() {
s.initParticipant()
return
}
}
func (s *Server) apply(ents []raft.Entry) {
offset := s.node.Applied() - int64(len(ents)) + 1