aboutsummaryrefslogtreecommitdiff
path: root/go/topology
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2015-02-07 15:35:28 -0800
committerChris Lu <chris.lu@gmail.com>2015-02-07 15:35:28 -0800
commitf7998f86522ef04717e22bb094f00138bdf18748 (patch)
tree5d8454179564d52feae0ad78caa2648518f63eb8 /go/topology
parent714ccb6e2b709355bed617947ccaa6ad4b68b77b (diff)
downloadseaweedfs-f7998f86522ef04717e22bb094f00138bdf18748.tar.xz
seaweedfs-f7998f86522ef04717e22bb094f00138bdf18748.zip
merge conflicts
Diffstat (limited to 'go/topology')
-rw-r--r--go/topology/store_replicate.go26
1 files changed, 21 insertions, 5 deletions
diff --git a/go/topology/store_replicate.go b/go/topology/store_replicate.go
index 0c52f9d30..da426e587 100644
--- a/go/topology/store_replicate.go
+++ b/go/topology/store_replicate.go
@@ -7,11 +7,18 @@ import (
"github.com/chrislusf/weed-fs/go/glog"
"github.com/chrislusf/weed-fs/go/operation"
+ "github.com/chrislusf/weed-fs/go/security"
"github.com/chrislusf/weed-fs/go/storage"
"github.com/chrislusf/weed-fs/go/util"
)
-func ReplicatedWrite(masterNode string, s *storage.Store, volumeId storage.VolumeId, needle *storage.Needle, r *http.Request) (size uint32, errorStatus string) {
+func ReplicatedWrite(masterNode string, s *storage.Store,
+ volumeId storage.VolumeId, needle *storage.Needle,
+ r *http.Request) (size uint32, errorStatus string) {
+
+ //check JWT
+ jwt := security.GetJwt(r)
+
ret, err := s.Write(volumeId, needle)
needToReplicate := !s.HasVolume(volumeId)
if err != nil {
@@ -27,7 +34,10 @@ func ReplicatedWrite(masterNode string, s *storage.Store, volumeId storage.Volum
if needToReplicate { //send to other replica locations
if r.FormValue("type") != "replicate" {
if !distributedOperation(masterNode, s, volumeId, func(location operation.Location) bool {
- _, err := operation.Upload("http://"+location.Url+r.URL.Path+"?type=replicate&ts="+strconv.FormatUint(needle.LastModified, 10), string(needle.Name), bytes.NewReader(needle.Data), needle.IsGzipped(), string(needle.Mime))
+ _, err := operation.Upload(
+ "http://"+location.Url+r.URL.Path+"?type=replicate&ts="+strconv.FormatUint(needle.LastModified, 10),
+ string(needle.Name), bytes.NewReader(needle.Data), needle.IsGzipped(), string(needle.Mime),
+ jwt)
return err == nil
}) {
ret = 0
@@ -41,7 +51,7 @@ func ReplicatedWrite(masterNode string, s *storage.Store, volumeId storage.Volum
volumeId.String() + ": " + err.Error()
} else {
distributedOperation(masterNode, s, volumeId, func(location operation.Location) bool {
- return nil == util.Delete("http://"+location.Url+r.URL.Path+"?type=replicate")
+ return nil == util.Delete("http://"+location.Url+r.URL.Path+"?type=replicate", jwt)
})
}
}
@@ -49,7 +59,13 @@ func ReplicatedWrite(masterNode string, s *storage.Store, volumeId storage.Volum
return
}
-func ReplicatedDelete(masterNode string, store *storage.Store, volumeId storage.VolumeId, n *storage.Needle, r *http.Request) (ret uint32) {
+func ReplicatedDelete(masterNode string, store *storage.Store,
+ volumeId storage.VolumeId, n *storage.Needle,
+ r *http.Request) (ret uint32) {
+
+ //check JWT
+ jwt := security.GetJwt(r)
+
ret, err := store.Delete(volumeId, n)
if err != nil {
glog.V(0).Infoln("delete error:", err)
@@ -63,7 +79,7 @@ func ReplicatedDelete(masterNode string, store *storage.Store, volumeId storage.
if needToReplicate { //send to other replica locations
if r.FormValue("type") != "replicate" {
if !distributedOperation(masterNode, store, volumeId, func(location operation.Location) bool {
- return nil == util.Delete("http://"+location.Url+r.URL.Path+"?type=replicate")
+ return nil == util.Delete("http://"+location.Url+r.URL.Path+"?type=replicate", jwt)
}) {
ret = 0
}