Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
Signed-off-by: lhy1024 <[email protected]>
  • Loading branch information
lhy1024 committed Oct 9, 2023
1 parent 62fb5d1 commit 4606779
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 23 deletions.
9 changes: 6 additions & 3 deletions pkg/mcs/scheduling/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import (
"github.com/tikv/pd/pkg/mcs/utils"
"github.com/tikv/pd/pkg/member"
"github.com/tikv/pd/pkg/schedule"
sc "github.com/tikv/pd/pkg/schedule/config"
sche "github.com/tikv/pd/pkg/schedule/core"
"github.com/tikv/pd/pkg/schedule/handler"
"github.com/tikv/pd/pkg/schedule/hbstream"
Expand Down Expand Up @@ -396,6 +397,11 @@ func (s *Server) GetEncryptionKeyManager() *encryption.Manager {
return s.encryptionKeyManager
}

// GetSharedConfig returns the shared config.
func (s *Server) GetSharedConfig() sc.SharedConfigProvider {
return s.persistConfig
}

// ServerLoopWgDone decreases the server loop wait group.
func (s *Server) ServerLoopWgDone() {
s.serverLoopWg.Done()
Expand Down Expand Up @@ -468,9 +474,6 @@ func (s *Server) startServer() (err error) {
if err != nil {
return err
}
s.cluster.GetSchedulerConfig().GetHotRegionsWriteInterval()
s.cluster.GetSchedulerConfig().GetHotRegionsReservedDays()
s.participant.IsLeader()

h := handler.NewHandler(&svr{s})
s.hotRegionStorage, err = storage.NewHotRegionsStorage(
Expand Down
24 changes: 4 additions & 20 deletions pkg/schedule/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/tikv/pd/pkg/encryption"
"github.com/tikv/pd/pkg/errs"
"github.com/tikv/pd/pkg/schedule"
sc "github.com/tikv/pd/pkg/schedule/config"
sche "github.com/tikv/pd/pkg/schedule/core"
"github.com/tikv/pd/pkg/schedule/filter"
"github.com/tikv/pd/pkg/schedule/operator"
Expand All @@ -49,6 +50,7 @@ type Server interface {
GetCoordinator() *schedule.Coordinator
GetCluster() sche.SharedCluster
GetEncryptionKeyManager() *encryption.Manager
GetSharedConfig() sc.SharedConfigProvider
}

// Handler is a handler to handle http request about schedule.
Expand Down Expand Up @@ -904,30 +906,12 @@ func (h *Handler) PauseOrResumeChecker(name string, t int64) (err error) {

// GetHotRegionsWriteInterval gets interval for PD to store Hot Region information..
func (h *Handler) GetHotRegionsWriteInterval() time.Duration {
defaultHotRegionsWriteInterval := 10 * time.Minute
c := h.GetCluster()
if c == nil {
return defaultHotRegionsWriteInterval
}
cfg := h.GetCluster().GetSharedConfig()
if cfg == nil {
return defaultHotRegionsWriteInterval
}
return cfg.GetHotRegionsWriteInterval()
return h.GetSharedConfig().GetHotRegionsWriteInterval()
}

// GetHotRegionsReservedDays gets days hot region information is kept.
func (h *Handler) GetHotRegionsReservedDays() uint64 {
defaultHotRegionsReservedDays := uint64(7)
c := h.GetCluster()
if c == nil {
return defaultHotRegionsReservedDays
}
cfg := h.GetCluster().GetSharedConfig()
if cfg == nil {
return defaultHotRegionsReservedDays
}
return cfg.GetHotRegionsReservedDays()
return h.GetSharedConfig().GetHotRegionsReservedDays()
}

// GetHotRegions gets hot regions' statistics by RWType and storeIDs.
Expand Down
5 changes: 5 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2095,6 +2095,11 @@ func (s *Server) GetEncryptionKeyManager() *encryption.Manager {
return s.encryptionKeyManager
}

// GetSharedConfig returns the shared config.
func (s *Server) GetSharedConfig() sc.SharedConfigProvider {
return s.persistOptions
}

// SetClient sets the etcd client.
// Notes: it is only used for test.
func (s *Server) SetClient(client *clientv3.Client) {
Expand Down

0 comments on commit 4606779

Please sign in to comment.