Skip to content

Commit

Permalink
fix conflict
Browse files Browse the repository at this point in the history
Signed-off-by: husharp <jinhao.hu@pingcap.com>
  • Loading branch information
HuSharp committed Apr 26, 2024
1 parent efb03ec commit 05a87b2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
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

0 comments on commit 05a87b2

Please sign in to comment.