Skip to content

Commit

Permalink
fix conflict
Browse files Browse the repository at this point in the history
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
  • Loading branch information
CabinfeverB committed Jan 10, 2024
1 parent 56045ac commit 66eb822
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 88 deletions.
48 changes: 0 additions & 48 deletions pkg/schedule/schedulers/evict_slow_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,54 +92,6 @@ func (conf *evictSlowStoreSchedulerConfig) clearAndPersist() (oldID uint64, err
return
}

<<<<<<< HEAD
=======
type evictSlowStoreHandler struct {
rd *render.Render
config *evictSlowStoreSchedulerConfig
}

func newEvictSlowStoreHandler(config *evictSlowStoreSchedulerConfig) http.Handler {
h := &evictSlowStoreHandler{
config: config,
rd: render.New(render.Options{IndentJSON: true}),
}
router := mux.NewRouter()
router.HandleFunc("/config", h.UpdateConfig).Methods(http.MethodPost)
router.HandleFunc("/list", h.ListConfig).Methods(http.MethodGet)
return router
}

func (handler *evictSlowStoreHandler) UpdateConfig(w http.ResponseWriter, r *http.Request) {
var input map[string]interface{}
if err := apiutil.ReadJSONRespondError(handler.rd, w, r.Body, &input); err != nil {
return
}
recoveryDurationGapFloat, ok := input["recovery-duration"].(float64)
if !ok {
handler.rd.JSON(w, http.StatusInternalServerError, errors.New("invalid argument for 'recovery-duration'").Error())
return
}
handler.config.Lock()
defer handler.config.Unlock()
prevRecoveryDurationGap := handler.config.RecoveryDurationGap
recoveryDurationGap := uint64(recoveryDurationGapFloat)
handler.config.RecoveryDurationGap = recoveryDurationGap
if err := handler.config.persistLocked(); err != nil {
handler.rd.JSON(w, http.StatusInternalServerError, err.Error())
handler.config.RecoveryDurationGap = prevRecoveryDurationGap
return
}
log.Info("evict-slow-store-scheduler update 'recovery-duration' - unit: s", zap.Uint64("prev", prevRecoveryDurationGap), zap.Uint64("cur", recoveryDurationGap))
handler.rd.JSON(w, http.StatusOK, "Config updated.")
}

func (handler *evictSlowStoreHandler) ListConfig(w http.ResponseWriter, r *http.Request) {
conf := handler.config.Clone()
handler.rd.JSON(w, http.StatusOK, conf)
}

>>>>>>> 8b8c78a78 (scheduler: add aduit log for scheduler config API and add resp msg for evict-leader (#7674))
type evictSlowStoreScheduler struct {
*BaseScheduler
conf *evictSlowStoreSchedulerConfig
Expand Down
12 changes: 3 additions & 9 deletions server/api/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,18 +220,12 @@ func (suite *serviceTestSuite) TestServiceLabels() {
suite.Equal("Profile", serviceLabel)

accessPaths = suite.svr.GetServiceLabels("GetSchedulerConfig")
<<<<<<< HEAD
suite.Len(accessPaths, 1)
suite.Equal("/pd/api/v1/scheduler-config", accessPaths[0].Path)
suite.Equal("", accessPaths[0].Method)
=======
re.Len(accessPaths, 1)
re.Equal("/pd/api/v1/scheduler-config", accessPaths[0].Path)
re.Equal("GET", accessPaths[0].Method)
suite.Equal("GET", accessPaths[0].Method)
accessPaths = suite.svr.GetServiceLabels("HandleSchedulerConfig")
re.Len(accessPaths, 4)
re.Equal("/pd/api/v1/scheduler-config", accessPaths[0].Path)
>>>>>>> 8b8c78a78 (scheduler: add aduit log for scheduler config API and add resp msg for evict-leader (#7674))
suite.Len(accessPaths, 4)
suite.Equal("/pd/api/v1/scheduler-config", accessPaths[0].Path)

accessPaths = suite.svr.GetServiceLabels("ResignLeader")
suite.Len(accessPaths, 1)
Expand Down
31 changes: 0 additions & 31 deletions tests/pdctl/scheduler/scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,39 +411,8 @@ func (suite *schedulerTestSuite) checkScheduler(cluster *tests.TestCluster) {
echo = mustExec(re, cmd, []string{"-u", pdAddr, "scheduler", "add", "balance-leader-scheduler"}, nil)
re.Contains(echo, "Success!")

<<<<<<< HEAD:tests/pdctl/scheduler/scheduler_test.go
// test evict-slow-trend scheduler config
echo = mustExec(re, cmd, []string{"-u", pdAddr, "scheduler", "add", "evict-slow-trend-scheduler"}, nil)
=======
// test evict-slow-store && evict-slow-trend schedulers config
evictSlownessSchedulers := []string{"evict-slow-store-scheduler", "evict-slow-trend-scheduler"}
for _, schedulerName := range evictSlownessSchedulers {
echo = mustExec(re, cmd, []string{"-u", pdAddr, "scheduler", "add", schedulerName}, nil)
if strings.Contains(echo, "Success!") {
re.Contains(echo, "Success!")
} else {
re.Contains(echo, "scheduler existed")
}
testutil.Eventually(re, func() bool {
echo = mustExec(re, cmd, []string{"-u", pdAddr, "scheduler", "show"}, nil)
return strings.Contains(echo, schedulerName)
})
echo = mustExec(re, cmd, []string{"-u", pdAddr, "scheduler", "config", schedulerName, "set", "recovery-duration", "100"}, nil)
re.Contains(echo, "Success! Config updated.")
conf = make(map[string]interface{})
testutil.Eventually(re, func() bool {
mustExec(re, cmd, []string{"-u", pdAddr, "scheduler", "config", schedulerName, "show"}, &conf)
return conf["recovery-duration"] == 100.
})
echo = mustExec(re, cmd, []string{"-u", pdAddr, "scheduler", "remove", schedulerName}, nil)
re.Contains(echo, "Success!")
testutil.Eventually(re, func() bool {
echo = mustExec(re, cmd, []string{"-u", pdAddr, "scheduler", "show"}, nil)
return !strings.Contains(echo, schedulerName)
})
}
echo = mustExec(re, cmd, []string{"-u", pdAddr, "scheduler", "add", "evict-slow-store-scheduler"}, nil)
>>>>>>> 8b8c78a78 (scheduler: add aduit log for scheduler config API and add resp msg for evict-leader (#7674)):tools/pd-ctl/tests/scheduler/scheduler_test.go
re.Contains(echo, "Success!")
echo = mustExec(re, cmd, []string{"-u", pdAddr, "scheduler", "show"}, nil)
re.Contains(echo, "evict-slow-trend-scheduler")
Expand Down

0 comments on commit 66eb822

Please sign in to comment.