mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-11-23 18:49:17 +08:00
[shell] add admin noLock for balance (#6209)
add admin noLock for balance
This commit is contained in:
parent
15fc58bfd9
commit
9a5d3e7b31
@ -76,14 +76,19 @@ func (c *commandVolumeBalance) Do(args []string, commandEnv *CommandEnv, writer
|
|||||||
dc := balanceCommand.String("dataCenter", "", "only apply the balancing for this dataCenter")
|
dc := balanceCommand.String("dataCenter", "", "only apply the balancing for this dataCenter")
|
||||||
racks := balanceCommand.String("racks", "", "only apply the balancing for this racks")
|
racks := balanceCommand.String("racks", "", "only apply the balancing for this racks")
|
||||||
nodes := balanceCommand.String("nodes", "", "only apply the balancing for this nodes")
|
nodes := balanceCommand.String("nodes", "", "only apply the balancing for this nodes")
|
||||||
|
noLock := balanceCommand.Bool("noLock", false, "do not lock the admin shell at one's own risk")
|
||||||
applyBalancing := balanceCommand.Bool("force", false, "apply the balancing plan.")
|
applyBalancing := balanceCommand.Bool("force", false, "apply the balancing plan.")
|
||||||
if err = balanceCommand.Parse(args); err != nil {
|
if err = balanceCommand.Parse(args); err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
infoAboutSimulationMode(writer, *applyBalancing, "-force")
|
infoAboutSimulationMode(writer, *applyBalancing, "-force")
|
||||||
|
|
||||||
if err = commandEnv.confirmIsLocked(args); err != nil {
|
if *noLock {
|
||||||
return
|
commandEnv.noLock = true
|
||||||
|
} else {
|
||||||
|
if err = commandEnv.confirmIsLocked(args); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// collect topology information
|
// collect topology information
|
||||||
|
@ -35,6 +35,7 @@ type CommandEnv struct {
|
|||||||
MasterClient *wdclient.MasterClient
|
MasterClient *wdclient.MasterClient
|
||||||
option *ShellOptions
|
option *ShellOptions
|
||||||
locker *exclusive_locks.ExclusiveLocker
|
locker *exclusive_locks.ExclusiveLocker
|
||||||
|
noLock bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCommandEnv(options *ShellOptions) *CommandEnv {
|
func NewCommandEnv(options *ShellOptions) *CommandEnv {
|
||||||
@ -42,6 +43,7 @@ func NewCommandEnv(options *ShellOptions) *CommandEnv {
|
|||||||
env: make(map[string]string),
|
env: make(map[string]string),
|
||||||
MasterClient: wdclient.NewMasterClient(options.GrpcDialOption, *options.FilerGroup, pb.AdminShellClient, "", "", "", *pb.ServerAddresses(*options.Masters).ToServiceDiscovery()),
|
MasterClient: wdclient.NewMasterClient(options.GrpcDialOption, *options.FilerGroup, pb.AdminShellClient, "", "", "", *pb.ServerAddresses(*options.Masters).ToServiceDiscovery()),
|
||||||
option: options,
|
option: options,
|
||||||
|
noLock: false,
|
||||||
}
|
}
|
||||||
ce.locker = exclusive_locks.NewExclusiveLocker(ce.MasterClient, "shell")
|
ce.locker = exclusive_locks.NewExclusiveLocker(ce.MasterClient, "shell")
|
||||||
return ce
|
return ce
|
||||||
@ -79,6 +81,9 @@ func (ce *CommandEnv) isLocked() bool {
|
|||||||
if ce == nil {
|
if ce == nil {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
if ce.noLock {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return ce.locker.IsLocked()
|
return ce.locker.IsLocked()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user