diff --git a/server/api/admin.go b/server/api/admin.go index 246c9239f59..cd050102037 100644 --- a/server/api/admin.go +++ b/server/api/admin.go @@ -61,7 +61,7 @@ func (h *adminHandler) DeleteRegionCache(w http.ResponseWriter, r *http.Request) return } rc.DropCacheRegion(regionID) - if h.svr.IsAPIServiceMode() { + if h.svr.IsServiceIndependent(utils.SchedulingServiceName) { err = h.DeleteRegionCacheInSchedulingServer(regionID) } msg := "The region is removed from server cache." @@ -101,7 +101,7 @@ func (h *adminHandler) DeleteRegionStorage(w http.ResponseWriter, r *http.Reques } // Remove region from cache. rc.DropCacheRegion(regionID) - if h.svr.IsAPIServiceMode() { + if h.svr.IsServiceIndependent(utils.SchedulingServiceName) { err = h.DeleteRegionCacheInSchedulingServer(regionID) } msg := "The region is removed from server cache and region meta storage." @@ -117,7 +117,7 @@ func (h *adminHandler) DeleteAllRegionCache(w http.ResponseWriter, r *http.Reque var err error rc := getCluster(r) rc.DropCacheAllRegion() - if h.svr.IsAPIServiceMode() { + if h.svr.IsServiceIndependent(utils.SchedulingServiceName) { err = h.DeleteRegionCacheInSchedulingServer() } msg := "All regions are removed from server cache." @@ -241,7 +241,7 @@ func (h *adminHandler) DeleteRegionCacheInSchedulingServer(id ...uint64) error { } func (h *adminHandler) buildMsg(msg string, err error) string { - if h.svr.IsAPIServiceMode() && err != nil { + if h.svr.IsServiceIndependent(utils.SchedulingServiceName) && err != nil { return fmt.Sprintf("This operation was executed in API server but needs to be re-executed on scheduling server due to the following error: %s", err.Error()) } return msg diff --git a/server/api/config.go b/server/api/config.go index 746b1119a73..428cebdb1d8 100644 --- a/server/api/config.go +++ b/server/api/config.go @@ -62,7 +62,7 @@ func newConfHandler(svr *server.Server, rd *render.Render) *confHandler { // @Router /config [get] func (h *confHandler) GetConfig(w http.ResponseWriter, r *http.Request) { cfg := h.svr.GetConfig() - if h.svr.IsAPIServiceMode() { + if h.svr.IsServiceIndependent(utils.SchedulingServiceName) { schedulingServerConfig, err := h.GetSchedulingServerConfig() if err != nil { h.rd.JSON(w, http.StatusInternalServerError, err.Error()) @@ -313,7 +313,7 @@ func getConfigMap(cfg map[string]interface{}, key []string, value interface{}) m // @Success 200 {object} sc.ScheduleConfig // @Router /config/schedule [get] func (h *confHandler) GetScheduleConfig(w http.ResponseWriter, r *http.Request) { - if h.svr.IsAPIServiceMode() { + if h.svr.IsServiceIndependent(utils.SchedulingServiceName) { cfg, err := h.GetSchedulingServerConfig() if err != nil { h.rd.JSON(w, http.StatusInternalServerError, err.Error()) @@ -386,7 +386,7 @@ func (h *confHandler) SetScheduleConfig(w http.ResponseWriter, r *http.Request) // @Success 200 {object} sc.ReplicationConfig // @Router /config/replicate [get] func (h *confHandler) GetReplicationConfig(w http.ResponseWriter, r *http.Request) { - if h.svr.IsAPIServiceMode() { + if h.svr.IsServiceIndependent(utils.SchedulingServiceName) { cfg, err := h.GetSchedulingServerConfig() if err != nil { h.rd.JSON(w, http.StatusInternalServerError, err.Error())