MCPcopy
hub / github.com/CodisLabs/codis / handleSlotActionCommand

Method handleSlotActionCommand

cmd/admin/dashboard.go:702–773  ·  view source on GitHub ↗
(d map[string]interface{})

Source from the content-addressed store, hash-verified

700}
701
702func (t *cmdDashboard) handleSlotActionCommand(d map[string]interface{}) {
703 c := t.newTopomClient()
704
705 switch {
706
707 case d["--create"].(bool):
708
709 sid := utils.ArgumentIntegerMust(d, "--sid")
710 gid := utils.ArgumentIntegerMust(d, "--gid")
711
712 log.Debugf("call rpc create-slot-action to dashboard %s", t.addr)
713 if err := c.SlotCreateAction(sid, gid); err != nil {
714 log.PanicErrorf(err, "call rpc create-slot-action to dashboard %s failed", t.addr)
715 }
716 log.Debugf("call rpc create-slot-action OK")
717
718 case d["--remove"].(bool):
719
720 sid := utils.ArgumentIntegerMust(d, "--sid")
721
722 log.Debugf("call rpc remove-slot-action to dashboard %s", t.addr)
723 if err := c.SlotRemoveAction(sid); err != nil {
724 log.PanicErrorf(err, "call rpc remove-slot-action to dashboard %s failed", t.addr)
725 }
726 log.Debugf("call rpc remove-slot-action OK")
727
728 case d["--create-some"].(bool):
729
730 src := utils.ArgumentIntegerMust(d, "--gid-from")
731 dst := utils.ArgumentIntegerMust(d, "--gid-to")
732 num := utils.ArgumentIntegerMust(d, "--num-slots")
733
734 log.Debugf("call rpc create-slot-action-some to dashboard %s", t.addr)
735 if err := c.SlotCreateActionSome(src, dst, num); err != nil {
736 log.PanicErrorf(err, "call rpc create-slot-action-some to dashboard %s failed", t.addr)
737 }
738 log.Debugf("call rpc create-slot-action-some OK")
739
740 case d["--create-range"].(bool):
741
742 beg := utils.ArgumentIntegerMust(d, "--beg")
743 end := utils.ArgumentIntegerMust(d, "--end")
744 gid := utils.ArgumentIntegerMust(d, "--gid")
745
746 log.Debugf("call rpc create-slot-action-range to dashboard %s", t.addr)
747 if err := c.SlotCreateActionRange(beg, end, gid); err != nil {
748 log.PanicErrorf(err, "call rpc create-slot-action-range to dashboard %s failed", t.addr)
749 }
750 log.Debugf("call rpc create-slot-action-range OK")
751
752 case d["--interval"] != nil:
753
754 value := utils.ArgumentIntegerMust(d, "--interval")
755
756 log.Debugf("call rpc slot-action-interval to dashboard %s", t.addr)
757 if err := c.SetSlotActionInterval(value); err != nil {
758 log.PanicErrorf(err, "call rpc slot-action-interval to dashboard %s failed", t.addr)
759 }

Callers 1

MainMethod · 0.95

Calls 9

newTopomClientMethod · 0.95
DebugfMethod · 0.80
PanicErrorfMethod · 0.80
SlotCreateActionMethod · 0.45
SlotRemoveActionMethod · 0.45
SlotCreateActionSomeMethod · 0.45
SlotCreateActionRangeMethod · 0.45
SetSlotActionIntervalMethod · 0.45
SetSlotActionDisabledMethod · 0.45

Tested by

no test coverage detected