Skip to content

Commit

Permalink
move and fix test
Browse files Browse the repository at this point in the history
Signed-off-by: lhy1024 <[email protected]>
  • Loading branch information
lhy1024 committed Nov 1, 2023
1 parent 08927e5 commit bd12406
Show file tree
Hide file tree
Showing 10 changed files with 673 additions and 558 deletions.
13 changes: 7 additions & 6 deletions pkg/mcs/scheduling/server/apis/v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ func changeLogLevel(c *gin.Context) {
c.String(http.StatusOK, "The log level is updated.")
}

<<<<<<< HEAD
// @Tags config
// @Summary Get full config.
// @Produce json
Expand All @@ -205,24 +204,26 @@ func changeLogLevel(c *gin.Context) {
func getConfig(c *gin.Context) {
svr := c.MustGet(multiservicesapi.ServiceContextKey).(*scheserver.Server)
cfg := svr.GetConfig()
cfg.Schedule.MaxMergeRegionKeys = cfg.Schedule.GetMaxMergeRegionKeys()
c.IndentedJSON(http.StatusOK, cfg)
}

// @Tags config
// @Summary Get schedule config.
// @Produce json
// @Success 200 {object} sc.ScheduleConfig
// @Success 200 {object} config.ScheduleConfig
// @Router /config/schedule [get]
func getScheduleConfig(c *gin.Context) {
svr := c.MustGet(multiservicesapi.ServiceContextKey).(*scheserver.Server)
cfg := svr.GetScheduleConfig()
cfg.MaxMergeRegionKeys = cfg.GetMaxMergeRegionKeys()
c.IndentedJSON(http.StatusOK, cfg)
}

// @Tags config
// @Summary Get replication config.
// @Produce json
// @Success 200 {object} sc.ReplicationConfig
// @Success 200 {object} config.ReplicationConfig
// @Router /config/replicate [get]
func getReplicationConfig(c *gin.Context) {
svr := c.MustGet(multiservicesapi.ServiceContextKey).(*scheserver.Server)
Expand All @@ -233,13 +234,14 @@ func getReplicationConfig(c *gin.Context) {
// @Tags config
// @Summary Get store config.
// @Produce json
// @Success 200 {object} sc.StoreConfig
// @Success 200 {object} config.StoreConfig
// @Router /config/store [get]
func getStoreConfig(c *gin.Context) {
svr := c.MustGet(multiservicesapi.ServiceContextKey).(*scheserver.Server)
cfg := svr.GetStoreConfig()
c.IndentedJSON(http.StatusOK, cfg)
=======
}

// @Tags admin
// @Summary Drop all regions from cache.
// @Produce json
Expand Down Expand Up @@ -278,7 +280,6 @@ func deleteRegionCacheByID(c *gin.Context) {
}
cluster.DropCacheRegion(regionID)
c.String(http.StatusOK, "The region is removed from server cache.")
>>>>>>> a1a1eea8dafd7918d583378790a4bb6c39a21f97
}

// @Tags operators
Expand Down
8 changes: 8 additions & 0 deletions pkg/mcs/scheduling/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,14 @@ func (s *Server) GetConfig() *config.Config {
cfg.Schedule = *s.persistConfig.GetScheduleConfig().Clone()
cfg.Replication = *s.persistConfig.GetReplicationConfig().Clone()
cfg.ClusterVersion = *s.persistConfig.GetClusterVersion()
if s.storage == nil {
return cfg
}
sches, configs, err := s.storage.LoadAllSchedulerConfigs()
if err != nil {
return cfg
}
cfg.Schedule.SchedulersPayload = schedulers.ToPayload(sches, configs)
return cfg
}

Expand Down
22 changes: 5 additions & 17 deletions server/api/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,32 +63,20 @@ func newConfHandler(svr *server.Server, rd *render.Render) *confHandler {
func (h *confHandler) GetConfig(w http.ResponseWriter, r *http.Request) {
cfg := h.svr.GetConfig()
if h.svr.IsAPIServiceMode() {
b, err := h.GetSchedulingServerConfig("config/schedule")
if err != nil {
h.rd.JSON(w, http.StatusInternalServerError, err.Error())
return
}
var scheduleCfg sc.ScheduleConfig
err = json.Unmarshal(b, &scheduleCfg)
if err != nil {
h.rd.JSON(w, http.StatusInternalServerError, err.Error())
return
}
cfg.Schedule = scheduleCfg
b, err = h.GetSchedulingServerConfig("config/replicate")
b, err := h.GetSchedulingServerConfig("config")
if err != nil {
h.rd.JSON(w, http.StatusInternalServerError, err.Error())
return
}
var replicationCfg sc.ReplicationConfig
err = json.Unmarshal(b, &replicationCfg)
var configSchedulingServer config.Config
err = json.Unmarshal(b, &configSchedulingServer)
if err != nil {
h.rd.JSON(w, http.StatusInternalServerError, err.Error())
return
}
cfg.Replication = replicationCfg
cfg.Schedule = configSchedulingServer.Schedule
cfg.Replication = configSchedulingServer.Replication
// TODO: will we support config/store?
// TODO: after scheduler-config is supported, we need to merge the config.
} else {
cfg.Schedule.MaxMergeRegionKeys = cfg.Schedule.GetMaxMergeRegionKeys()
}
Expand Down
Loading

0 comments on commit bd12406

Please sign in to comment.