1
0
Fork 0
mirror of https://github.com/chrislusf/seaweedfs synced 2024-07-04 08:06:53 +02:00

a little refactoring

This commit is contained in:
Chris Lu 2016-06-06 23:50:27 -07:00
parent 04380d6a36
commit 0e3140c54c

View file

@ -120,20 +120,14 @@ func (fs *FilerServer) setMasterNode(masterNode string) {
}
func (fs *FilerServer) detectHealthyMaster(masterNode string) (master string, e error) {
statUrl := "http://" + masterNode + "/stats"
glog.V(4).Infof("Connecting to %s ...", statUrl)
_, e = util.Get(statUrl)
if e != nil {
if e = checkMaster(masterNode); e != nil {
fs.masterNodes.Reset()
for i := 0; i <= 3; i++ {
master, e = fs.masterNodes.FindMaster()
if e != nil {
continue
} else {
statUrl := "http://" + master + "/stats"
glog.V(4).Infof("Connecting to %s ...", statUrl)
_, e = util.Get(statUrl)
if e == nil {
if e = checkMaster(masterNode); e == nil {
break
}
}
@ -143,3 +137,10 @@ func (fs *FilerServer) detectHealthyMaster(masterNode string) (master string, e
}
return
}
func checkMaster(masterNode string) error {
statUrl := "http://" + masterNode + "/stats"
glog.V(4).Infof("Connecting to %s ...", statUrl)
_, e := util.Get(statUrl)
return e
}