let knowen peer to rejoin to the cluster
parent
d0da319e26
commit
b9e1da8ac2
1
peer.go
1
peer.go
|
@ -250,6 +250,7 @@ func (p *Peer) sendVoteRequest(req *RequestVoteRequest, c chan *RequestVoteRespo
|
||||||
debugln("peer.vote: ", p.server.Name(), "->", p.Name())
|
debugln("peer.vote: ", p.server.Name(), "->", p.Name())
|
||||||
req.peer = p
|
req.peer = p
|
||||||
if resp := p.server.Transporter().SendVoteRequest(p.server, p, req); resp != nil {
|
if resp := p.server.Transporter().SendVoteRequest(p.server, p, req); resp != nil {
|
||||||
|
debugln("peer.vote: recv", p.server.Name(), "<-", p.Name())
|
||||||
resp.peer = p
|
resp.peer = p
|
||||||
c <- resp
|
c <- resp
|
||||||
}
|
}
|
||||||
|
|
|
@ -516,6 +516,8 @@ func (s *Server) candidateLoop() {
|
||||||
} else if resp.Term > s.currentTerm {
|
} else if resp.Term > s.currentTerm {
|
||||||
s.debugln("server.candidate.vote.failed")
|
s.debugln("server.candidate.vote.failed")
|
||||||
s.setCurrentTerm(resp.Term, "", false)
|
s.setCurrentTerm(resp.Term, "", false)
|
||||||
|
} else {
|
||||||
|
s.debugln("server.candidate.vote: denied")
|
||||||
}
|
}
|
||||||
|
|
||||||
case e := <-s.c:
|
case e := <-s.c:
|
||||||
|
@ -808,7 +810,7 @@ func (s *Server) AddPeer(name string) error {
|
||||||
|
|
||||||
// Do not allow peers to be added twice.
|
// Do not allow peers to be added twice.
|
||||||
if s.peers[name] != nil {
|
if s.peers[name] != nil {
|
||||||
return DuplicatePeerError
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only add the peer if it doesn't have the same name.
|
// Only add the peer if it doesn't have the same name.
|
||||||
|
|
|
@ -403,7 +403,7 @@ func TestServerMultiNode(t *testing.T) {
|
||||||
}
|
}
|
||||||
mutex.RUnlock()
|
mutex.RUnlock()
|
||||||
|
|
||||||
for i := 0; i < 20; i++ {
|
for i := 0; i < 200000; i++ {
|
||||||
retry := 0
|
retry := 0
|
||||||
fmt.Println("Round ", i)
|
fmt.Println("Round ", i)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue