aboutsummaryrefslogtreecommitdiff
path: root/go/replication/allocate_volume.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2014-02-14 17:10:49 -0800
committerChris Lu <chris.lu@gmail.com>2014-02-14 17:10:49 -0800
commitedae676913363bdd1e5a50bf0778fdcc3c6d6051 (patch)
tree8711d0e0382ba15b2810e7783cdede4283d7e1c4 /go/replication/allocate_volume.go
parentef4c2c0d1e5bb45a63cde703013871daa401d1ef (diff)
downloadseaweedfs-edae676913363bdd1e5a50bf0778fdcc3c6d6051.tar.xz
seaweedfs-edae676913363bdd1e5a50bf0778fdcc3c6d6051.zip
1. volume server auto detect clustered master nodes
2. remove operation package dependency on storage
Diffstat (limited to 'go/replication/allocate_volume.go')
-rw-r--r--go/replication/allocate_volume.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/go/replication/allocate_volume.go b/go/replication/allocate_volume.go
new file mode 100644
index 000000000..0f5ebc00f
--- /dev/null
+++ b/go/replication/allocate_volume.go
@@ -0,0 +1,33 @@
+package replication
+
+import (
+ "code.google.com/p/weed-fs/go/storage"
+ "code.google.com/p/weed-fs/go/topology"
+ "code.google.com/p/weed-fs/go/util"
+ "encoding/json"
+ "errors"
+ "net/url"
+)
+
+type AllocateVolumeResult struct {
+ Error string
+}
+
+func AllocateVolume(dn *topology.DataNode, vid storage.VolumeId, collection string, repType storage.ReplicationType) error {
+ values := make(url.Values)
+ values.Add("volume", vid.String())
+ values.Add("collection", collection)
+ values.Add("replication", repType.String())
+ jsonBlob, err := util.Post("http://"+dn.PublicUrl+"/admin/assign_volume", values)
+ if err != nil {
+ return err
+ }
+ var ret AllocateVolumeResult
+ if err := json.Unmarshal(jsonBlob, &ret); err != nil {
+ return err
+ }
+ if ret.Error != "" {
+ return errors.New(ret.Error)
+ }
+ return nil
+}