Chris Lu
12 years ago
6 changed files with 81 additions and 23 deletions
-
18weed-fs/note/replication.txt
-
14weed-fs/src/cmd/weed/volume.go
-
31weed-fs/src/pkg/admin/storage.go
-
15weed-fs/src/pkg/storage/volume_info.go
-
6weed-fs/src/pkg/topology/data_node.go
-
2weed-fs/src/pkg/topology/volume_location.go
@ -0,0 +1,31 @@ |
|||
package admin |
|||
|
|||
import ( |
|||
"encoding/json" |
|||
"errors" |
|||
"strconv" |
|||
"net/url" |
|||
"pkg/util" |
|||
"pkg/storage" |
|||
"pkg/topology" |
|||
) |
|||
|
|||
type AllocateVolumeResult struct { |
|||
error string |
|||
} |
|||
|
|||
func AllocateVolume(dn *topology.DataNode, vid storage.VolumeId, repType storage.ReplicationType) error{ |
|||
values := make(url.Values) |
|||
values.Add("volume", vid.String()) |
|||
values.Add("replicationType", repType.String()) |
|||
jsonBlob := util.Post("http://"+dn.Ip+":"+strconv.Itoa(dn.Port)+"/admin/assign_volume", values) |
|||
var ret AllocateVolumeResult |
|||
err := json.Unmarshal(jsonBlob, &ret) |
|||
if err != nil { |
|||
return err |
|||
} |
|||
if ret.error != "" { |
|||
return errors.New(ret.error) |
|||
} |
|||
return nil |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue