Skip to content

Commit

Permalink
This is an automated cherry-pick of tikv#8124
Browse files Browse the repository at this point in the history
close tikv#8125

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
  • Loading branch information
HuSharp authored and ti-chi-bot committed Apr 26, 2024
1 parent c325311 commit 1937a9e
Show file tree
Hide file tree
Showing 4 changed files with 26 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 @@ -198,10 +198,17 @@ 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)

<<<<<<< HEAD
// WithBalanceLeaderCounter sets the counter for the scheduler.
func WithBalanceLeaderCounter(counter *prometheus.CounterVec) BalanceLeaderCreateOption {
return func(s *balanceLeaderScheduler) {
s.counter = counter
=======
// WithBalanceLeaderFilterCounterName sets the filter counter name for the scheduler.
func WithBalanceLeaderFilterCounterName(name string) BalanceLeaderCreateOption {
return func(s *balanceLeaderScheduler) {
s.filterCounter.SetScope(name)
>>>>>>> 50c80407c (scheduler: fix scatter counter name (#8124))
}
}

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 @@ -103,6 +103,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
8 changes: 8 additions & 0 deletions pkg/schedule/schedulers/scatter_range.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,21 @@ func newScatterRangeScheduler(opController *schedule.OperatorController, config
opController,
&balanceLeaderSchedulerConfig{Ranges: []core.KeyRange{core.NewKeyRange("", "")}},
WithBalanceLeaderName("scatter-range-leader"),
<<<<<<< HEAD
WithBalanceLeaderCounter(scatterRangeLeaderCounter),
=======
WithBalanceLeaderFilterCounterName("scatter-range-leader"),
>>>>>>> 50c80407c (scheduler: fix scatter counter name (#8124))
),
balanceRegion: newBalanceRegionScheduler(
opController,
&balanceRegionSchedulerConfig{Ranges: []core.KeyRange{core.NewKeyRange("", "")}},
WithBalanceRegionName("scatter-range-region"),
<<<<<<< HEAD
WithBalanceRegionCounter(scatterRangeRegionCounter),
=======
WithBalanceRegionFilterCounterName("scatter-range-region"),
>>>>>>> 50c80407c (scheduler: fix scatter counter name (#8124))
),
}
return scheduler
Expand Down

0 comments on commit 1937a9e

Please sign in to comment.