2022-12-28 17:36:44 +08:00
|
|
|
package shell
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"io"
|
|
|
|
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
Commands = append(Commands, &commandEnableVacuum{})
|
|
|
|
}
|
|
|
|
|
|
|
|
type commandEnableVacuum struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *commandEnableVacuum) Name() string {
|
|
|
|
return "volume.vacuum.enable"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *commandEnableVacuum) Help() string {
|
2022-12-29 23:05:05 +08:00
|
|
|
return `enable vacuuming request from Master
|
2022-12-28 17:36:44 +08:00
|
|
|
|
|
|
|
volume.vacuum.enable
|
|
|
|
|
|
|
|
`
|
|
|
|
}
|
|
|
|
|
2024-09-29 11:22:57 +08:00
|
|
|
func (c *commandEnableVacuum) IsResourceHeavy() bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2022-12-28 17:36:44 +08:00
|
|
|
func (c *commandEnableVacuum) Do(args []string, commandEnv *CommandEnv, writer io.Writer) (err error) {
|
|
|
|
|
|
|
|
if err = commandEnv.confirmIsLocked(args); err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
err = commandEnv.MasterClient.WithClient(false, func(client master_pb.SeaweedClient) error {
|
|
|
|
_, err = client.EnableVacuum(context.Background(), &master_pb.EnableVacuumRequest{})
|
|
|
|
return err
|
|
|
|
})
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|