aboutsummaryrefslogtreecommitdiff
path: root/go/operation
diff options
context:
space:
mode:
authoryourchanges <yourchanges@gmail.com>2014-10-21 15:50:48 +0800
committeryourchanges <yourchanges@gmail.com>2014-10-21 15:50:48 +0800
commitf7bcd8e958ef185baeca0c455a397d49fcb62256 (patch)
treebb2a2de4fcb7f9ac7e1d65a78e82cbe1f5f17e36 /go/operation
parent78ccbbf3d0766e1ececf91fa00766d1ed33050cc (diff)
parenta3c17f17b144c4298409fddda2d6bc4b39d38ca5 (diff)
downloadseaweedfs-f7bcd8e958ef185baeca0c455a397d49fcb62256.tar.xz
seaweedfs-f7bcd8e958ef185baeca0c455a397d49fcb62256.zip
Merge pull request #1 from chrislusf/master
update
Diffstat (limited to 'go/operation')
-rw-r--r--go/operation/assign_file_id.go9
-rw-r--r--go/operation/delete_content.go2
-rw-r--r--go/operation/list_masters.go4
-rw-r--r--go/operation/lookup.go2
-rw-r--r--go/operation/submit.go13
-rw-r--r--go/operation/system_message.pb.go12
-rw-r--r--go/operation/upload_content.go2
7 files changed, 27 insertions, 17 deletions
diff --git a/go/operation/assign_file_id.go b/go/operation/assign_file_id.go
index 018e1d763..4e72ad939 100644
--- a/go/operation/assign_file_id.go
+++ b/go/operation/assign_file_id.go
@@ -1,8 +1,8 @@
package operation
import (
- "code.google.com/p/weed-fs/go/glog"
- "code.google.com/p/weed-fs/go/util"
+ "github.com/chrislusf/weed-fs/go/glog"
+ "github.com/chrislusf/weed-fs/go/util"
"encoding/json"
"errors"
"net/url"
@@ -17,7 +17,7 @@ type AssignResult struct {
Error string `json:"error,omitempty"`
}
-func Assign(server string, count int, replication string, collection string) (*AssignResult, error) {
+func Assign(server string, count int, replication string, collection string, ttl string) (*AssignResult, error) {
values := make(url.Values)
values.Add("count", strconv.Itoa(count))
if replication != "" {
@@ -26,6 +26,9 @@ func Assign(server string, count int, replication string, collection string) (*A
if collection != "" {
values.Add("collection", collection)
}
+ if ttl != "" {
+ values.Add("ttl", ttl)
+ }
jsonBlob, err := util.Post("http://"+server+"/dir/assign", values)
glog.V(2).Info("assign result :", string(jsonBlob))
if err != nil {
diff --git a/go/operation/delete_content.go b/go/operation/delete_content.go
index e4f9d39bb..84391b634 100644
--- a/go/operation/delete_content.go
+++ b/go/operation/delete_content.go
@@ -1,7 +1,7 @@
package operation
import (
- "code.google.com/p/weed-fs/go/util"
+ "github.com/chrislusf/weed-fs/go/util"
"encoding/json"
"errors"
"net/url"
diff --git a/go/operation/list_masters.go b/go/operation/list_masters.go
index 491c79f20..7d46a9ebc 100644
--- a/go/operation/list_masters.go
+++ b/go/operation/list_masters.go
@@ -1,8 +1,8 @@
package operation
import (
- "code.google.com/p/weed-fs/go/glog"
- "code.google.com/p/weed-fs/go/util"
+ "github.com/chrislusf/weed-fs/go/glog"
+ "github.com/chrislusf/weed-fs/go/util"
"encoding/json"
)
diff --git a/go/operation/lookup.go b/go/operation/lookup.go
index f191bfdbf..ebf153d27 100644
--- a/go/operation/lookup.go
+++ b/go/operation/lookup.go
@@ -1,7 +1,7 @@
package operation
import (
- "code.google.com/p/weed-fs/go/util"
+ "github.com/chrislusf/weed-fs/go/util"
"encoding/json"
"errors"
_ "fmt"
diff --git a/go/operation/submit.go b/go/operation/submit.go
index 9191f7d9a..3e09c2edf 100644
--- a/go/operation/submit.go
+++ b/go/operation/submit.go
@@ -2,7 +2,7 @@ package operation
import (
"bytes"
- "code.google.com/p/weed-fs/go/glog"
+ "github.com/chrislusf/weed-fs/go/glog"
"io"
"mime"
"os"
@@ -20,6 +20,7 @@ type FilePart struct {
ModTime int64 //in seconds
Replication string
Collection string
+ Ttl string
Server string //this comes from assign result
Fid string //this comes from assign result, but customizable
}
@@ -32,12 +33,12 @@ type SubmitResult struct {
Error string `json:"error,omitempty"`
}
-func SubmitFiles(master string, files []FilePart, replication string, collection string, maxMB int) ([]SubmitResult, error) {
+func SubmitFiles(master string, files []FilePart, replication string, collection string, ttl string, maxMB int) ([]SubmitResult, error) {
results := make([]SubmitResult, len(files))
for index, file := range files {
results[index].FileName = file.FileName
}
- ret, err := Assign(master, len(files), replication, collection)
+ ret, err := Assign(master, len(files), replication, collection, ttl)
if err != nil {
for index, _ := range files {
results[index].Error = err.Error()
@@ -112,7 +113,7 @@ func (fi FilePart) Upload(maxMB int, master string) (retSize uint32, err error)
chunks := fi.FileSize/chunkSize + 1
fids := make([]string, 0)
for i := int64(0); i < chunks; i++ {
- id, count, e := upload_one_chunk(fi.FileName+"-"+strconv.FormatInt(i+1, 10), io.LimitReader(fi.Reader, chunkSize), master, fi.Replication, fi.Collection)
+ id, count, e := upload_one_chunk(fi.FileName+"-"+strconv.FormatInt(i+1, 10), io.LimitReader(fi.Reader, chunkSize), master, fi.Replication, fi.Collection, fi.Ttl)
if e != nil {
return 0, e
}
@@ -130,8 +131,8 @@ func (fi FilePart) Upload(maxMB int, master string) (retSize uint32, err error)
return
}
-func upload_one_chunk(filename string, reader io.Reader, master, replication string, collection string) (fid string, size uint32, e error) {
- ret, err := Assign(master, 1, replication, collection)
+func upload_one_chunk(filename string, reader io.Reader, master, replication string, collection string, ttl string) (fid string, size uint32, e error) {
+ ret, err := Assign(master, 1, replication, collection, ttl)
if err != nil {
return "", 0, err
}
diff --git a/go/operation/system_message.pb.go b/go/operation/system_message.pb.go
index 45ae8a648..9f00dd74d 100644
--- a/go/operation/system_message.pb.go
+++ b/go/operation/system_message.pb.go
@@ -15,12 +15,10 @@ It has these top-level messages:
package operation
import proto "code.google.com/p/goprotobuf/proto"
-import json "encoding/json"
import math "math"
-// Reference proto, json, and math imports to suppress error if they are not otherwise used.
+// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
-var _ = &json.SyntaxError{}
var _ = math.Inf
type VolumeInformationMessage struct {
@@ -33,6 +31,7 @@ type VolumeInformationMessage struct {
ReadOnly *bool `protobuf:"varint,7,opt,name=read_only" json:"read_only,omitempty"`
ReplicaPlacement *uint32 `protobuf:"varint,8,req,name=replica_placement" json:"replica_placement,omitempty"`
Version *uint32 `protobuf:"varint,9,opt,name=version,def=2" json:"version,omitempty"`
+ Ttl *uint32 `protobuf:"varint,10,opt,name=ttl" json:"ttl,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
@@ -105,6 +104,13 @@ func (m *VolumeInformationMessage) GetVersion() uint32 {
return Default_VolumeInformationMessage_Version
}
+func (m *VolumeInformationMessage) GetTtl() uint32 {
+ if m != nil && m.Ttl != nil {
+ return *m.Ttl
+ }
+ return 0
+}
+
type JoinMessage struct {
IsInit *bool `protobuf:"varint,1,opt,name=is_init" json:"is_init,omitempty"`
Ip *string `protobuf:"bytes,2,req,name=ip" json:"ip,omitempty"`
diff --git a/go/operation/upload_content.go b/go/operation/upload_content.go
index b89e65ce8..38737702d 100644
--- a/go/operation/upload_content.go
+++ b/go/operation/upload_content.go
@@ -2,7 +2,7 @@ package operation
import (
"bytes"
- "code.google.com/p/weed-fs/go/glog"
+ "github.com/chrislusf/weed-fs/go/glog"
"encoding/json"
"errors"
"fmt"