Skip to content

Commit

Permalink
scheduler: fix scatter counter name (tikv#8124)
Browse files Browse the repository at this point in the history
close tikv#8125

Signed-off-by: husharp <[email protected]>
  • Loading branch information
HuSharp authored Apr 26, 2024
1 parent de5bad3 commit 50c8040
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/schedule/filter/counter.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ func NewCounter(scope string) *Counter {
return &Counter{counter: counter, scope: scope}
}

func (c *Counter) SetScope(scope string) {
c.scope = scope
}

// Add adds the filter counter.
func (c *Counter) inc(action action, filterType filterType, sourceID uint64, targetID uint64) {
if _, ok := c.counter[action][filterType][sourceID]; !ok {
Expand Down
7 changes: 7 additions & 0 deletions pkg/schedule/schedulers/balance_leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,13 @@ func (l *balanceLeaderScheduler) ServeHTTP(w http.ResponseWriter, r *http.Reques
// BalanceLeaderCreateOption is used to create a scheduler with an option.
type BalanceLeaderCreateOption func(s *balanceLeaderScheduler)

// WithBalanceLeaderFilterCounterName sets the filter counter name for the scheduler.
func WithBalanceLeaderFilterCounterName(name string) BalanceLeaderCreateOption {
return func(s *balanceLeaderScheduler) {
s.filterCounter.SetScope(name)
}
}

// WithBalanceLeaderName sets the name for the scheduler.
func WithBalanceLeaderName(name string) BalanceLeaderCreateOption {
return func(s *balanceLeaderScheduler) {
Expand Down
7 changes: 7 additions & 0 deletions pkg/schedule/schedulers/balance_region.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ func WithBalanceRegionName(name string) BalanceRegionCreateOption {
}
}

// WithBalanceRegionFilterCounterName sets the filter counter name for the scheduler.
func WithBalanceRegionFilterCounterName(name string) BalanceRegionCreateOption {
return func(s *balanceRegionScheduler) {
s.filterCounter.SetScope(name)
}
}

func (s *balanceRegionScheduler) GetName() string {
return s.conf.Name
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/schedule/schedulers/scatter_range.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,13 @@ func newScatterRangeScheduler(opController *operator.Controller, config *scatter
opController,
&balanceLeaderSchedulerConfig{Ranges: []core.KeyRange{core.NewKeyRange("", "")}},
WithBalanceLeaderName("scatter-range-leader"),
WithBalanceLeaderFilterCounterName("scatter-range-leader"),
),
balanceRegion: newBalanceRegionScheduler(
opController,
&balanceRegionSchedulerConfig{Ranges: []core.KeyRange{core.NewKeyRange("", "")}},
WithBalanceRegionName("scatter-range-region"),
WithBalanceRegionFilterCounterName("scatter-range-region"),
),
}
return scheduler
Expand Down

0 comments on commit 50c8040

Please sign in to comment.