mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
a little refactoring
This commit is contained in:
parent
04380d6a36
commit
0e3140c54c
|
@ -120,20 +120,14 @@ func (fs *FilerServer) setMasterNode(masterNode string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fs *FilerServer) detectHealthyMaster(masterNode string) (master string, e error) {
|
func (fs *FilerServer) detectHealthyMaster(masterNode string) (master string, e error) {
|
||||||
statUrl := "http://" + masterNode + "/stats"
|
if e = checkMaster(masterNode); e != nil {
|
||||||
glog.V(4).Infof("Connecting to %s ...", statUrl)
|
|
||||||
_, e = util.Get(statUrl)
|
|
||||||
if e != nil {
|
|
||||||
fs.masterNodes.Reset()
|
fs.masterNodes.Reset()
|
||||||
for i := 0; i <= 3; i++ {
|
for i := 0; i <= 3; i++ {
|
||||||
master, e = fs.masterNodes.FindMaster()
|
master, e = fs.masterNodes.FindMaster()
|
||||||
if e != nil {
|
if e != nil {
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
statUrl := "http://" + master + "/stats"
|
if e = checkMaster(masterNode); e == nil {
|
||||||
glog.V(4).Infof("Connecting to %s ...", statUrl)
|
|
||||||
_, e = util.Get(statUrl)
|
|
||||||
if e == nil {
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,3 +137,10 @@ func (fs *FilerServer) detectHealthyMaster(masterNode string) (master string, e
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func checkMaster(masterNode string) error {
|
||||||
|
statUrl := "http://" + masterNode + "/stats"
|
||||||
|
glog.V(4).Infof("Connecting to %s ...", statUrl)
|
||||||
|
_, e := util.Get(statUrl)
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue