diff options
Diffstat (limited to 'weed/wdclient/masterclient.go')
| -rw-r--r-- | weed/wdclient/masterclient.go | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/weed/wdclient/masterclient.go b/weed/wdclient/masterclient.go index 6d88e56e9..64ae876b0 100644 --- a/weed/wdclient/masterclient.go +++ b/weed/wdclient/masterclient.go @@ -27,7 +27,7 @@ type MasterClient struct { masters map[string]pb.ServerAddress grpcDialOption grpc.DialOption - vidMap + *vidMap vidMapCacheSize int OnPeerUpdate func(update *master_pb.ClusterNodeUpdate, startFrom time.Time) OnPeerUpdateLock sync.RWMutex @@ -262,8 +262,11 @@ func (mc *MasterClient) tryConnectToMaster(master pb.ServerAddress) (nextHintedL } func (mc *MasterClient) updateVidMap(resp *master_pb.KeepConnectedResponse) { + if resp.VolumeLocation.IsEmptyUrl() { + glog.V(0).Infof("updateVidMap ignore short heartbeat: %+v", resp) + return + } // process new volume location - glog.V(1).Infof("updateVidMap() resp.VolumeLocation.DataCenter %v", resp.VolumeLocation.DataCenter) loc := Location{ Url: resp.VolumeLocation.Url, PublicUrl: resp.VolumeLocation.PublicUrl, @@ -271,21 +274,25 @@ func (mc *MasterClient) updateVidMap(resp *master_pb.KeepConnectedResponse) { GrpcPort: int(resp.VolumeLocation.GrpcPort), } for _, newVid := range resp.VolumeLocation.NewVids { - glog.V(1).Infof("%s.%s: %s masterClient adds volume %d", mc.FilerGroup, mc.clientType, loc.Url, newVid) + glog.V(2).Infof("%s.%s: %s masterClient adds volume %d", mc.FilerGroup, mc.clientType, loc.Url, newVid) mc.addLocation(newVid, loc) } for _, deletedVid := range resp.VolumeLocation.DeletedVids { - glog.V(1).Infof("%s.%s: %s masterClient removes volume %d", mc.FilerGroup, mc.clientType, loc.Url, deletedVid) + glog.V(2).Infof("%s.%s: %s masterClient removes volume %d", mc.FilerGroup, mc.clientType, loc.Url, deletedVid) mc.deleteLocation(deletedVid, loc) } for _, newEcVid := range resp.VolumeLocation.NewEcVids { - glog.V(1).Infof("%s.%s: %s masterClient adds ec volume %d", mc.FilerGroup, mc.clientType, loc.Url, newEcVid) + glog.V(2).Infof("%s.%s: %s masterClient adds ec volume %d", mc.FilerGroup, mc.clientType, loc.Url, newEcVid) mc.addEcLocation(newEcVid, loc) } for _, deletedEcVid := range resp.VolumeLocation.DeletedEcVids { - glog.V(1).Infof("%s.%s: %s masterClient removes ec volume %d", mc.FilerGroup, mc.clientType, loc.Url, deletedEcVid) + glog.V(2).Infof("%s.%s: %s masterClient removes ec volume %d", mc.FilerGroup, mc.clientType, loc.Url, deletedEcVid) mc.deleteEcLocation(deletedEcVid, loc) } + glog.V(1).Infof("updateVidMap(%s) %s.%s: %s volume add: %d, del: %d, add ec: %d del ec: %d", + resp.VolumeLocation.DataCenter, mc.FilerGroup, mc.clientType, loc.Url, + len(resp.VolumeLocation.NewVids), len(resp.VolumeLocation.DeletedVids), + len(resp.VolumeLocation.NewEcVids), len(resp.VolumeLocation.DeletedEcVids)) } func (mc *MasterClient) WithClient(streamingMode bool, fn func(client master_pb.SeaweedClient) error) error { @@ -303,9 +310,12 @@ func (mc *MasterClient) resetVidMap() { DataCenter: mc.DataCenter, cache: mc.cache, } - mc.vidMap = newVidMap(mc.DataCenter) - mc.vidMap.cache = tail + nvm := newVidMap(mc.DataCenter) + nvm.cache = tail + mc.vidMap = nvm + + //trim for i := 0; i < mc.vidMapCacheSize && tail.cache != nil; i++ { if i == mc.vidMapCacheSize-1 { tail.cache = nil |
