aboutsummaryrefslogtreecommitdiff
path: root/go/replication
diff options
context:
space:
mode:
Diffstat (limited to 'go/replication')
-rw-r--r--go/replication/allocate_volume.go33
-rw-r--r--go/replication/store_replicate.go2
-rw-r--r--go/replication/volume_growth.go3
3 files changed, 35 insertions, 3 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
+}
diff --git a/go/replication/store_replicate.go b/go/replication/store_replicate.go
index bc630c5d1..3e709de44 100644
--- a/go/replication/store_replicate.go
+++ b/go/replication/store_replicate.go
@@ -71,7 +71,7 @@ func ReplicatedDelete(masterNode string, store *storage.Store, volumeId storage.
}
func distributedOperation(masterNode string, store *storage.Store, volumeId storage.VolumeId, op func(location operation.Location) bool) bool {
- if lookupResult, lookupErr := operation.Lookup(masterNode, volumeId); lookupErr == nil {
+ if lookupResult, lookupErr := operation.Lookup(masterNode, volumeId.String()); lookupErr == nil {
length := 0
selfUrl := (store.Ip + ":" + strconv.Itoa(store.Port))
results := make(chan bool)
diff --git a/go/replication/volume_growth.go b/go/replication/volume_growth.go
index 6e5bf1f5c..d7d1c90bd 100644
--- a/go/replication/volume_growth.go
+++ b/go/replication/volume_growth.go
@@ -2,7 +2,6 @@ package replication
import (
"code.google.com/p/weed-fs/go/glog"
- "code.google.com/p/weed-fs/go/operation"
"code.google.com/p/weed-fs/go/storage"
"code.google.com/p/weed-fs/go/topology"
"errors"
@@ -200,7 +199,7 @@ func (vg *VolumeGrowth) GrowByCountAndType(count int, collection string, repType
}
func (vg *VolumeGrowth) grow(topo *topology.Topology, vid storage.VolumeId, collection string, repType storage.ReplicationType, servers ...*topology.DataNode) error {
for _, server := range servers {
- if err := operation.AllocateVolume(server, vid, collection, repType); err == nil {
+ if err := AllocateVolume(server, vid, collection, repType); err == nil {
vi := storage.VolumeInfo{Id: vid, Size: 0, Collection: collection, RepType: repType, Version: storage.CurrentVersion}
server.AddOrUpdateVolume(vi)
topo.RegisterVolumeLayout(&vi, server)