Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scheduler: fix scatter counter name (#8124) #8127

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions server/schedule/filter/counter.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,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 server/schedulers/balance_leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,13 @@ func WithBalanceLeaderName(name string) BalanceLeaderCreateOption {
}
}

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

func (l *balanceLeaderScheduler) GetName() string {
return l.name
}
Expand Down
7 changes: 7 additions & 0 deletions server/schedulers/balance_region.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,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 server/schedulers/scatter_range.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,14 @@ func newScatterRangeScheduler(opController *schedule.OperatorController, config
&balanceLeaderSchedulerConfig{Ranges: []core.KeyRange{core.NewKeyRange("", "")}},
WithBalanceLeaderName("scatter-range-leader"),
WithBalanceLeaderCounter(scatterRangeLeaderCounter),
WithBalanceLeaderFilterCounterName("scatter-range-leader"),
),
balanceRegion: newBalanceRegionScheduler(
opController,
&balanceRegionSchedulerConfig{Ranges: []core.KeyRange{core.NewKeyRange("", "")}},
WithBalanceRegionName("scatter-range-region"),
WithBalanceRegionCounter(scatterRangeRegionCounter),
WithBalanceRegionFilterCounterName("scatter-range-region"),
),
}
return scheduler
Expand Down
Loading