SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
refactoring in order to adjust volume server url later
Chris Lu723ae11db401
diff --git a/weed/filer/reader_at.go b/weed/filer/reader_at.goindex 835d6cfc24..da7eae6212 100644--- a/weed/filer/reader_at.go+++ b/weed/filer/reader_at.go@@ -75,7 +75,7 @@ func LookupFn(filerClient filer_pb.FilerClient) LookupFileIdFunctionType {}for _, loc := range locations.Locations {- volumeServerAddress := filerClient.AdjustedUrl(loc.Url)+ volumeServerAddress := filerClient.AdjustedUrl(loc)targetUrl := fmt.Sprintf("http://%s/%s", volumeServerAddress, fileId)targetUrls = append(targetUrls, targetUrl)}diff --git a/weed/filesys/wfs_deletion.go b/weed/filesys/wfs_deletion.goindex 9791c8630f..a245b67952 100644--- a/weed/filesys/wfs_deletion.go+++ b/weed/filesys/wfs_deletion.go@@ -68,7 +68,7 @@ func (wfs *WFS) deleteFileIds(grpcDialOption grpc.DialOption, client filer_pb.Se}for _, loc := range locations.Locations {lr.Locations = append(lr.Locations, operation.Location{- Url: wfs.AdjustedUrl(loc.Url),+ Url: wfs.AdjustedUrl(loc),PublicUrl: loc.PublicUrl,})}diff --git a/weed/filesys/wfs_filer_client.go b/weed/filesys/wfs_filer_client.goindex 736df3588b..8c30de3c5d 100644--- a/weed/filesys/wfs_filer_client.go+++ b/weed/filesys/wfs_filer_client.go@@ -26,15 +26,15 @@ func (wfs *WFS) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) error) erro}-func (wfs *WFS) AdjustedUrl(hostAndPort string) string {+func (wfs *WFS) AdjustedUrl(location *filer_pb.Location) string {if !wfs.option.OutsideContainerClusterMode {- return hostAndPort+ return location.Url}- commaIndex := strings.Index(hostAndPort, ":")+ commaIndex := strings.Index(location.Url, ":")if commaIndex < 0 {- return hostAndPort+ return location.Url}filerCommaIndex := strings.Index(wfs.option.FilerGrpcAddress, ":")- return fmt.Sprintf("%s:%s", wfs.option.FilerGrpcAddress[:filerCommaIndex], hostAndPort[commaIndex+1:])+ return fmt.Sprintf("%s:%s", wfs.option.FilerGrpcAddress[:filerCommaIndex], location.Url[commaIndex+1:])}diff --git a/weed/filesys/wfs_write.go b/weed/filesys/wfs_write.goindex fec33e4ab7..e7db31203d 100644--- a/weed/filesys/wfs_write.go+++ b/weed/filesys/wfs_write.go@@ -38,8 +38,12 @@ func (wfs *WFS) saveDataAsChunk(dir string) filer.SaveDataAsChunkFunctionType {return fmt.Errorf("assign volume failure %v: %v", request, resp.Error)}- fileId, host, auth = resp.FileId, resp.Url, security.EncodedJwt(resp.Auth)- host = wfs.AdjustedUrl(host)+ fileId, auth = resp.FileId, security.EncodedJwt(resp.Auth)+ loc := &filer_pb.Location{+ Url: resp.Url,+ PublicUrl: resp.PublicUrl,+ }+ host = wfs.AdjustedUrl(loc)collection, replication = resp.Collection, resp.Replicationreturn nildiff --git a/weed/messaging/broker/broker_append.go b/weed/messaging/broker/broker_append.goindex 80f107e007..8e5b56fd01 100644--- a/weed/messaging/broker/broker_append.go+++ b/weed/messaging/broker/broker_append.go@@ -108,6 +108,6 @@ func (broker *MessageBroker) WithFilerClient(fn func(filer_pb.SeaweedFilerClient}-func (broker *MessageBroker) AdjustedUrl(hostAndPort string) string {- return hostAndPort+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.goindex 4eacfa2e5b..96a716d5b2 100644--- a/weed/pb/filer_pb/filer_client.go+++ b/weed/pb/filer_pb/filer_client.go@@ -21,7 +21,7 @@ var (type FilerClient interface {WithFilerClient(fn func(SeaweedFilerClient) error) error- AdjustedUrl(hostAndPort string) string+ 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.goindex d33669447c..98330da6bc 100644--- a/weed/replication/sink/filersink/fetch_write.go+++ b/weed/replication/sink/filersink/fetch_write.go@@ -124,6 +124,6 @@ func (fs *FilerSink) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) error)}, fs.grpcAddress, fs.grpcDialOption)}-func (fs *FilerSink) AdjustedUrl(hostAndPort string) string {- return hostAndPort+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.goindex c3ef8835c1..ff4f2eb262 100644--- a/weed/replication/source/filer_source.go+++ b/weed/replication/source/filer_source.go@@ -111,8 +111,8 @@ func (fs *FilerSource) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) erro}-func (fs *FilerSource) AdjustedUrl(hostAndPort string) string {- return hostAndPort+func (fs *FilerSource) AdjustedUrl(location *filer_pb.Location) string {+ return location.Url}func volumeId(fileId string) string {diff --git a/weed/s3api/s3api_handlers.go b/weed/s3api/s3api_handlers.goindex fa706cd1c4..6935c75bd9 100644--- a/weed/s3api/s3api_handlers.go+++ b/weed/s3api/s3api_handlers.go@@ -50,8 +50,8 @@ func (s3a *S3ApiServer) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) err}, s3a.option.FilerGrpcAddress, s3a.option.GrpcDialOption)}-func (s3a *S3ApiServer) AdjustedUrl(hostAndPort string) string {- return hostAndPort+func (s3a *S3ApiServer) AdjustedUrl(location *filer_pb.Location) string {+ return location.Url}// If none of the http routes match respond with MethodNotAlloweddiff --git a/weed/server/webdav_server.go b/weed/server/webdav_server.goindex f13e73a7b3..ee5fa5f650 100644--- a/weed/server/webdav_server.go+++ b/weed/server/webdav_server.go@@ -118,8 +118,8 @@ func (fs *WebDavFileSystem) WithFilerClient(fn func(filer_pb.SeaweedFilerClient)}, fs.option.FilerGrpcAddress, fs.option.GrpcDialOption)}-func (fs *WebDavFileSystem) AdjustedUrl(hostAndPort string) string {- return hostAndPort+func (fs *WebDavFileSystem) AdjustedUrl(location *filer_pb.Location) string {+ return location.Url}func clearName(name string) (string, error) {diff --git a/weed/shell/commands.go b/weed/shell/commands.goindex f61ed9f829..1a937ad53b 100644--- a/weed/shell/commands.go+++ b/weed/shell/commands.go@@ -102,8 +102,8 @@ func (ce *CommandEnv) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) error}-func (ce *CommandEnv) AdjustedUrl(hostAndPort string) string {- return hostAndPort+func (ce *CommandEnv) AdjustedUrl(location *filer_pb.Location) string {+ return location.Url}func parseFilerUrl(entryPath string) (filerServer string, filerPort int64, path string, err error) {