aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2021-01-28 14:36:29 -0800
committerChris Lu <chris.lu@gmail.com>2021-01-28 14:36:29 -0800
commit990fa69bfeac65a72bec1539993e32633858c8f5 (patch)
tree00b90626c590534b64a581da8807117459b91ecb
parent9292796ec2d8f796f3e9162fcd1362cba801e7e4 (diff)
downloadseaweedfs-990fa69bfeac65a72bec1539993e32633858c8f5.tar.xz
seaweedfs-990fa69bfeac65a72bec1539993e32633858c8f5.zip
add back AdjustedUrl() related code
-rw-r--r--weed/filer/reader_at.go2
-rw-r--r--weed/filesys/wfs_filer_client.go7
-rw-r--r--weed/filesys/wfs_write.go2
-rw-r--r--weed/messaging/broker/broker_append.go4
-rw-r--r--weed/pb/filer_pb/filer_client.go1
-rw-r--r--weed/replication/sink/filersink/fetch_write.go3
-rw-r--r--weed/replication/source/filer_source.go4
-rw-r--r--weed/s3api/s3api_handlers.go3
-rw-r--r--weed/server/webdav_server.go3
-rw-r--r--weed/shell/commands.go4
10 files changed, 31 insertions, 2 deletions
diff --git a/weed/filer/reader_at.go b/weed/filer/reader_at.go
index 41d177210..a1e989684 100644
--- a/weed/filer/reader_at.go
+++ b/weed/filer/reader_at.go
@@ -71,7 +71,7 @@ func LookupFn(filerClient filer_pb.FilerClient) wdclient.LookupFileIdFunctionTyp
}
for _, loc := range locations.Locations {
- volumeServerAddress := loc.Url
+ volumeServerAddress := filerClient.AdjustedUrl(loc)
targetUrl := fmt.Sprintf("http://%s/%s", volumeServerAddress, fileId)
targetUrls = append(targetUrls, targetUrl)
}
diff --git a/weed/filesys/wfs_filer_client.go b/weed/filesys/wfs_filer_client.go
index e0d352a7b..ef4213af1 100644
--- a/weed/filesys/wfs_filer_client.go
+++ b/weed/filesys/wfs_filer_client.go
@@ -25,3 +25,10 @@ func (wfs *WFS) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) error) erro
return err
}
+
+func (wfs *WFS) AdjustedUrl(location *filer_pb.Location) string {
+ if wfs.option.OutsideContainerClusterMode {
+ return location.PublicUrl
+ }
+ return location.Url
+}
diff --git a/weed/filesys/wfs_write.go b/weed/filesys/wfs_write.go
index dfe6e57a6..54e114013 100644
--- a/weed/filesys/wfs_write.go
+++ b/weed/filesys/wfs_write.go
@@ -44,7 +44,7 @@ func (wfs *WFS) saveDataAsChunk(fullPath util.FullPath) filer.SaveDataAsChunkFun
Url: resp.Url,
PublicUrl: resp.PublicUrl,
}
- host = loc.Url
+ host = wfs.AdjustedUrl(loc)
collection, replication = resp.Collection, resp.Replication
return nil
diff --git a/weed/messaging/broker/broker_append.go b/weed/messaging/broker/broker_append.go
index 67c9bcb79..8e5b56fd0 100644
--- a/weed/messaging/broker/broker_append.go
+++ b/weed/messaging/broker/broker_append.go
@@ -107,3 +107,7 @@ func (broker *MessageBroker) WithFilerClient(fn func(filer_pb.SeaweedFilerClient
return
}
+
+func (broker *MessageBroker) AdjustedUrl(location *filer_pb.Location) string {
+ return location.Url
+}
diff --git a/weed/pb/filer_pb/filer_client.go b/weed/pb/filer_pb/filer_client.go
index 7198de95c..079fbd671 100644
--- a/weed/pb/filer_pb/filer_client.go
+++ b/weed/pb/filer_pb/filer_client.go
@@ -20,6 +20,7 @@ var (
type FilerClient interface {
WithFilerClient(fn func(SeaweedFilerClient) error) error
+ AdjustedUrl(location *Location) string
}
func GetEntry(filerClient FilerClient, fullFilePath util.FullPath) (entry *Entry, err error) {
diff --git a/weed/replication/sink/filersink/fetch_write.go b/weed/replication/sink/filersink/fetch_write.go
index 544b84995..b062adcfe 100644
--- a/weed/replication/sink/filersink/fetch_write.go
+++ b/weed/replication/sink/filersink/fetch_write.go
@@ -128,3 +128,6 @@ func (fs *FilerSink) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) error)
}, fs.grpcAddress, fs.grpcDialOption)
}
+func (fs *FilerSink) AdjustedUrl(location *filer_pb.Location) string {
+ return location.Url
+}
diff --git a/weed/replication/source/filer_source.go b/weed/replication/source/filer_source.go
index eff1da8dc..3982360b0 100644
--- a/weed/replication/source/filer_source.go
+++ b/weed/replication/source/filer_source.go
@@ -124,6 +124,10 @@ func (fs *FilerSource) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) erro
}
+func (fs *FilerSource) AdjustedUrl(location *filer_pb.Location) string {
+ return location.Url
+}
+
func volumeId(fileId string) string {
lastCommaIndex := strings.LastIndex(fileId, ",")
if lastCommaIndex > 0 {
diff --git a/weed/s3api/s3api_handlers.go b/weed/s3api/s3api_handlers.go
index 57b26f3dd..6935c75bd 100644
--- a/weed/s3api/s3api_handlers.go
+++ b/weed/s3api/s3api_handlers.go
@@ -50,6 +50,9 @@ func (s3a *S3ApiServer) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) err
}, s3a.option.FilerGrpcAddress, s3a.option.GrpcDialOption)
}
+func (s3a *S3ApiServer) AdjustedUrl(location *filer_pb.Location) string {
+ return location.Url
+}
// If none of the http routes match respond with MethodNotAllowed
func notFoundHandler(w http.ResponseWriter, r *http.Request) {
diff --git a/weed/server/webdav_server.go b/weed/server/webdav_server.go
index 5bd92a136..feb193230 100644
--- a/weed/server/webdav_server.go
+++ b/weed/server/webdav_server.go
@@ -123,6 +123,9 @@ func (fs *WebDavFileSystem) WithFilerClient(fn func(filer_pb.SeaweedFilerClient)
}, fs.option.FilerGrpcAddress, fs.option.GrpcDialOption)
}
+func (fs *WebDavFileSystem) AdjustedUrl(location *filer_pb.Location) string {
+ return location.Url
+}
func clearName(name string) (string, error) {
slashed := strings.HasSuffix(name, "/")
diff --git a/weed/shell/commands.go b/weed/shell/commands.go
index 6e1348ca5..0e285214b 100644
--- a/weed/shell/commands.go
+++ b/weed/shell/commands.go
@@ -102,6 +102,10 @@ func (ce *CommandEnv) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) error
}
+func (ce *CommandEnv) AdjustedUrl(location *filer_pb.Location) string {
+ return location.Url
+}
+
func parseFilerUrl(entryPath string) (filerServer string, filerPort int64, path string, err error) {
if strings.HasPrefix(entryPath, "http") {
var u *url.URL