Skip to content

Commit

Permalink
json
Browse files Browse the repository at this point in the history
Signed-off-by: Calvin Neo <[email protected]>
  • Loading branch information
CalvinNeo committed Dec 20, 2024
1 parent 1b5eecb commit feb6ccc
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
17 changes: 13 additions & 4 deletions pkg/schedule/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -1333,19 +1333,28 @@ func (h *Handler) BalanceKeyrange(data string) (string, error) {
// CheckBalanceKeyrangeStatus returns the status of the balance-keyrange scheduler.
func (h *Handler) CheckBalanceKeyrangeStatus() (any, error) {
sc, err := h.GetSchedulersController()
makeJsonResp := func(s string) any {
return struct {
Scheduling bool `json:"scheduling"`
ErrMsg string `json:"err_msg"`
}{
Scheduling: false,
ErrMsg: s,
}
}
if err != nil {
return "", err
return makeJsonResp("Get scheduler control error"), err
}
s := sc.GetScheduler(types.BalanceKeyrangeScheduler.String())
if s == nil {
return "", nil
return makeJsonResp("No scheduler found"), nil
}
if s.IsDisable() {
return "", nil
return makeJsonResp("Scheduler disabled"), nil
}
st := sc.GetSchedulerStatus(types.BalanceKeyrangeScheduler.String())
if st == nil {
return "", nil
return makeJsonResp("can't get scheduler status"), nil
}
return st, nil
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/schedule/schedulers/balance_keyrange.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,11 +359,13 @@ func (s *balanceKeyrangeScheduler) GetStatus() any {
RunningOps []*OperatorWrapper `json:"running"`
Pending []*OperatorWrapper `json:"pending"`
TotalCount int `json:"total"`
ErrMsg string `json:"err_msg"`
}{
Scheduling: scheduling,
RunningOps: running,
Pending: pending,
TotalCount: total,
ErrMsg: "",
}
return j
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/schedule/schedulers/balance_keyrange_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func assertValidateMigrationPlan(re *require.Assertions, ops []*MigrationOp, sto
storesIn[op.ToStore] += len(op.Regions)
storesOut[op.FromStore] += len(op.Regions)
// For each region in migration plan, it no longer exists in FromStore, and exists in ToStore
for rid, _ := range op.Regions {
for rid := range op.Regions {
inTo := false
inFr := false
r, ok := regionMap[rid]
Expand Down Expand Up @@ -281,7 +281,7 @@ type regionStoresPair struct {

func buildRedistributeRegionsTestCases(storeIDs []uint64, regionDist []regionStoresPair) ([]*metapb.Store, []*core.RegionInfo) {
storeIdLabels := []uint64{}
for _ = range storeIDs {
for range storeIDs {
storeIdLabels = append(storeIdLabels, 0)
}
return buildRedistributeRegionsTestCasesWithLabel(storeIDs, storeIdLabels, regionDist)
Expand Down
1 change: 0 additions & 1 deletion server/api/region.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ func (h *regionsHandler) CheckRegionsReplicated(w http.ResponseWriter, r *http.R

// @Tags region
// @Summary
// @Accept json
// @Param start_key body string true "Regions start key, hex encoded"
// @Param end_key body string true "Regions end key, hex encoded"
// @Param batch_size body string true "Maximum operators scheduled in one"
Expand Down

0 comments on commit feb6ccc

Please sign in to comment.