diff options
Diffstat (limited to 'weed/wdclient/masterclient.go')
| -rw-r--r-- | weed/wdclient/masterclient.go | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/weed/wdclient/masterclient.go b/weed/wdclient/masterclient.go index 5280305e2..b1b9d474e 100644 --- a/weed/wdclient/masterclient.go +++ b/weed/wdclient/masterclient.go @@ -18,7 +18,7 @@ type MasterClient struct { clientType string clientHost pb.ServerAddress currentMaster pb.ServerAddress - masters []pb.ServerAddress + masters map[string]pb.ServerAddress grpcDialOption grpc.DialOption vidMap @@ -26,7 +26,7 @@ type MasterClient struct { OnPeerUpdate func(update *master_pb.ClusterNodeUpdate) } -func NewMasterClient(grpcDialOption grpc.DialOption, clientType string, clientHost pb.ServerAddress, clientDataCenter string, masters []pb.ServerAddress) *MasterClient { +func NewMasterClient(grpcDialOption grpc.DialOption, clientType string, clientHost pb.ServerAddress, clientDataCenter string, masters map[string]pb.ServerAddress) *MasterClient { return &MasterClient{ clientType: clientType, clientHost: clientHost, @@ -41,6 +41,11 @@ func (mc *MasterClient) GetMaster() pb.ServerAddress { return mc.currentMaster } +func (mc *MasterClient) GetMasters() map[string]pb.ServerAddress { + mc.WaitUntilConnected() + return mc.masters +} + func (mc *MasterClient) WaitUntilConnected() { for mc.currentMaster == "" { time.Sleep(time.Duration(rand.Int31n(200)) * time.Millisecond) @@ -154,6 +159,14 @@ func (mc *MasterClient) tryConnectToMaster(master pb.ServerAddress) (nextHintedL glog.V(1).Infof("%s: %s masterClient removes volume %d", mc.clientType, loc.Url, deletedVid) mc.deleteLocation(deletedVid, loc) } + for _, newEcVid := range resp.VolumeLocation.NewEcVids { + glog.V(1).Infof("%s: %s masterClient adds ec volume %d", mc.clientType, loc.Url, newEcVid) + mc.addEcLocation(newEcVid, loc) + } + for _, deletedEcVid := range resp.VolumeLocation.DeletedEcVids { + glog.V(1).Infof("%s: %s masterClient removes ec volume %d", mc.clientType, loc.Url, deletedEcVid) + mc.deleteEcLocation(deletedEcVid, loc) + } } if resp.ClusterNodeUpdate != nil { |
