aboutsummaryrefslogtreecommitdiff
path: root/weed/wdclient/vid_map.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2019-07-28 03:58:13 -0700
committerChris Lu <chris.lu@gmail.com>2019-07-28 03:58:13 -0700
commit8afd8d35b3230f6fc286967e8aa9641bd8c1460c (patch)
tree8c134e958969a7aec6337c8c7bab120009006941 /weed/wdclient/vid_map.go
parent2c6cf72e73861f3bdefaba28189fa2b15fa26d9e (diff)
downloadseaweedfs-8afd8d35b3230f6fc286967e8aa9641bd8c1460c.tar.xz
seaweedfs-8afd8d35b3230f6fc286967e8aa9641bd8c1460c.zip
master: followers can also lookup and redirect
improve scalability
Diffstat (limited to 'weed/wdclient/vid_map.go')
-rw-r--r--weed/wdclient/vid_map.go15
1 files changed, 10 insertions, 5 deletions
diff --git a/weed/wdclient/vid_map.go b/weed/wdclient/vid_map.go
index 06308944d..01d9cdaed 100644
--- a/weed/wdclient/vid_map.go
+++ b/weed/wdclient/vid_map.go
@@ -64,20 +64,25 @@ func (vc *vidMap) LookupVolumeServer(fileId string) (volumeServer string, err er
return serverUrl, nil
}
-func (vc *vidMap) GetVidLocations(vid string) (locations []Location) {
+func (vc *vidMap) GetVidLocations(vid string) (locations []Location, err error) {
id, err := strconv.Atoi(vid)
if err != nil {
glog.V(1).Infof("Unknown volume id %s", vid)
- return nil
+ return nil, fmt.Errorf("Unknown volume id %s", vid)
}
- return vc.GetLocations(uint32(id))
+ foundLocations, found := vc.GetLocations(uint32(id))
+ if found {
+ return foundLocations, nil
+ }
+ return nil, fmt.Errorf("volume id %s not found", vid)
}
-func (vc *vidMap) GetLocations(vid uint32) (locations []Location) {
+func (vc *vidMap) GetLocations(vid uint32) (locations []Location, found bool) {
vc.RLock()
defer vc.RUnlock()
- return vc.vid2Locations[vid]
+ locations, found = vc.vid2Locations[vid]
+ return
}
func (vc *vidMap) GetRandomLocation(vid uint32) (serverUrl string, err error) {