mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
mount: change option name to volumeServerAccess, with publicUrl and filerProxy modes
This commit is contained in:
parent
990fa69bfe
commit
19295600f9
|
@ -11,19 +11,19 @@ type MountOptions struct {
|
||||||
dir *string
|
dir *string
|
||||||
dirAutoCreate *bool
|
dirAutoCreate *bool
|
||||||
collection *string
|
collection *string
|
||||||
replication *string
|
replication *string
|
||||||
ttlSec *int
|
ttlSec *int
|
||||||
chunkSizeLimitMB *int
|
chunkSizeLimitMB *int
|
||||||
concurrentWriters *int
|
concurrentWriters *int
|
||||||
cacheDir *string
|
cacheDir *string
|
||||||
cacheSizeMB *int64
|
cacheSizeMB *int64
|
||||||
dataCenter *string
|
dataCenter *string
|
||||||
allowOthers *bool
|
allowOthers *bool
|
||||||
umaskString *string
|
umaskString *string
|
||||||
nonempty *bool
|
nonempty *bool
|
||||||
outsideContainerClusterMode *bool
|
volumeServerAccess *string
|
||||||
uidMap *string
|
uidMap *string
|
||||||
gidMap *string
|
gidMap *string
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -50,7 +50,7 @@ func init() {
|
||||||
mountOptions.allowOthers = cmdMount.Flag.Bool("allowOthers", true, "allows other users to access the file system")
|
mountOptions.allowOthers = cmdMount.Flag.Bool("allowOthers", true, "allows other users to access the file system")
|
||||||
mountOptions.umaskString = cmdMount.Flag.String("umask", "022", "octal umask, e.g., 022, 0111")
|
mountOptions.umaskString = cmdMount.Flag.String("umask", "022", "octal umask, e.g., 022, 0111")
|
||||||
mountOptions.nonempty = cmdMount.Flag.Bool("nonempty", false, "allows the mounting over a non-empty directory")
|
mountOptions.nonempty = cmdMount.Flag.Bool("nonempty", false, "allows the mounting over a non-empty directory")
|
||||||
mountOptions.outsideContainerClusterMode = cmdMount.Flag.Bool("outsideContainerClusterMode", false, "allows other users to access volume servers with publicUrl")
|
mountOptions.volumeServerAccess = cmdMount.Flag.String("volumeServerAccess", "direct", "access volume servers by [direct|publicUrl|filerProxy]")
|
||||||
mountOptions.uidMap = cmdMount.Flag.String("map.uid", "", "map local uid to uid on filer, comma-separated <local_uid>:<filer_uid>")
|
mountOptions.uidMap = cmdMount.Flag.String("map.uid", "", "map local uid to uid on filer, comma-separated <local_uid>:<filer_uid>")
|
||||||
mountOptions.gidMap = cmdMount.Flag.String("map.gid", "", "map local gid to gid on filer, comma-separated <local_gid>:<filer_gid>")
|
mountOptions.gidMap = cmdMount.Flag.String("map.gid", "", "map local gid to gid on filer, comma-separated <local_gid>:<filer_gid>")
|
||||||
|
|
||||||
|
|
|
@ -179,19 +179,19 @@ func RunMount(option *MountOptions, umask os.FileMode) bool {
|
||||||
TtlSec: int32(*option.ttlSec),
|
TtlSec: int32(*option.ttlSec),
|
||||||
ChunkSizeLimit: int64(chunkSizeLimitMB) * 1024 * 1024,
|
ChunkSizeLimit: int64(chunkSizeLimitMB) * 1024 * 1024,
|
||||||
ConcurrentWriters: *option.concurrentWriters,
|
ConcurrentWriters: *option.concurrentWriters,
|
||||||
CacheDir: *option.cacheDir,
|
CacheDir: *option.cacheDir,
|
||||||
CacheSizeMB: *option.cacheSizeMB,
|
CacheSizeMB: *option.cacheSizeMB,
|
||||||
DataCenter: *option.dataCenter,
|
DataCenter: *option.dataCenter,
|
||||||
EntryCacheTtl: 3 * time.Second,
|
EntryCacheTtl: 3 * time.Second,
|
||||||
MountUid: uid,
|
MountUid: uid,
|
||||||
MountGid: gid,
|
MountGid: gid,
|
||||||
MountMode: mountMode,
|
MountMode: mountMode,
|
||||||
MountCtime: fileInfo.ModTime(),
|
MountCtime: fileInfo.ModTime(),
|
||||||
MountMtime: time.Now(),
|
MountMtime: time.Now(),
|
||||||
Umask: umask,
|
Umask: umask,
|
||||||
OutsideContainerClusterMode: *mountOptions.outsideContainerClusterMode,
|
VolumeServerAccess: *mountOptions.volumeServerAccess,
|
||||||
Cipher: cipher,
|
Cipher: cipher,
|
||||||
UidGidMapper: uidGidMapper,
|
UidGidMapper: uidGidMapper,
|
||||||
})
|
})
|
||||||
|
|
||||||
// mount
|
// mount
|
||||||
|
|
|
@ -48,9 +48,9 @@ type Option struct {
|
||||||
MountCtime time.Time
|
MountCtime time.Time
|
||||||
MountMtime time.Time
|
MountMtime time.Time
|
||||||
|
|
||||||
OutsideContainerClusterMode bool // whether the mount runs outside SeaweedFS containers
|
VolumeServerAccess string // how to access volume servers
|
||||||
Cipher bool // whether encrypt data on volume server
|
Cipher bool // whether encrypt data on volume server
|
||||||
UidGidMapper *meta_cache.UidGidMapper
|
UidGidMapper *meta_cache.UidGidMapper
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ = fs.FS(&WFS{})
|
var _ = fs.FS(&WFS{})
|
||||||
|
@ -257,7 +257,7 @@ func (wfs *WFS) mapPbIdFromLocalToFiler(entry *filer_pb.Entry) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wfs *WFS) LookupFn() wdclient.LookupFileIdFunctionType {
|
func (wfs *WFS) LookupFn() wdclient.LookupFileIdFunctionType {
|
||||||
if wfs.option.OutsideContainerClusterMode {
|
if wfs.option.VolumeServerAccess == "filerProxy" {
|
||||||
return func(fileId string) (targetUrls []string, err error) {
|
return func(fileId string) (targetUrls []string, err error) {
|
||||||
return []string{"http://" + wfs.option.FilerAddress + "/?proxyChunkId=" + fileId}, nil
|
return []string{"http://" + wfs.option.FilerAddress + "/?proxyChunkId=" + fileId}, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ func (wfs *WFS) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) error) erro
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wfs *WFS) AdjustedUrl(location *filer_pb.Location) string {
|
func (wfs *WFS) AdjustedUrl(location *filer_pb.Location) string {
|
||||||
if wfs.option.OutsideContainerClusterMode {
|
if wfs.option.VolumeServerAccess == "publicUrl" {
|
||||||
return location.PublicUrl
|
return location.PublicUrl
|
||||||
}
|
}
|
||||||
return location.Url
|
return location.Url
|
||||||
|
|
|
@ -53,7 +53,7 @@ func (wfs *WFS) saveDataAsChunk(fullPath util.FullPath) filer.SaveDataAsChunkFun
|
||||||
}
|
}
|
||||||
|
|
||||||
fileUrl := fmt.Sprintf("http://%s/%s", host, fileId)
|
fileUrl := fmt.Sprintf("http://%s/%s", host, fileId)
|
||||||
if wfs.option.OutsideContainerClusterMode {
|
if wfs.option.VolumeServerAccess == "filerProxy" {
|
||||||
fileUrl = fmt.Sprintf("http://%s/?proxyChunkId=%s", wfs.option.FilerAddress, fileId)
|
fileUrl = fmt.Sprintf("http://%s/?proxyChunkId=%s", wfs.option.FilerAddress, fileId)
|
||||||
}
|
}
|
||||||
uploadResult, err, data := operation.Upload(fileUrl, filename, wfs.option.Cipher, reader, false, "", nil, auth)
|
uploadResult, err, data := operation.Upload(fileUrl, filename, wfs.option.Cipher, reader, false, "", nil, auth)
|
||||||
|
|
Loading…
Reference in a new issue