|
@ -61,7 +61,7 @@ func (mc *MasterClient) LookupFileIdWithFallback(fileId string) (fullUrls []stri |
|
|
if err == nil && len(fullUrls) > 0 { |
|
|
if err == nil && len(fullUrls) > 0 { |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
err = pb.WithMasterClient(false, mc.getCurrentMaster(), mc.grpcDialOption, false, func(client master_pb.SeaweedClient) error { |
|
|
|
|
|
|
|
|
err = pb.WithMasterClient(false, mc.GetMaster(), mc.grpcDialOption, false, func(client master_pb.SeaweedClient) error { |
|
|
resp, err := client.LookupVolume(context.Background(), &master_pb.LookupVolumeRequest{ |
|
|
resp, err := client.LookupVolume(context.Background(), &master_pb.LookupVolumeRequest{ |
|
|
VolumeOrFileIds: []string{fileId}, |
|
|
VolumeOrFileIds: []string{fileId}, |
|
|
}) |
|
|
}) |
|
@ -227,8 +227,8 @@ func (mc *MasterClient) tryConnectToMaster(master pb.ServerAddress) (nextHintedL |
|
|
|
|
|
|
|
|
if resp.VolumeLocation != nil { |
|
|
if resp.VolumeLocation != nil { |
|
|
// maybe the leader is changed
|
|
|
// maybe the leader is changed
|
|
|
if resp.VolumeLocation.Leader != "" && string(mc.getCurrentMaster()) != resp.VolumeLocation.Leader { |
|
|
|
|
|
glog.V(0).Infof("currentMaster %v redirected to leader %v", mc.getCurrentMaster(), resp.VolumeLocation.Leader) |
|
|
|
|
|
|
|
|
if resp.VolumeLocation.Leader != "" && string(mc.GetMaster()) != resp.VolumeLocation.Leader { |
|
|
|
|
|
glog.V(0).Infof("currentMaster %v redirected to leader %v", mc.GetMaster(), resp.VolumeLocation.Leader) |
|
|
nextHintedLeader = pb.ServerAddress(resp.VolumeLocation.Leader) |
|
|
nextHintedLeader = pb.ServerAddress(resp.VolumeLocation.Leader) |
|
|
stats.MasterClientConnectCounter.WithLabelValues(stats.RedirectedToLeader).Inc() |
|
|
stats.MasterClientConnectCounter.WithLabelValues(stats.RedirectedToLeader).Inc() |
|
|
return nil |
|
|
return nil |
|
@ -290,10 +290,7 @@ func (mc *MasterClient) updateVidMap(resp *master_pb.KeepConnectedResponse) { |
|
|
|
|
|
|
|
|
func (mc *MasterClient) WithClient(streamingMode bool, fn func(client master_pb.SeaweedClient) error) error { |
|
|
func (mc *MasterClient) WithClient(streamingMode bool, fn func(client master_pb.SeaweedClient) error) error { |
|
|
return util.Retry("master grpc", func() error { |
|
|
return util.Retry("master grpc", func() error { |
|
|
for mc.getCurrentMaster() == "" { |
|
|
|
|
|
time.Sleep(3 * time.Second) |
|
|
|
|
|
} |
|
|
|
|
|
return pb.WithMasterClient(streamingMode, mc.getCurrentMaster(), mc.grpcDialOption, false, func(client master_pb.SeaweedClient) error { |
|
|
|
|
|
|
|
|
return pb.WithMasterClient(streamingMode, mc.GetMaster(), mc.grpcDialOption, false, func(client master_pb.SeaweedClient) error { |
|
|
return fn(client) |
|
|
return fn(client) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|