Skip to content

Commit

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

Signed-off-by: husharp <[email protected]>

Co-authored-by: husharp <[email protected]>
  • Loading branch information
ti-chi-bot and HuSharp authored Apr 30, 2024
1 parent 5845336 commit 78f4254
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/schedule/filter/counter.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ func NewCounter(scope string) *Counter {
return &Counter{counter: counter, scope: scope}
}

// SetScope sets the scope for the counter.
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 @@ -194,6 +194,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 @@ -91,6 +91,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 78f4254

Please sign in to comment.