Konstantin Lebedev
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
5 additions and
7 deletions
-
weed/server/master_server.go
-
weed/wdclient/masterclient.go
|
|
@ -276,11 +276,9 @@ func (ms *MasterServer) startAdminScripts() { |
|
|
|
go commandEnv.MasterClient.KeepConnectedToMaster() |
|
|
|
|
|
|
|
go func() { |
|
|
|
commandEnv.MasterClient.WaitUntilConnected() |
|
|
|
|
|
|
|
for { |
|
|
|
time.Sleep(time.Duration(sleepMinutes) * time.Minute) |
|
|
|
if ms.Topo.IsLeader() { |
|
|
|
if ms.Topo.IsLeader() && ms.MasterClient.GetMaster() != "" { |
|
|
|
shellOptions.FilerAddress = ms.GetOneFiler(cluster.FilerGroupName(*shellOptions.FilerGroup)) |
|
|
|
if shellOptions.FilerAddress == "" { |
|
|
|
continue |
|
|
|
|
|
@ -93,7 +93,10 @@ func (mc *MasterClient) GetMasters() map[string]pb.ServerAddress { |
|
|
|
} |
|
|
|
|
|
|
|
func (mc *MasterClient) WaitUntilConnected() { |
|
|
|
for mc.currentMaster == "" { |
|
|
|
for { |
|
|
|
if mc.currentMaster != "" { |
|
|
|
return |
|
|
|
} |
|
|
|
time.Sleep(time.Duration(rand.Int31n(200)) * time.Millisecond) |
|
|
|
} |
|
|
|
} |
|
|
@ -135,7 +138,6 @@ func (mc *MasterClient) FindLeaderFromOtherPeers(myMasterAddress pb.ServerAddres |
|
|
|
func (mc *MasterClient) tryAllMasters() { |
|
|
|
var nextHintedLeader pb.ServerAddress |
|
|
|
for _, master := range mc.masters { |
|
|
|
|
|
|
|
nextHintedLeader = mc.tryConnectToMaster(master) |
|
|
|
for nextHintedLeader != "" { |
|
|
|
nextHintedLeader = mc.tryConnectToMaster(nextHintedLeader) |
|
|
@ -228,9 +230,7 @@ func (mc *MasterClient) tryConnectToMaster(master pb.ServerAddress) (nextHintedL |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
if gprcErr != nil { |
|
|
|
stats.MasterClientConnectCounter.WithLabelValues(stats.Failed).Inc() |
|
|
|