mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
add mountOptions.chunkSizeLimitMB, remove cmdMount.IsDebug
This commit is contained in:
parent
8ab7dd9d08
commit
5c4480ec6c
|
@ -1,10 +1,11 @@
|
||||||
package command
|
package command
|
||||||
|
|
||||||
type MountOptions struct {
|
type MountOptions struct {
|
||||||
filer *string
|
filer *string
|
||||||
dir *string
|
dir *string
|
||||||
collection *string
|
collection *string
|
||||||
replication *string
|
replication *string
|
||||||
|
chunkSizeLimitMB *int
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -13,11 +14,11 @@ var (
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
cmdMount.Run = runMount // break init cycle
|
cmdMount.Run = runMount // break init cycle
|
||||||
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.collection = cmdMount.Flag.String("collection", "", "collection to create the files")
|
||||||
mountOptions.replication = cmdMount.Flag.String("replication", "000", "replication to create to files")
|
mountOptions.replication = cmdMount.Flag.String("replication", "000", "replication to create to files")
|
||||||
|
mountOptions.chunkSizeLimitMB = cmdMount.Flag.Int("chunkSizeLimitMB", 0, "if set, limit the chunk size in MB")
|
||||||
}
|
}
|
||||||
|
|
||||||
var cmdMount = &Command{
|
var cmdMount = &Command{
|
||||||
|
|
|
@ -48,7 +48,7 @@ func runMount(cmd *Command, args []string) bool {
|
||||||
})
|
})
|
||||||
|
|
||||||
err = fs.Serve(c, filesys.NewSeaweedFileSystem(
|
err = fs.Serve(c, filesys.NewSeaweedFileSystem(
|
||||||
*mountOptions.filer, *mountOptions.collection, *mountOptions.replication))
|
*mountOptions.filer, *mountOptions.collection, *mountOptions.replication, *mountOptions.chunkSizeLimitMB))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fuse.Unmount(*mountOptions.dir)
|
fuse.Unmount(*mountOptions.dir)
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,13 @@ func (pages *ContinuousDirtyPages) AddPage(ctx context.Context, offset int64, da
|
||||||
Offset: offset,
|
Offset: offset,
|
||||||
Data: data,
|
Data: data,
|
||||||
})
|
})
|
||||||
return nil, nil
|
|
||||||
|
if pages.totalSize() >= pages.f.wfs.chunkSizeLimit {
|
||||||
|
chunk, err = pages.saveToStorage(ctx)
|
||||||
|
pages.pages = nil
|
||||||
|
glog.V(3).Infof("%s/%s add split [%d,%d)", pages.f.dir.Path, pages.f.Name, chunk.Offset, chunk.Offset+int64(chunk.Size))
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
chunk, err = pages.saveToStorage(ctx)
|
chunk, err = pages.saveToStorage(ctx)
|
||||||
|
|
|
@ -13,14 +13,16 @@ type WFS struct {
|
||||||
listDirectoryEntriesCache *ccache.Cache
|
listDirectoryEntriesCache *ccache.Cache
|
||||||
collection string
|
collection string
|
||||||
replication string
|
replication string
|
||||||
|
chunkSizeLimit int64
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSeaweedFileSystem(filer string, collection string, replication string) *WFS {
|
func NewSeaweedFileSystem(filer string, collection string, replication string, chunkSizeLimitMB int) *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,
|
collection: collection,
|
||||||
replication: replication,
|
replication: replication,
|
||||||
|
chunkSizeLimit: int64(chunkSizeLimitMB) * 1024 * 1024,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue