mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-09-19 15:47:57 +08:00
add listener for volumd id location for benchmark tool
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||
"github.com/chrislusf/seaweedfs/weed/pb/master_pb"
|
||||
"github.com/chrislusf/seaweedfs/weed/util"
|
||||
"math/rand"
|
||||
)
|
||||
|
||||
type MasterClient struct {
|
||||
@@ -32,6 +33,12 @@ func (mc *MasterClient) GetMaster() string {
|
||||
return mc.currentMaster
|
||||
}
|
||||
|
||||
func (mc *MasterClient) WaitUntilConnected() {
|
||||
for mc.currentMaster == "" {
|
||||
time.Sleep(time.Duration(rand.Int31n(200)) * time.Millisecond)
|
||||
}
|
||||
}
|
||||
|
||||
func (mc *MasterClient) KeepConnectedToMaster() {
|
||||
glog.V(0).Infof("%s bootstraps with masters %v", mc.name, mc.masters)
|
||||
for {
|
||||
@@ -50,9 +57,6 @@ func (mc *MasterClient) tryAllMasters() {
|
||||
return err
|
||||
}
|
||||
|
||||
glog.V(0).Infof("Connected to %v", master)
|
||||
mc.currentMaster = master
|
||||
|
||||
if err = stream.Send(&master_pb.ClientListenRequest{Name: mc.name}); err != nil {
|
||||
glog.V(0).Infof("failed to send to %s: %v", master, err)
|
||||
return err
|
||||
@@ -74,9 +78,17 @@ func (mc *MasterClient) tryAllMasters() {
|
||||
for _, deletedVid := range volumeLocation.DeletedVids {
|
||||
mc.deleteLocation(deletedVid, loc)
|
||||
}
|
||||
|
||||
if mc.currentMaster == "" {
|
||||
glog.V(0).Infof("Connected to %v", master)
|
||||
mc.currentMaster = master
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
mc.currentMaster = ""
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user