aboutsummaryrefslogtreecommitdiff
path: root/weed-fs/src/pkg
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2012-09-20 02:47:32 -0700
committerChris Lu <chris.lu@gmail.com>2012-09-20 02:47:32 -0700
commit462f2ed9589425610789ffe597defae8041e9782 (patch)
treee3497cdacb068c0da6c44ae5418988702afd9502 /weed-fs/src/pkg
parenta1bc529db65aa67ff7d52b76d700c093eb0c6c17 (diff)
downloadseaweedfs-462f2ed9589425610789ffe597defae8041e9782.tar.xz
seaweedfs-462f2ed9589425610789ffe597defae8041e9782.zip
for moved volumes, redirect with code 501
Diffstat (limited to 'weed-fs/src/pkg')
-rw-r--r--weed-fs/src/pkg/operation/lookup.go34
-rw-r--r--weed-fs/src/pkg/storage/store.go5
2 files changed, 39 insertions, 0 deletions
diff --git a/weed-fs/src/pkg/operation/lookup.go b/weed-fs/src/pkg/operation/lookup.go
new file mode 100644
index 000000000..fa5f149a1
--- /dev/null
+++ b/weed-fs/src/pkg/operation/lookup.go
@@ -0,0 +1,34 @@
+package operation
+
+import (
+ "encoding/json"
+ "net/url"
+ "pkg/storage"
+ "pkg/util"
+ "fmt"
+)
+
+type Location struct {
+ Url string "url"
+ PublicUrl string "publicUrl"
+}
+type LookupResult struct {
+ Locations []Location "locations"
+ Error string "error"
+}
+
+func Lookup(server string, vid storage.VolumeId) (*LookupResult, error) {
+ values := make(url.Values)
+ values.Add("volumeId", vid.String())
+ jsonBlob, err := util.Post("http://"+server+"/dir/lookup", values)
+ fmt.Println("Lookup Result:", string(jsonBlob))
+ if err != nil {
+ return nil, err
+ }
+ var ret LookupResult
+ err = json.Unmarshal(jsonBlob, &ret)
+ if err != nil {
+ return nil, err
+ }
+ return &ret, nil
+}
diff --git a/weed-fs/src/pkg/storage/store.go b/weed-fs/src/pkg/storage/store.go
index adb243e13..d1155bb78 100644
--- a/weed-fs/src/pkg/storage/store.go
+++ b/weed-fs/src/pkg/storage/store.go
@@ -136,6 +136,11 @@ func (s *Store) Read(i VolumeId, n *Needle) (int, error) {
return 0, errors.New("Not Found")
}
+func (s *Store) HasVolume(i VolumeId) bool {
+ _, ok := s.volumes[i]
+ return ok
+}
+
type VolumeLocations struct {
Vid VolumeId
Locations []string