|
@ -127,22 +127,21 @@ func (mc *MasterClient) tryConnectToMaster(master pb.ServerAddress) (nextHintedL |
|
|
} |
|
|
} |
|
|
glog.V(1).Infof("%s.%s masterClient Connected to %v", mc.FilerGroup, mc.clientType, master) |
|
|
glog.V(1).Infof("%s.%s masterClient Connected to %v", mc.FilerGroup, mc.clientType, master) |
|
|
|
|
|
|
|
|
//reset vidMap only when masterClient successfully connected to new leader
|
|
|
|
|
|
resp, err := stream.Recv() |
|
|
resp, err := stream.Recv() |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
glog.V(0).Infof("%s.%s masterClient failed to receive from %s: %v", mc.FilerGroup, mc.clientType, master, err) |
|
|
glog.V(0).Infof("%s.%s masterClient failed to receive from %s: %v", mc.FilerGroup, mc.clientType, master, err) |
|
|
stats.MasterClientConnectCounter.WithLabelValues(stats.FailedToReceive).Inc() |
|
|
stats.MasterClientConnectCounter.WithLabelValues(stats.FailedToReceive).Inc() |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
if resp.VolumeLocation != nil { |
|
|
|
|
|
//immediately check whether it is the leader
|
|
|
|
|
|
if resp.VolumeLocation.Leader != "" { |
|
|
|
|
|
glog.V(0).Infof("redirected to leader %v", resp.VolumeLocation.Leader) |
|
|
|
|
|
nextHintedLeader = pb.ServerAddress(resp.VolumeLocation.Leader) |
|
|
|
|
|
stats.MasterClientConnectCounter.WithLabelValues(stats.RedirectedToleader).Inc() |
|
|
|
|
|
return nil |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// check if it is the leader to determine whether to reset the vidMap
|
|
|
|
|
|
if resp.VolumeLocation != nil && resp.VolumeLocation.Leader != "" { |
|
|
|
|
|
glog.V(0).Infof("redirected to leader %v", resp.VolumeLocation.Leader) |
|
|
|
|
|
nextHintedLeader = pb.ServerAddress(resp.VolumeLocation.Leader) |
|
|
|
|
|
stats.MasterClientConnectCounter.WithLabelValues(stats.RedirectedToleader).Inc() |
|
|
|
|
|
return nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
mc.currentMaster = master |
|
|
mc.currentMaster = master |
|
|
mc.vidMap = newVidMap("") |
|
|
mc.vidMap = newVidMap("") |
|
|
|
|
|
|
|
|