Merge pull request #11 from xiangli-cmu/master

return error when cannot join the cluster
This commit is contained in:
Xiang Li 2013-07-10 17:49:57 -07:00
commit 78cb13cf19
2 changed files with 13 additions and 2 deletions

View File

@ -501,6 +501,9 @@ func joinCluster(s *raft.Server, serverName string) error {
resp, err := t.Post(fmt.Sprintf("%s/join", serverName), &b)
for {
if err != nil {
return fmt.Errorf("Unable to join: %v", err)
}
if resp != nil {
defer resp.Body.Close()
if resp.StatusCode == http.StatusOK {

View File

@ -26,7 +26,11 @@ func (t transporter) SendAppendEntriesRequest(server *raft.Server, peer *raft.Pe
debug("Send LogEntries to %s ", peer.Name())
resp, _ := t.Post(fmt.Sprintf("%s/log/append", peer.Name()), &b)
resp, err := t.Post(fmt.Sprintf("%s/log/append", peer.Name()), &b)
if err != nil {
debug("Cannot send AppendEntriesRequest to %s : %s", peer.Name(), err)
}
if resp != nil {
defer resp.Body.Close()
@ -47,7 +51,11 @@ func (t transporter) SendVoteRequest(server *raft.Server, peer *raft.Peer, req *
debug("Send Vote to %s", peer.Name())
resp, _ := t.Post(fmt.Sprintf("%s/vote", peer.Name()), &b)
resp, err := t.Post(fmt.Sprintf("%s/vote", peer.Name()), &b)
if err != nil {
debug("Cannot send VoteRequest to %s : %s", peer.Name(), err)
}
if resp != nil {
defer resp.Body.Close()