aboutsummaryrefslogtreecommitdiff
path: root/weed/operation
diff options
context:
space:
mode:
Diffstat (limited to 'weed/operation')
-rw-r--r--weed/operation/assign_file_id.go36
-rw-r--r--weed/operation/submit.go16
2 files changed, 42 insertions, 10 deletions
diff --git a/weed/operation/assign_file_id.go b/weed/operation/assign_file_id.go
index acc2d3034..f2365890c 100644
--- a/weed/operation/assign_file_id.go
+++ b/weed/operation/assign_file_id.go
@@ -11,6 +11,16 @@ import (
"github.com/chrislusf/seaweedfs/weed/util"
)
+type VolumeAssignRequest struct {
+ Count uint64
+ Replication string
+ Collection string
+ Ttl string
+ DataCenter string
+ Rack string
+ DataNode string
+}
+
type AssignResult struct {
Fid string `json:"fid,omitempty"`
Url string `json:"url,omitempty"`
@@ -19,18 +29,28 @@ type AssignResult struct {
Error string `json:"error,omitempty"`
}
-func Assign(server string, count uint64, replication string, collection string, ttl string) (*AssignResult, error) {
+func Assign(server string, r *VolumeAssignRequest) (*AssignResult, error) {
values := make(url.Values)
- values.Add("count", strconv.FormatUint(count, 10))
- if replication != "" {
- values.Add("replication", replication)
+ values.Add("count", strconv.FormatUint(r.Count, 10))
+ if r.Replication != "" {
+ values.Add("replication", r.Replication)
+ }
+ if r.Collection != "" {
+ values.Add("collection", r.Collection)
}
- if collection != "" {
- values.Add("collection", collection)
+ if r.Ttl != "" {
+ values.Add("ttl", r.Ttl)
}
- if ttl != "" {
- values.Add("ttl", ttl)
+ if r.DataCenter != "" {
+ values.Add("dataCenter", r.DataCenter)
}
+ if r.Rack != "" {
+ values.Add("rack", r.Rack)
+ }
+ if r.DataNode != "" {
+ values.Add("dataNode", r.DataNode)
+ }
+
jsonBlob, err := util.Post("http://"+server+"/dir/assign", values)
glog.V(2).Info("assign result :", string(jsonBlob))
if err != nil {
diff --git a/weed/operation/submit.go b/weed/operation/submit.go
index 19bbd7a70..54b6e164e 100644
--- a/weed/operation/submit.go
+++ b/weed/operation/submit.go
@@ -44,7 +44,13 @@ func SubmitFiles(master string, files []FilePart,
for index, file := range files {
results[index].FileName = file.FileName
}
- ret, err := Assign(master, uint64(len(files)), replication, collection, ttl)
+ ar := &VolumeAssignRequest{
+ Count: uint64(len(files)),
+ Replication: replication,
+ Collection: collection,
+ Ttl: ttl,
+ }
+ ret, err := Assign(master, ar)
if err != nil {
for index, _ := range files {
results[index].Error = err.Error()
@@ -164,7 +170,13 @@ func (fi FilePart) Upload(maxMB int, master string, secret security.Secret) (ret
func upload_one_chunk(filename string, reader io.Reader, master,
replication string, collection string, ttl string, jwt security.EncodedJwt,
) (fid string, size uint32, e error) {
- ret, err := Assign(master, 1, replication, collection, ttl)
+ ar := &VolumeAssignRequest{
+ Count: 1,
+ Replication: replication,
+ Collection: collection,
+ Ttl: ttl,
+ }
+ ret, err := Assign(master, ar)
if err != nil {
return "", 0, err
}