diff options
Diffstat (limited to 'weed/shell/command_fs_configure.go')
| -rw-r--r-- | weed/shell/command_fs_configure.go | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/weed/shell/command_fs_configure.go b/weed/shell/command_fs_configure.go index d4d70048d..8def10d03 100644 --- a/weed/shell/command_fs_configure.go +++ b/weed/shell/command_fs_configure.go @@ -7,9 +7,11 @@ import ( "io" "math" "net/http" + "strings" "github.com/chrislusf/seaweedfs/weed/filer" "github.com/chrislusf/seaweedfs/weed/pb/filer_pb" + "github.com/chrislusf/seaweedfs/weed/storage/super_block" "github.com/chrislusf/seaweedfs/weed/util" ) @@ -27,13 +29,16 @@ func (c *commandFsConfigure) Name() string { func (c *commandFsConfigure) Help() string { return `configure and apply storage options for each location - # see the possible configuration file content + # see the current configuration file content fs.configure # trying the changes and see the possible configuration file content fs.configure -locationPrfix=/my/folder -collection=abc fs.configure -locationPrfix=/my/folder -collection=abc -ttl=7d + # example: configure adding only 1 physical volume for each bucket collection + fs.configure -locationPrfix=/buckets/ -volumeGrowthCount=1 + # apply the changes fs.configure -locationPrfix=/my/folder -collection=abc -apply @@ -51,6 +56,7 @@ func (c *commandFsConfigure) Do(args []string, commandEnv *CommandEnv, writer io replication := fsConfigureCommand.String("replication", "", "assign writes with this replication") ttl := fsConfigureCommand.String("ttl", "", "assign writes with this ttl") fsync := fsConfigureCommand.Bool("fsync", false, "fsync for the writes") + volumeGrowthCount := fsConfigureCommand.Int("volumeGrowthCount", 0, "the number of physical volumes to add if no writable volumes") isDelete := fsConfigureCommand.Bool("delete", false, "delete the configuration by locationPrefix") apply := fsConfigureCommand.Bool("apply", false, "update and apply filer configuration") if err = fsConfigureCommand.Parse(args); err != nil { @@ -82,12 +88,31 @@ func (c *commandFsConfigure) Do(args []string, commandEnv *CommandEnv, writer io if *locationPrefix != "" { locConf := &filer_pb.FilerConf_PathConf{ - LocationPrefix: *locationPrefix, - Collection: *collection, - Replication: *replication, - Ttl: *ttl, - Fsync: *fsync, + LocationPrefix: *locationPrefix, + Collection: *collection, + Replication: *replication, + Ttl: *ttl, + Fsync: *fsync, + VolumeGrowthCount: uint32(*volumeGrowthCount), + } + + // check collection + if *collection != "" && strings.HasPrefix(*locationPrefix, "/buckets/") { + return fmt.Errorf("one s3 bucket goes to one collection and not customizable.") } + + // check replication + if *replication != "" { + rp, err := super_block.NewReplicaPlacementFromString(*replication) + if err != nil { + return fmt.Errorf("parse replication %s: %v", *replication, err) + } + if *volumeGrowthCount % rp.GetCopyCount() != 0 { + return fmt.Errorf("volumeGrowthCount %d should be devided by replication copy count %d", *volumeGrowthCount, rp.GetCopyCount()) + } + } + + // save it if *isDelete { fc.DeleteLocationConf(*locationPrefix) } else { |
