Add retrying logic to wait for other peers during cluster bootstrapping.

This commit is contained in:
Chris Lu
2014-04-11 16:23:58 -07:00
parent 7c82e2316b
commit 008aee0dc1
4 changed files with 44 additions and 15 deletions

View File

@@ -52,21 +52,26 @@ func NewTopology(id string, confFile string, seq sequence.Sequencer, volumeSizeL
}
func (t *Topology) IsLeader() bool {
return t.RaftServer == nil || t.Leader() == t.RaftServer.Name()
if leader, e := t.Leader(); e == nil {
return leader == t.RaftServer.Name()
}
return false
}
func (t *Topology) Leader() string {
func (t *Topology) Leader() (string, error) {
l := ""
if t.RaftServer != nil {
l = t.RaftServer.Leader()
} else {
return "", errors.New("Raft Server not ready yet!")
}
if l == "" {
// We are a single node cluster, we are the leader
return t.RaftServer.Name()
return t.RaftServer.Name(), errors.New("Raft Server not initialized!")
}
return l
return l, nil
}
func (t *Topology) loadConfiguration(configurationFile string) error {