mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
masterclient: fallback to directly querying master in case of missing volume id location
This commit is contained in:
parent
280e33092c
commit
9c517d2b35
|
@ -38,6 +38,36 @@ func NewMasterClient(grpcDialOption grpc.DialOption, filerGroup string, clientTy
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (mc *MasterClient) GetLookupFileIdFunction() LookupFileIdFunctionType {
|
||||||
|
return mc.LookupFileIdWithFallback
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mc *MasterClient) LookupFileIdWithFallback(fileId string) (fullUrls []string, err error) {
|
||||||
|
fullUrls, err = mc.vidMap.LookupFileId(fileId)
|
||||||
|
err = pb.WithMasterClient(false, mc.currentMaster, mc.grpcDialOption, func(client master_pb.SeaweedClient) error {
|
||||||
|
resp, err := client.LookupVolume(context.Background(), &master_pb.LookupVolumeRequest{
|
||||||
|
VolumeOrFileIds: []string{fileId},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for vid, vidLocation := range resp.VolumeIdLocations {
|
||||||
|
for _, vidLoc := range vidLocation.Locations {
|
||||||
|
loc := Location{
|
||||||
|
Url: vidLoc.Url,
|
||||||
|
PublicUrl: vidLoc.PublicUrl,
|
||||||
|
GrpcPort: int(vidLoc.GrpcPort),
|
||||||
|
}
|
||||||
|
mc.vidMap.addLocation(uint32(vid), loc)
|
||||||
|
fullUrls = append(fullUrls, loc.Url)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func (mc *MasterClient) GetMaster() pb.ServerAddress {
|
func (mc *MasterClient) GetMaster() pb.ServerAddress {
|
||||||
mc.WaitUntilConnected()
|
mc.WaitUntilConnected()
|
||||||
return mc.currentMaster
|
return mc.currentMaster
|
||||||
|
|
|
@ -90,10 +90,6 @@ func (vc *vidMap) LookupVolumeServerUrl(vid string) (serverUrls []string, err er
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (vc *vidMap) GetLookupFileIdFunction() LookupFileIdFunctionType {
|
|
||||||
return vc.LookupFileId
|
|
||||||
}
|
|
||||||
|
|
||||||
func (vc *vidMap) LookupFileId(fileId string) (fullUrls []string, err error) {
|
func (vc *vidMap) LookupFileId(fileId string) (fullUrls []string, err error) {
|
||||||
parts := strings.Split(fileId, ",")
|
parts := strings.Split(fileId, ",")
|
||||||
if len(parts) != 2 {
|
if len(parts) != 2 {
|
||||||
|
|
Loading…
Reference in a new issue