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 efb03ec commit 034b35b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions server/schedule/filter/counter.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,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 server/schedulers/balance_leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,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:server/schedulers/balance_leader.go

Check failure on line 220 in server/schedulers/balance_leader.go

View workflow job for this annotation

GitHub Actions / statics

syntax error: non-declaration statement outside function body
// WithBalanceLeaderCounter sets the counter for the scheduler.
func WithBalanceLeaderCounter(counter *prometheus.CounterVec) BalanceLeaderCreateOption {
return func(s *balanceLeaderScheduler) {
s.counter = counter
=======

Check failure on line 225 in server/schedulers/balance_leader.go

View workflow job for this annotation

GitHub Actions / statics

syntax error: unexpected ==, expecting }
// WithBalanceLeaderFilterCounterName sets the filter counter name for the scheduler.
func WithBalanceLeaderFilterCounterName(name string) BalanceLeaderCreateOption {

Check failure on line 227 in server/schedulers/balance_leader.go

View workflow job for this annotation

GitHub Actions / statics

syntax error: unexpected ) at end of statement
return func(s *balanceLeaderScheduler) {
s.filterCounter.SetScope(name)
>>>>>>> 50c80407c (scheduler: fix scatter counter name (#8124)):pkg/schedule/schedulers/balance_leader.go

Check failure on line 230 in server/schedulers/balance_leader.go

View workflow job for this annotation

GitHub Actions / statics

syntax error: unexpected >>, expecting }

Check failure on line 230 in server/schedulers/balance_leader.go

View workflow job for this annotation

GitHub Actions / statics

invalid character U+0023 '#'
}

Check failure on line 231 in server/schedulers/balance_leader.go

View workflow job for this annotation

GitHub Actions / statics

syntax error: unexpected }, expecting expression

Check failure on line 231 in server/schedulers/balance_leader.go

View workflow job for this annotation

GitHub Actions / statics

expression in go must be function call
}

Check failure on line 232 in server/schedulers/balance_leader.go

View workflow job for this annotation

GitHub Actions / statics

syntax error: non-declaration statement outside function body

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
8 changes: 8 additions & 0 deletions server/schedulers/scatter_range.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,21 @@ func newScatterRangeScheduler(opController *schedule.OperatorController, config
opController,
&balanceLeaderSchedulerConfig{Ranges: []core.KeyRange{core.NewKeyRange("", "")}},
WithBalanceLeaderName("scatter-range-leader"),
<<<<<<< HEAD:server/schedulers/scatter_range.go

Check failure on line 167 in server/schedulers/scatter_range.go

View workflow job for this annotation

GitHub Actions / statics

syntax error: unexpected <<, expecting expression
WithBalanceLeaderCounter(scatterRangeLeaderCounter),

Check failure on line 168 in server/schedulers/scatter_range.go

View workflow job for this annotation

GitHub Actions / statics

syntax error: unexpected comma at end of statement
=======
WithBalanceLeaderFilterCounterName("scatter-range-leader"),
>>>>>>> 50c80407c (scheduler: fix scatter counter name (#8124)):pkg/schedule/schedulers/scatter_range.go
),
balanceRegion: newBalanceRegionScheduler(
opController,
&balanceRegionSchedulerConfig{Ranges: []core.KeyRange{core.NewKeyRange("", "")}},
WithBalanceRegionName("scatter-range-region"),
<<<<<<< HEAD:server/schedulers/scatter_range.go
WithBalanceRegionCounter(scatterRangeRegionCounter),
=======
WithBalanceRegionFilterCounterName("scatter-range-region"),
>>>>>>> 50c80407c (scheduler: fix scatter counter name (#8124)):pkg/schedule/schedulers/scatter_range.go
),
}
return scheduler
Expand Down

0 comments on commit 034b35b

Please sign in to comment.