aboutsummaryrefslogtreecommitdiff
path: root/weed/topology
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2021-02-17 20:55:55 -0800
committerChris Lu <chris.lu@gmail.com>2021-02-17 20:55:55 -0800
commit6daa932f5c1571cc60cf89014cf17810d756dd6b (patch)
treea6c6fce133c0178efec6324c708f3371dcd4f180 /weed/topology
parentdd9f3a01049bef33046d3728d82b25b67b8533ac (diff)
downloadseaweedfs-6daa932f5c1571cc60cf89014cf17810d756dd6b.tar.xz
seaweedfs-6daa932f5c1571cc60cf89014cf17810d756dd6b.zip
refactoring to get master function, instead of passing master values directly
this will enable retrying later
Diffstat (limited to 'weed/topology')
-rw-r--r--weed/topology/store_replicate.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/weed/topology/store_replicate.go b/weed/topology/store_replicate.go
index 6b4076913..ea0a8c968 100644
--- a/weed/topology/store_replicate.go
+++ b/weed/topology/store_replicate.go
@@ -18,7 +18,7 @@ import (
"github.com/chrislusf/seaweedfs/weed/util"
)
-func ReplicatedWrite(masterNode string, s *storage.Store, volumeId needle.VolumeId, n *needle.Needle, r *http.Request) (isUnchanged bool, err error) {
+func ReplicatedWrite(masterFn operation.GetMasterFn, s *storage.Store, volumeId needle.VolumeId, n *needle.Needle, r *http.Request) (isUnchanged bool, err error) {
//check JWT
jwt := security.GetJwt(r)
@@ -27,7 +27,7 @@ func ReplicatedWrite(masterNode string, s *storage.Store, volumeId needle.Volume
var remoteLocations []operation.Location
if r.FormValue("type") != "replicate" {
// this is the initial request
- remoteLocations, err = getWritableRemoteReplications(s, volumeId, masterNode)
+ remoteLocations, err = getWritableRemoteReplications(s, volumeId, masterFn)
if err != nil {
glog.V(0).Infoln(err)
return
@@ -92,7 +92,7 @@ func ReplicatedWrite(masterNode string, s *storage.Store, volumeId needle.Volume
return
}
-func ReplicatedDelete(masterNode string, store *storage.Store,
+func ReplicatedDelete(masterFn operation.GetMasterFn, store *storage.Store,
volumeId needle.VolumeId, n *needle.Needle,
r *http.Request) (size types.Size, err error) {
@@ -101,7 +101,7 @@ func ReplicatedDelete(masterNode string, store *storage.Store,
var remoteLocations []operation.Location
if r.FormValue("type") != "replicate" {
- remoteLocations, err = getWritableRemoteReplications(store, volumeId, masterNode)
+ remoteLocations, err = getWritableRemoteReplications(store, volumeId, masterFn)
if err != nil {
glog.V(0).Infoln(err)
return
@@ -161,7 +161,7 @@ func distributedOperation(locations []operation.Location, store *storage.Store,
return ret.Error()
}
-func getWritableRemoteReplications(s *storage.Store, volumeId needle.VolumeId, masterNode string) (
+func getWritableRemoteReplications(s *storage.Store, volumeId needle.VolumeId, masterFn operation.GetMasterFn) (
remoteLocations []operation.Location, err error) {
v := s.GetVolume(volumeId)
@@ -170,7 +170,7 @@ func getWritableRemoteReplications(s *storage.Store, volumeId needle.VolumeId, m
}
// not on local store, or has replications
- lookupResult, lookupErr := operation.Lookup(masterNode, volumeId.String())
+ lookupResult, lookupErr := operation.Lookup(masterFn, volumeId.String())
if lookupErr == nil {
selfUrl := s.Ip + ":" + strconv.Itoa(s.Port)
for _, location := range lookupResult.Locations {