Merge pull request #31 from xiangli-cmu/master

do not try the empty machine name
This commit is contained in:
polvi 2013-07-24 17:26:52 -07:00
commit d0ec1007a2

14
etcd.go
View File

@ -225,6 +225,9 @@ func startRaft(securityType int) {
raftServer.SetElectionTimeout(ELECTIONTIMTOUT)
raftServer.SetHeartbeatTimeout(HEARTBEATTIMEOUT)
// start to response to raft requests
go startRaftTransport(info.RaftPort, securityType)
if raftServer.IsLogEmpty() {
// start as a leader in a new cluster
@ -249,10 +252,12 @@ func startRaft(securityType int) {
// start as a follower in a existing cluster
} else {
raftServer.StartFollower()
raftServer.StartFollower(false)
for _, machine := range cluster {
if len(machine) == 0 {
continue
}
err = joinCluster(raftServer, machine)
if err != nil {
debug("cannot join to cluster via machine %s %s", machine, err)
@ -268,7 +273,7 @@ func startRaft(securityType int) {
} else {
// rejoin the previous cluster
raftServer.StartFollower()
raftServer.StartFollower(true)
debug("%s restart as a follower", raftServer.Name())
}
@ -277,9 +282,6 @@ func startRaft(securityType int) {
go raftServer.Snapshot()
}
// start to response to raft requests
go startRaftTransport(info.RaftPort, securityType)
}
// Create transporter using by raft server