mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-11-28 05:15:00 +08:00
refactoring in order to adjust volume server url later
This commit is contained in:
parent
d5fcb0f474
commit
723ae11db4
@ -75,7 +75,7 @@ func LookupFn(filerClient filer_pb.FilerClient) LookupFileIdFunctionType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, loc := range locations.Locations {
|
for _, loc := range locations.Locations {
|
||||||
volumeServerAddress := filerClient.AdjustedUrl(loc.Url)
|
volumeServerAddress := filerClient.AdjustedUrl(loc)
|
||||||
targetUrl := fmt.Sprintf("http://%s/%s", volumeServerAddress, fileId)
|
targetUrl := fmt.Sprintf("http://%s/%s", volumeServerAddress, fileId)
|
||||||
targetUrls = append(targetUrls, targetUrl)
|
targetUrls = append(targetUrls, targetUrl)
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ func (wfs *WFS) deleteFileIds(grpcDialOption grpc.DialOption, client filer_pb.Se
|
|||||||
}
|
}
|
||||||
for _, loc := range locations.Locations {
|
for _, loc := range locations.Locations {
|
||||||
lr.Locations = append(lr.Locations, operation.Location{
|
lr.Locations = append(lr.Locations, operation.Location{
|
||||||
Url: wfs.AdjustedUrl(loc.Url),
|
Url: wfs.AdjustedUrl(loc),
|
||||||
PublicUrl: loc.PublicUrl,
|
PublicUrl: loc.PublicUrl,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -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 {
|
if !wfs.option.OutsideContainerClusterMode {
|
||||||
return hostAndPort
|
return location.Url
|
||||||
}
|
}
|
||||||
commaIndex := strings.Index(hostAndPort, ":")
|
commaIndex := strings.Index(location.Url, ":")
|
||||||
if commaIndex < 0 {
|
if commaIndex < 0 {
|
||||||
return hostAndPort
|
return location.Url
|
||||||
}
|
}
|
||||||
filerCommaIndex := strings.Index(wfs.option.FilerGrpcAddress, ":")
|
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:])
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,8 +38,12 @@ func (wfs *WFS) saveDataAsChunk(dir string) filer.SaveDataAsChunkFunctionType {
|
|||||||
return fmt.Errorf("assign volume failure %v: %v", request, resp.Error)
|
return fmt.Errorf("assign volume failure %v: %v", request, resp.Error)
|
||||||
}
|
}
|
||||||
|
|
||||||
fileId, host, auth = resp.FileId, resp.Url, security.EncodedJwt(resp.Auth)
|
fileId, auth = resp.FileId, security.EncodedJwt(resp.Auth)
|
||||||
host = wfs.AdjustedUrl(host)
|
loc := &filer_pb.Location{
|
||||||
|
Url: resp.Url,
|
||||||
|
PublicUrl: resp.PublicUrl,
|
||||||
|
}
|
||||||
|
host = wfs.AdjustedUrl(loc)
|
||||||
collection, replication = resp.Collection, resp.Replication
|
collection, replication = resp.Collection, resp.Replication
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -108,6 +108,6 @@ func (broker *MessageBroker) WithFilerClient(fn func(filer_pb.SeaweedFilerClient
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (broker *MessageBroker) AdjustedUrl(hostAndPort string) string {
|
func (broker *MessageBroker) AdjustedUrl(location *filer_pb.Location) string {
|
||||||
return hostAndPort
|
return location.Url
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ var (
|
|||||||
|
|
||||||
type FilerClient interface {
|
type FilerClient interface {
|
||||||
WithFilerClient(fn func(SeaweedFilerClient) error) error
|
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) {
|
func GetEntry(filerClient FilerClient, fullFilePath util.FullPath) (entry *Entry, err error) {
|
||||||
|
@ -124,6 +124,6 @@ func (fs *FilerSink) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) error)
|
|||||||
}, fs.grpcAddress, fs.grpcDialOption)
|
}, fs.grpcAddress, fs.grpcDialOption)
|
||||||
|
|
||||||
}
|
}
|
||||||
func (fs *FilerSink) AdjustedUrl(hostAndPort string) string {
|
func (fs *FilerSink) AdjustedUrl(location *filer_pb.Location) string {
|
||||||
return hostAndPort
|
return location.Url
|
||||||
}
|
}
|
||||||
|
@ -111,8 +111,8 @@ func (fs *FilerSource) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) erro
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fs *FilerSource) AdjustedUrl(hostAndPort string) string {
|
func (fs *FilerSource) AdjustedUrl(location *filer_pb.Location) string {
|
||||||
return hostAndPort
|
return location.Url
|
||||||
}
|
}
|
||||||
|
|
||||||
func volumeId(fileId string) string {
|
func volumeId(fileId string) string {
|
||||||
|
@ -50,8 +50,8 @@ func (s3a *S3ApiServer) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) err
|
|||||||
}, s3a.option.FilerGrpcAddress, s3a.option.GrpcDialOption)
|
}, s3a.option.FilerGrpcAddress, s3a.option.GrpcDialOption)
|
||||||
|
|
||||||
}
|
}
|
||||||
func (s3a *S3ApiServer) AdjustedUrl(hostAndPort string) string {
|
func (s3a *S3ApiServer) AdjustedUrl(location *filer_pb.Location) string {
|
||||||
return hostAndPort
|
return location.Url
|
||||||
}
|
}
|
||||||
|
|
||||||
// If none of the http routes match respond with MethodNotAllowed
|
// If none of the http routes match respond with MethodNotAllowed
|
||||||
|
@ -118,8 +118,8 @@ func (fs *WebDavFileSystem) WithFilerClient(fn func(filer_pb.SeaweedFilerClient)
|
|||||||
}, fs.option.FilerGrpcAddress, fs.option.GrpcDialOption)
|
}, fs.option.FilerGrpcAddress, fs.option.GrpcDialOption)
|
||||||
|
|
||||||
}
|
}
|
||||||
func (fs *WebDavFileSystem) AdjustedUrl(hostAndPort string) string {
|
func (fs *WebDavFileSystem) AdjustedUrl(location *filer_pb.Location) string {
|
||||||
return hostAndPort
|
return location.Url
|
||||||
}
|
}
|
||||||
|
|
||||||
func clearName(name string) (string, error) {
|
func clearName(name string) (string, error) {
|
||||||
|
@ -102,8 +102,8 @@ func (ce *CommandEnv) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) error
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ce *CommandEnv) AdjustedUrl(hostAndPort string) string {
|
func (ce *CommandEnv) AdjustedUrl(location *filer_pb.Location) string {
|
||||||
return hostAndPort
|
return location.Url
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseFilerUrl(entryPath string) (filerServer string, filerPort int64, path string, err error) {
|
func parseFilerUrl(entryPath string) (filerServer string, filerPort int64, path string, err error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user