diff options
| author | Chris Lu <chris.lu@gmail.com> | 2020-04-23 03:11:07 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2020-04-23 03:11:07 -0700 |
| commit | 69f336e59f6e4f855bfc5c2ebf0e57413fe92961 (patch) | |
| tree | 82c58dc40808499992b34b9819478f9522654fd5 /weed/shell/command_fs_lock_unlock.go | |
| parent | ff0a7c1d18361ad76fb2c6134cfdca267e96fea0 (diff) | |
| download | seaweedfs-69f336e59f6e4f855bfc5c2ebf0e57413fe92961.tar.xz seaweedfs-69f336e59f6e4f855bfc5c2ebf0e57413fe92961.zip | |
shell: add lock/unlock command
Diffstat (limited to 'weed/shell/command_fs_lock_unlock.go')
| -rw-r--r-- | weed/shell/command_fs_lock_unlock.go | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/weed/shell/command_fs_lock_unlock.go b/weed/shell/command_fs_lock_unlock.go new file mode 100644 index 000000000..a173d6c85 --- /dev/null +++ b/weed/shell/command_fs_lock_unlock.go @@ -0,0 +1,55 @@ +package shell + +import ( + "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() + + 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 +} + |
