diff options
| author | chrislu <chrislu@roblox.com> | 2021-12-10 13:11:00 -0800 |
|---|---|---|
| committer | chrislu <chrislu@roblox.com> | 2021-12-10 13:11:00 -0800 |
| commit | 991a3dca0d30e980a234c8d8e4c5558625b03325 (patch) | |
| tree | f6a092b524d3bdd5f98e834f2e1124c65059fe9a /weed/shell/command_lock_unlock.go | |
| parent | 2d6fcdf83ae4d033e3457f4722feaeea761b1a02 (diff) | |
| download | seaweedfs-991a3dca0d30e980a234c8d8e4c5558625b03325.tar.xz seaweedfs-991a3dca0d30e980a234c8d8e4c5558625b03325.zip | |
rename file
Diffstat (limited to 'weed/shell/command_lock_unlock.go')
| -rw-r--r-- | weed/shell/command_lock_unlock.go | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/weed/shell/command_lock_unlock.go b/weed/shell/command_lock_unlock.go new file mode 100644 index 000000000..33458bb6f --- /dev/null +++ b/weed/shell/command_lock_unlock.go @@ -0,0 +1,55 @@ +package shell + +import ( + "github.com/chrislusf/seaweedfs/weed/util" + "io" +) + +func init() { + Commands = append(Commands, &commandUnlock{}) + Commands = append(Commands, &commandLock{}) +} + +// =========== Lock ============== +type commandLock struct { +} + +func (c *commandLock) Name() string { + return "lock" +} + +func (c *commandLock) Help() string { + return `lock in order to exclusively manage the cluster + + This is a blocking operation if there is alread another lock. +` +} + +func (c *commandLock) Do(args []string, commandEnv *CommandEnv, writer io.Writer) (err error) { + + commandEnv.locker.RequestLock(util.DetectedHostAddress()) + + return nil +} + +// =========== Unlock ============== + +type commandUnlock struct { +} + +func (c *commandUnlock) Name() string { + return "unlock" +} + +func (c *commandUnlock) Help() string { + return `unlock the cluster-wide lock + +` +} + +func (c *commandUnlock) Do(args []string, commandEnv *CommandEnv, writer io.Writer) (err error) { + + commandEnv.locker.ReleaseLock() + + return nil +} |
