mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
Fix looking for master nodes.
This commit is contained in:
parent
99aee22e08
commit
c7cf4fa46c
|
@ -43,7 +43,9 @@ func NewMasterNodes(bootstrapNode string) (mn *MasterNodes) {
|
|||
return
|
||||
}
|
||||
func (mn *MasterNodes) reset() {
|
||||
glog.V(4).Infof("Resetting master nodes: %v", mn)
|
||||
if len(mn.nodes) > 1 && mn.lastNode > 0 {
|
||||
glog.V(0).Infof("Reset master %s from: %v", mn.nodes[mn.lastNode], mn.nodes)
|
||||
mn.lastNode = -mn.lastNode
|
||||
}
|
||||
}
|
||||
|
@ -58,9 +60,9 @@ func (mn *MasterNodes) findMaster() (string, error) {
|
|||
if len(masters) == 0 {
|
||||
continue
|
||||
}
|
||||
mn.nodes = masters
|
||||
mn.nodes = append(masters, m)
|
||||
mn.lastNode = rand.Intn(len(mn.nodes))
|
||||
glog.V(2).Info("current master node is :", mn.nodes[mn.lastNode])
|
||||
glog.V(2).Infof("current master nodes is %v", mn)
|
||||
break
|
||||
} else {
|
||||
glog.V(4).Infof("Failed listing masters on %s: %v", m, e)
|
||||
|
@ -321,9 +323,11 @@ func (s *Store) SendHeartbeatToMaster() (masterNode string, secretKey security.S
|
|||
var ret operation.JoinResult
|
||||
if err := json.Unmarshal(jsonBlob, &ret); err != nil {
|
||||
glog.V(0).Infof("Failed to join %s with response: %s", joinUrl, string(jsonBlob))
|
||||
s.masterNodes.reset()
|
||||
return masterNode, "", err
|
||||
}
|
||||
if ret.Error != "" {
|
||||
s.masterNodes.reset()
|
||||
return masterNode, "", errors.New(ret.Error)
|
||||
}
|
||||
s.volumeSizeLimit = ret.VolumeSizeLimit
|
||||
|
|
Loading…
Reference in a new issue