You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1002 B

  1. package shell
  2. import (
  3. "github.com/seaweedfs/seaweedfs/weed/util"
  4. "io"
  5. )
  6. func init() {
  7. Commands = append(Commands, &commandUnlock{})
  8. Commands = append(Commands, &commandLock{})
  9. }
  10. // =========== Lock ==============
  11. type commandLock struct {
  12. }
  13. func (c *commandLock) Name() string {
  14. return "lock"
  15. }
  16. func (c *commandLock) Help() string {
  17. return `lock in order to exclusively manage the cluster
  18. This is a blocking operation if there is alread another lock.
  19. `
  20. }
  21. func (c *commandLock) Do(args []string, commandEnv *CommandEnv, writer io.Writer) (err error) {
  22. commandEnv.locker.RequestLock(util.DetectedHostAddress())
  23. return nil
  24. }
  25. // =========== Unlock ==============
  26. type commandUnlock struct {
  27. }
  28. func (c *commandUnlock) Name() string {
  29. return "unlock"
  30. }
  31. func (c *commandUnlock) Help() string {
  32. return `unlock the cluster-wide lock
  33. `
  34. }
  35. func (c *commandUnlock) Do(args []string, commandEnv *CommandEnv, writer io.Writer) (err error) {
  36. commandEnv.locker.ReleaseLock()
  37. return nil
  38. }