diff options
| author | Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.com> | 2024-08-05 21:22:17 +0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-05 09:22:17 -0700 |
| commit | ef4c555e90a0c36112324379e54f96002b477f34 (patch) | |
| tree | b60fcf776c98ee2b41873dd6bdaa1a7b2df67f27 | |
| parent | bd1b8119feef373dc71a7a315f2d3ff2bb983f45 (diff) | |
| download | seaweedfs-ef4c555e90a0c36112324379e54f96002b477f34.tar.xz seaweedfs-ef4c555e90a0c36112324379e54f96002b477f34.zip | |
[shell] volume.grow (#5855)
| -rw-r--r-- | weed/shell/command_volume_grow.go | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/weed/shell/command_volume_grow.go b/weed/shell/command_volume_grow.go new file mode 100644 index 000000000..21d98dddd --- /dev/null +++ b/weed/shell/command_volume_grow.go @@ -0,0 +1,64 @@ +package shell + +import ( + "context" + "flag" + "fmt" + "github.com/seaweedfs/seaweedfs/weed/pb/master_pb" + "io" +) + +func init() { + Commands = append(Commands, &commandGrow{}) +} + +type commandGrow struct { +} + +func (c *commandGrow) Name() string { + return "volume.grow" +} + +func (c *commandGrow) Help() string { + return `grow volumes + + volume.grow [-collection=<collection name>] [-dataCenter=<data center name>] + +` +} + +func (c *commandGrow) Do(args []string, commandEnv *CommandEnv, writer io.Writer) (err error) { + + volumeVacuumCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError) + growCount := volumeVacuumCommand.Uint("count", 2, "") + collection := volumeVacuumCommand.String("collection", "", "grow this collection") + dataCenter := volumeVacuumCommand.String("dataCenter", "", "grow volumes only from the specified data center") + + if err = volumeVacuumCommand.Parse(args); err != nil { + return nil + } + + assignRequest := &master_pb.AssignRequest{ + Count: 0, + Collection: *collection, + WritableVolumeCount: uint32(*growCount), + } + if *dataCenter != "" { + assignRequest.DataCenter = *dataCenter + } + + err = commandEnv.MasterClient.WithClient(false, func(client master_pb.SeaweedClient) error { + _, err := client.Assign(context.Background(), assignRequest) + + if err != nil { + return fmt.Errorf("Assign: %v", err) + } + return nil + }) + + if err != nil { + return + } + + return nil +} |
