|
@ -2,6 +2,7 @@ package wdclient |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
"context" |
|
|
"context" |
|
|
|
|
|
"fmt" |
|
|
"github.com/chrislusf/seaweedfs/weed/stats" |
|
|
"github.com/chrislusf/seaweedfs/weed/stats" |
|
|
"math/rand" |
|
|
"math/rand" |
|
|
"time" |
|
|
"time" |
|
@ -44,7 +45,7 @@ func (mc *MasterClient) GetLookupFileIdFunction() LookupFileIdFunctionType { |
|
|
|
|
|
|
|
|
func (mc *MasterClient) LookupFileIdWithFallback(fileId string) (fullUrls []string, err error) { |
|
|
func (mc *MasterClient) LookupFileIdWithFallback(fileId string) (fullUrls []string, err error) { |
|
|
fullUrls, err = mc.vidMap.LookupFileId(fileId) |
|
|
fullUrls, err = mc.vidMap.LookupFileId(fileId) |
|
|
if err == nil { |
|
|
|
|
|
|
|
|
if err == nil && len(fullUrls) > 0 { |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
err = pb.WithMasterClient(false, mc.currentMaster, mc.grpcDialOption, func(client master_pb.SeaweedClient) error { |
|
|
err = pb.WithMasterClient(false, mc.currentMaster, mc.grpcDialOption, func(client master_pb.SeaweedClient) error { |
|
@ -52,7 +53,7 @@ func (mc *MasterClient) LookupFileIdWithFallback(fileId string) (fullUrls []stri |
|
|
VolumeOrFileIds: []string{fileId}, |
|
|
VolumeOrFileIds: []string{fileId}, |
|
|
}) |
|
|
}) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return err |
|
|
|
|
|
|
|
|
return fmt.Errorf("LookupVolume failed: %v", err) |
|
|
} |
|
|
} |
|
|
for vid, vidLocation := range resp.VolumeIdLocations { |
|
|
for vid, vidLocation := range resp.VolumeIdLocations { |
|
|
for _, vidLoc := range vidLocation.Locations { |
|
|
for _, vidLoc := range vidLocation.Locations { |
|
@ -65,7 +66,6 @@ func (mc *MasterClient) LookupFileIdWithFallback(fileId string) (fullUrls []stri |
|
|
fullUrls = append(fullUrls, "http://"+loc.Url+"/"+fileId) |
|
|
fullUrls = append(fullUrls, "http://"+loc.Url+"/"+fileId) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return nil |
|
|
return nil |
|
|
}) |
|
|
}) |
|
|
return |
|
|
return |
|
|