@@ -10,7 +10,6 @@ import (
10
10
"math/rand"
11
11
"sort"
12
12
13
- "github.com/cockroachdb/cockroach/pkg/kv/kvserver/asim/config"
14
13
"github.com/cockroachdb/cockroach/pkg/roachpb"
15
14
)
16
15
@@ -372,106 +371,3 @@ func RangesInfoRandDistribution(
372
371
storeList , distribution , distribution , ranges , spanConfig ,
373
372
int64 (MinKey ), int64 (keyspace ), rangeSize )
374
373
}
375
-
376
- // NewStateWithDistribution returns a State where the stores given are
377
- // initialized with the specified % of the replicas. This is done on a best
378
- // effort basis, given the replication factor. It may be impossible to satisfy
379
- // some distributions, for example: percentOfReplicas {1: 0.40, 2: 0.20, 3:
380
- // 0.20}, replicationFactor 3, would be impossible to satisfy as the only
381
- // distribution possible is {1: 0.33, 2: 0.33, 3: 0.33} given a replication
382
- // factor of 3. A best effort distribution is applied in these cases.
383
- func NewStateWithDistribution (
384
- percentOfReplicas []float64 ,
385
- ranges , replicationFactor , keyspace int ,
386
- settings * config.SimulationSettings ,
387
- ) State {
388
- numNodes := len (percentOfReplicas )
389
- // Currently multi-store is not tested for correctness. Default to a single
390
- // store per node.
391
- clusterInfo := ClusterInfoWithStoreCount (numNodes , 1 /* storesPerNode */ )
392
- s := LoadClusterInfo (clusterInfo , settings )
393
-
394
- stores := make ([]StoreID , numNodes )
395
- for i , store := range s .Stores () {
396
- stores [i ] = store .StoreID ()
397
- }
398
- spanConfig := defaultSpanConfig
399
- spanConfig .NumReplicas = int32 (replicationFactor )
400
- spanConfig .NumVoters = int32 (replicationFactor )
401
-
402
- rangesInfo := RangesInfoWithDistribution (
403
- stores ,
404
- percentOfReplicas ,
405
- percentOfReplicas ,
406
- ranges ,
407
- spanConfig ,
408
- int64 (MinKey ),
409
- int64 (keyspace ),
410
- 0 , /* rangeSize */
411
- )
412
- LoadRangeInfo (s , rangesInfo ... )
413
- return s
414
- }
415
-
416
- // NewStateWithReplCounts returns a new test state where each store is
417
- // initialized the given number of replicas. The required number of ranges is
418
- // inferred from the replication factor and the replica count.
419
- func NewStateWithReplCounts (
420
- replCounts map [StoreID ]int , replicationFactor , keyspace int , settings * config.SimulationSettings ,
421
- ) State {
422
- clusterInfo := ClusterInfoWithStoreCount (len (replCounts ), 1 /* storesPerNode */ )
423
- rangesInfo := RangesInfoWithReplicaCounts (replCounts , keyspace , replicationFactor , 0 /* rangeSize */ )
424
- return LoadConfig (clusterInfo , rangesInfo , settings )
425
- }
426
-
427
- // NewStateEvenDistribution returns a new State where the replica count per
428
- // store is equal.
429
- func NewStateEvenDistribution (
430
- stores , ranges , replicationFactor , keyspace int , settings * config.SimulationSettings ,
431
- ) State {
432
- clusterInfo := ClusterInfoWithStoreCount (stores , 1 /* storesPerNode*/ )
433
- rangesInfo := RangesInfoEvenDistribution (stores , ranges , int64 (MinKey ), int64 (keyspace ), replicationFactor , 0 /* rangeSize */ )
434
- return LoadConfig (clusterInfo , rangesInfo , settings )
435
- }
436
-
437
- // NewStateSkewedDistribution returns a new State where the replica count per
438
- // store is skewed.
439
- func NewStateSkewedDistribution (
440
- stores , ranges , replicationFactor , keyspace int , settings * config.SimulationSettings ,
441
- ) State {
442
- clusterInfo := ClusterInfoWithStoreCount (stores , 1 /* storesPerNode */ )
443
- rangesInfo := RangesInfoSkewedDistribution (stores , ranges , int64 (MinKey ), int64 (keyspace ), replicationFactor , 0 /* rangeSize */ )
444
- return LoadConfig (clusterInfo , rangesInfo , settings )
445
- }
446
-
447
- // NewStateRandDistribution returns a new State where the replica count per
448
- // store is randomized.
449
- func NewStateRandDistribution (
450
- seed int64 ,
451
- stores int ,
452
- ranges int ,
453
- keyspace int ,
454
- replicationFactor int ,
455
- settings * config.SimulationSettings ,
456
- ) State {
457
- randSource := rand .New (rand .NewSource (seed ))
458
- clusterInfo := ClusterInfoWithStoreCount (stores , 1 /* storesPerNode */ )
459
- rangesInfo := RangesInfoRandDistribution (randSource , stores , ranges , keyspace , replicationFactor , 0 /* rangeSize */ )
460
- return LoadConfig (clusterInfo , rangesInfo , settings )
461
- }
462
-
463
- // NewStateWeightedRandDistribution returns a new State where the replica count
464
- // per store is weighted randomized based on weightedStores.
465
- func NewStateWeightedRandDistribution (
466
- seed int64 ,
467
- weightedStores []float64 ,
468
- ranges int ,
469
- keyspace int ,
470
- replicationFactor int ,
471
- settings * config.SimulationSettings ,
472
- ) State {
473
- randSource := rand .New (rand .NewSource (seed ))
474
- clusterInfo := ClusterInfoWithStoreCount (len (weightedStores ), 1 /* storesPerNode */ )
475
- rangesInfo := RangesInfoWeightedRandDistribution (randSource , weightedStores , ranges , keyspace , replicationFactor , 0 /* rangeSize */ )
476
- return LoadConfig (clusterInfo , rangesInfo , settings )
477
- }
0 commit comments