mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-10-24 15:00:43 +02:00
shell: add lock/unlock command
This commit is contained in:
1 parent
ff0a7c1d18
commit
69f336e59f
2 files changed
+58
-2
No files matched your search
@@ -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
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user