diff options
| author | 霍晓栋 <huoxd@jiedaibao.com> | 2016-06-23 11:19:09 +0800 |
|---|---|---|
| committer | 霍晓栋 <huoxd@jiedaibao.com> | 2016-06-23 11:19:09 +0800 |
| commit | 79b0a581327b0153acb869570eae20fa1a1e8faf (patch) | |
| tree | 04faaaf2a35d2c321537f051fece7abbf54bf9c6 /weed/operation/assign_file_id.go | |
| parent | 356b8048c57c7b6e676148892f5ff5031b2178b0 (diff) | |
| download | seaweedfs-79b0a581327b0153acb869570eae20fa1a1e8faf.tar.xz seaweedfs-79b0a581327b0153acb869570eae20fa1a1e8faf.zip | |
add options params for the Assign func
Diffstat (limited to 'weed/operation/assign_file_id.go')
| -rw-r--r-- | weed/operation/assign_file_id.go | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/weed/operation/assign_file_id.go b/weed/operation/assign_file_id.go index acc2d3034..a893e836b 100644 --- a/weed/operation/assign_file_id.go +++ b/weed/operation/assign_file_id.go @@ -19,7 +19,13 @@ type AssignResult struct { Error string `json:"error,omitempty"` } -func Assign(server string, count uint64, replication string, collection string, ttl string) (*AssignResult, error) { +/* +options params meaning: +options[0] main data Center +options[1] main rack +options[2] main data node +*/ +func Assign(server string, count uint64, replication string, collection string, ttl string, options ...string) (*AssignResult, error) { values := make(url.Values) values.Add("count", strconv.FormatUint(count, 10)) if replication != "" { @@ -31,6 +37,31 @@ func Assign(server string, count uint64, replication string, collection string, if ttl != "" { values.Add("ttl", ttl) } + + var dataCenter, rack, dataNode string + switch len(options) { + case 1: + dataCenter = options[0] + case 2: + dataCenter = options[0] + rack = options[1] + case 3: + dataCenter = options[0] + rack = options[1] + dataNode = options[2] + default: + } + + if dataCenter != "" { + values.Add("dataCenter", dataCenter) + } + if rack != "" { + values.Add("rack", rack) + } + if dataNode != "" { + values.Add("dataNode", dataNode) + } + jsonBlob, err := util.Post("http://"+server+"/dir/assign", values) glog.V(2).Info("assign result :", string(jsonBlob)) if err != nil { |
