Revert "use the first entry to bootstrap master cluster"
This reverts commit 40c8725ffa.
This commit is contained in:
@@ -3,6 +3,7 @@ package weed_server
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"reflect"
|
"reflect"
|
||||||
@@ -70,8 +71,8 @@ func NewRaftServer(r *mux.Router, peers []string, httpAddr string, dataDir strin
|
|||||||
for _, peer := range s.peers {
|
for _, peer := range s.peers {
|
||||||
s.raftServer.AddPeer(peer, "http://"+peer)
|
s.raftServer.AddPeer(peer, "http://"+peer)
|
||||||
}
|
}
|
||||||
|
time.Sleep(time.Duration(1000+rand.Int31n(3000)) * time.Millisecond)
|
||||||
if s.raftServer.IsLogEmpty() && isTheFirstOne(httpAddr, s.peers) {
|
if s.raftServer.IsLogEmpty() {
|
||||||
// Initialize the server by joining itself.
|
// Initialize the server by joining itself.
|
||||||
glog.V(0).Infoln("Initializing new cluster")
|
glog.V(0).Infoln("Initializing new cluster")
|
||||||
|
|
||||||
@@ -128,11 +129,3 @@ func isPeersChanged(dir string, self string, peers []string) (oldPeers []string,
|
|||||||
return oldPeers, !reflect.DeepEqual(peers, oldPeers)
|
return oldPeers, !reflect.DeepEqual(peers, oldPeers)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func isTheFirstOne(self string, peers []string) bool {
|
|
||||||
sort.Strings(peers)
|
|
||||||
if len(peers)<=0{
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return self == peers[0]
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user