aboutsummaryrefslogtreecommitdiff
path: root/go/operation
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2014-03-30 11:28:04 -0700
committerChris Lu <chris.lu@gmail.com>2014-03-30 11:28:04 -0700
commit2861275fb67112cb2fe51521b5052c3f1a98414d (patch)
treea86f0eeab6a0603d1217983430c11bb59632d87c /go/operation
parent259c7d66f72938857ee94cc747fc54982fbbcb1f (diff)
downloadseaweedfs-2861275fb67112cb2fe51521b5052c3f1a98414d.tar.xz
seaweedfs-2861275fb67112cb2fe51521b5052c3f1a98414d.zip
working filer server!
Diffstat (limited to 'go/operation')
-rw-r--r--go/operation/lookup_volume_id.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/go/operation/lookup_volume_id.go b/go/operation/lookup_volume_id.go
index 6e6035fae..2e488353b 100644
--- a/go/operation/lookup_volume_id.go
+++ b/go/operation/lookup_volume_id.go
@@ -5,6 +5,7 @@ import (
"encoding/json"
"errors"
_ "fmt"
+ "math/rand"
"net/url"
"strings"
)
@@ -37,16 +38,16 @@ func Lookup(server string, vid string) (*LookupResult, error) {
}
func LookupFileId(server string, fileId string) (fullUrl string, err error) {
- a := strings.Split(fileId, ",")
- if len(a) != 2 {
+ parts := strings.Split(fileId, ",")
+ if len(parts) != 2 {
return "", errors.New("Invalid fileId " + fileId)
}
- lookup, lookupError := Lookup(server, a[0])
+ lookup, lookupError := Lookup(server, parts[0])
if lookupError != nil {
return "", lookupError
}
if len(lookup.Locations) == 0 {
return "", errors.New("File Not Found")
}
- return "http://" + lookup.Locations[0].PublicUrl + "/" + fileId, nil
+ return "http://" + lookup.Locations[rand.Intn(len(lookup.Locations))].PublicUrl + "/" + fileId, nil
}