@@ -342,10 +342,6 @@ type ScatterScorerOptions struct {
342
342
343
343
var _ ScorerOptions = & ScatterScorerOptions {}
344
344
345
- func (o * ScatterScorerOptions ) getIOOverloadOptions () IOOverloadOptions {
346
- return o .RangeCountScorerOptions .IOOverloadOptions
347
- }
348
-
349
345
func (o * ScatterScorerOptions ) maybeJitterStoreStats (
350
346
sl storepool.StoreList , allocRand allocatorRand ,
351
347
) (perturbedSL storepool.StoreList ) {
@@ -360,37 +356,46 @@ func (o *ScatterScorerOptions) maybeJitterStoreStats(
360
356
return storepool .MakeStoreList (perturbedStoreDescs )
361
357
}
362
358
363
- // RangeCountScorerOptions is used by the replicateQueue to tell the Allocator's
364
- // rebalancing machinery to base its balance/convergence scores on range counts.
365
- // This means that the resulting rebalancing decisions will further the goal of
366
- // converging range counts across stores in the cluster.
367
- type RangeCountScorerOptions struct {
368
- IOOverloadOptions
369
- DiskCapacityOptions
370
- deterministic bool
371
- rangeRebalanceThreshold float64
359
+ // BaseScorerOptions is the base scorer options that is embedded in
360
+ // every scorer option.
361
+ type BaseScorerOptions struct {
362
+ IOOverload IOOverloadOptions
363
+ DiskCapacity DiskCapacityOptions
364
+ Deterministic bool
372
365
}
373
366
374
- var _ ScorerOptions = & RangeCountScorerOptions {}
367
+ func (bo BaseScorerOptions ) getIOOverloadOptions () IOOverloadOptions {
368
+ return bo .IOOverload
369
+ }
375
370
376
- func (o * RangeCountScorerOptions ) getIOOverloadOptions () IOOverloadOptions {
377
- return o . IOOverloadOptions
371
+ func (bo BaseScorerOptions ) getDiskOptions () DiskCapacityOptions {
372
+ return bo . DiskCapacity
378
373
}
379
374
380
- func (o * RangeCountScorerOptions ) getDiskOptions () DiskCapacityOptions {
381
- return o . DiskCapacityOptions
375
+ func (bo BaseScorerOptions ) deterministicForTesting () bool {
376
+ return bo . Deterministic
382
377
}
383
378
384
- func (o * RangeCountScorerOptions ) maybeJitterStoreStats (
379
+ // maybeJitterStoreStats returns the provided store list since that is the
380
+ // default behavior. ScatterScorerOptions is the only scorer option that jitters
381
+ // store stats to rebalance replicas across stores randomly.
382
+ func (bo BaseScorerOptions ) maybeJitterStoreStats (
385
383
sl storepool.StoreList , _ allocatorRand ,
386
- ) ( perturbedSL storepool.StoreList ) {
384
+ ) storepool.StoreList {
387
385
return sl
388
386
}
389
387
390
- func (o * RangeCountScorerOptions ) deterministicForTesting () bool {
391
- return o .deterministic
388
+ // RangeCountScorerOptions is used by the replicateQueue to tell the Allocator's
389
+ // rebalancing machinery to base its balance/convergence scores on range counts.
390
+ // This means that the resulting rebalancing decisions will further the goal of
391
+ // converging range counts across stores in the cluster.
392
+ type RangeCountScorerOptions struct {
393
+ BaseScorerOptions
394
+ rangeRebalanceThreshold float64
392
395
}
393
396
397
+ var _ ScorerOptions = & RangeCountScorerOptions {}
398
+
394
399
func (o RangeCountScorerOptions ) shouldRebalanceBasedOnThresholds (
395
400
ctx context.Context , eqClass equivalenceClass , metrics AllocatorMetrics ,
396
401
) bool {
@@ -491,10 +496,8 @@ func (o *RangeCountScorerOptions) removalMaximallyConvergesScore(
491
496
// queries-per-second. This means that the resulting rebalancing decisions will
492
497
// further the goal of converging QPS across stores in the cluster.
493
498
type LoadScorerOptions struct {
494
- IOOverloadOptions IOOverloadOptions
495
- DiskOptions DiskCapacityOptions
496
- Deterministic bool
497
- LoadDims []load.Dimension
499
+ BaseScorerOptions
500
+ LoadDims []load.Dimension
498
501
499
502
// LoadThreshold and MinLoadThreshold track the threshold beyond which a
500
503
// store should be considered under/overfull and the minimum absolute
@@ -528,23 +531,7 @@ type LoadScorerOptions struct {
528
531
RebalanceImpact load.Load
529
532
}
530
533
531
- func (o * LoadScorerOptions ) getIOOverloadOptions () IOOverloadOptions {
532
- return o .IOOverloadOptions
533
- }
534
-
535
- func (o * LoadScorerOptions ) getDiskOptions () DiskCapacityOptions {
536
- return o .DiskOptions
537
- }
538
-
539
- func (o * LoadScorerOptions ) maybeJitterStoreStats (
540
- sl storepool.StoreList , _ allocatorRand ,
541
- ) storepool.StoreList {
542
- return sl
543
- }
544
-
545
- func (o * LoadScorerOptions ) deterministicForTesting () bool {
546
- return o .Deterministic
547
- }
534
+ var _ ScorerOptions = & LoadScorerOptions {}
548
535
549
536
// shouldRebalanceBasedOnThresholds tries to determine if, within the given
550
537
// equivalenceClass `eqClass`, rebalancing a replica from one of the existing
0 commit comments