mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcd: clean up sync
This commit is contained in:
parent
a922947bb0
commit
6f481af383
38
etcd/etcd.go
38
etcd/etcd.go
@ -333,7 +333,6 @@ func (s *Server) run() {
|
|||||||
case s.modeC <- s.mode:
|
case s.modeC <- s.mode:
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
switch s.mode {
|
switch s.mode {
|
||||||
case participant:
|
case participant:
|
||||||
s.runParticipant()
|
s.runParticipant()
|
||||||
@ -389,20 +388,15 @@ func (s *Server) runParticipant() {
|
|||||||
s.apply(node.Next())
|
s.apply(node.Next())
|
||||||
s.send(node.Msgs())
|
s.send(node.Msgs())
|
||||||
if node.IsRemoved() {
|
if node.IsRemoved() {
|
||||||
break
|
log.Printf("Node: %d removed to standby mode\n", s.id)
|
||||||
|
s.initStandby()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Node: %d removed to standby mode\n", s.id)
|
|
||||||
s.initStandby()
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) runStandby() {
|
func (s *Server) runStandby() {
|
||||||
syncDuration := time.Duration(int64(s.clusterConf.SyncInterval * float64(time.Second)))
|
syncDuration := time.Duration(0)
|
||||||
if err := s.syncCluster(); err != nil {
|
|
||||||
log.Println("standby sync:", err)
|
|
||||||
}
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-time.After(syncDuration):
|
case <-time.After(syncDuration):
|
||||||
@ -422,20 +416,18 @@ func (s *Server) runStandby() {
|
|||||||
log.Println("standby join:", err)
|
log.Println("standby join:", err)
|
||||||
continue
|
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
|
||||||
|
// 2. record removeIndex in node to ignore msgDenial and old removal
|
||||||
|
s.node = &v2Raft{
|
||||||
|
Node: raft.New(s.id, defaultHeartbeat, defaultElection),
|
||||||
|
result: make(map[wait]chan interface{}),
|
||||||
|
}
|
||||||
|
s.Store = store.New()
|
||||||
|
s.initParticipant()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
|
||||||
// 2. record removeIndex in node to ignore msgDenial and old removal
|
|
||||||
s.node = &v2Raft{
|
|
||||||
Node: raft.New(s.id, defaultHeartbeat, defaultElection),
|
|
||||||
result: make(map[wait]chan interface{}),
|
|
||||||
}
|
|
||||||
s.Store = store.New()
|
|
||||||
s.initParticipant()
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) apply(ents []raft.Entry) {
|
func (s *Server) apply(ents []raft.Entry) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user