mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
weed mount add options for collection and replication
This commit is contained in:
parent
d0b238d2db
commit
8ab7dd9d08
|
@ -1,8 +1,10 @@
|
||||||
package command
|
package command
|
||||||
|
|
||||||
type MountOptions struct {
|
type MountOptions struct {
|
||||||
filer *string
|
filer *string
|
||||||
dir *string
|
dir *string
|
||||||
|
collection *string
|
||||||
|
replication *string
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -14,6 +16,8 @@ func init() {
|
||||||
cmdMount.IsDebug = cmdMount.Flag.Bool("debug", false, "verbose debug information")
|
cmdMount.IsDebug = cmdMount.Flag.Bool("debug", false, "verbose debug information")
|
||||||
mountOptions.filer = cmdMount.Flag.String("filer", "localhost:8888", "weed filer location")
|
mountOptions.filer = cmdMount.Flag.String("filer", "localhost:8888", "weed filer location")
|
||||||
mountOptions.dir = cmdMount.Flag.String("dir", ".", "mount weed filer to this directory")
|
mountOptions.dir = cmdMount.Flag.String("dir", ".", "mount weed filer to this directory")
|
||||||
|
mountOptions.collection = cmdMount.Flag.String("collection", "", "collection to create the files")
|
||||||
|
mountOptions.replication = cmdMount.Flag.String("replication", "000", "replication to create to files")
|
||||||
}
|
}
|
||||||
|
|
||||||
var cmdMount = &Command{
|
var cmdMount = &Command{
|
||||||
|
|
|
@ -47,7 +47,8 @@ func runMount(cmd *Command, args []string) bool {
|
||||||
c.Close()
|
c.Close()
|
||||||
})
|
})
|
||||||
|
|
||||||
err = fs.Serve(c, filesys.NewSeaweedFileSystem(*mountOptions.filer))
|
err = fs.Serve(c, filesys.NewSeaweedFileSystem(
|
||||||
|
*mountOptions.filer, *mountOptions.collection, *mountOptions.replication))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fuse.Unmount(*mountOptions.dir)
|
fuse.Unmount(*mountOptions.dir)
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,11 +123,12 @@ func (dir *Dir) Create(ctx context.Context, req *fuse.CreateRequest,
|
||||||
dir.NodeMap[req.Name] = file
|
dir.NodeMap[req.Name] = file
|
||||||
file.isOpen = true
|
file.isOpen = true
|
||||||
return file, &FileHandle{
|
return file, &FileHandle{
|
||||||
f: file,
|
f: file,
|
||||||
RequestId: req.Header.ID,
|
dirtyPages: &ContinuousDirtyPages{f: file},
|
||||||
NodeId: req.Header.Node,
|
RequestId: req.Header.ID,
|
||||||
Uid: req.Uid,
|
NodeId: req.Header.Node,
|
||||||
Gid: req.Gid,
|
Uid: req.Uid,
|
||||||
|
Gid: req.Gid,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,8 +108,8 @@ func (pages *ContinuousDirtyPages) saveToStorage(ctx context.Context) (*filer_pb
|
||||||
|
|
||||||
request := &filer_pb.AssignVolumeRequest{
|
request := &filer_pb.AssignVolumeRequest{
|
||||||
Count: 1,
|
Count: 1,
|
||||||
Replication: "000",
|
Replication: pages.f.wfs.replication,
|
||||||
Collection: "",
|
Collection: pages.f.wfs.collection,
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := client.AssignVolume(ctx, request)
|
resp, err := client.AssignVolume(ctx, request)
|
||||||
|
|
|
@ -11,12 +11,16 @@ import (
|
||||||
type WFS struct {
|
type WFS struct {
|
||||||
filer string
|
filer string
|
||||||
listDirectoryEntriesCache *ccache.Cache
|
listDirectoryEntriesCache *ccache.Cache
|
||||||
|
collection string
|
||||||
|
replication string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSeaweedFileSystem(filer string) *WFS {
|
func NewSeaweedFileSystem(filer string, collection string, replication string) *WFS {
|
||||||
return &WFS{
|
return &WFS{
|
||||||
filer: filer,
|
filer: filer,
|
||||||
listDirectoryEntriesCache: ccache.New(ccache.Configure().MaxSize(6000).ItemsToPrune(100)),
|
listDirectoryEntriesCache: ccache.New(ccache.Configure().MaxSize(6000).ItemsToPrune(100)),
|
||||||
|
collection: collection,
|
||||||
|
replication: replication,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue