@@ -31,7 +31,7 @@ type LoadGen interface {
31
31
// Generate returns a workload generator that is parameterized randomly by
32
32
// the seed and simulation settings provided.
33
33
Generate (seed int64 , settings * config.SimulationSettings ) []workload.Generator
34
- String ( ) string
34
+ StringWithTag ( tag string ) string
35
35
}
36
36
37
37
// ClusterGen provides a method to generate the initial cluster state, given a
@@ -51,7 +51,7 @@ type RangeGen interface {
51
51
// Generate returns an updated state, given the initial state, seed and
52
52
// simulation settings provided. In the updated state, ranges will have been
53
53
// created, replicas and leases assigned to stores in the cluster.
54
- Generate (seed int64 , settings * config.SimulationSettings , s state.State ) (state.State , string )
54
+ Generate (tag string , seed int64 , settings * config.SimulationSettings , s state.State ) (state.State , string )
55
55
String () string
56
56
}
57
57
@@ -66,10 +66,11 @@ func GenerateSimulation(
66
66
eventGen EventGen ,
67
67
seed int64 ,
68
68
buf * strings.Builder ,
69
+ tag string ,
69
70
) * asim.Simulator {
70
71
settings := settingsGen .Generate (seed )
71
72
s := clusterGen .Generate (seed , & settings )
72
- s , rangeStateStr := rangeGen .Generate (seed , & settings , s )
73
+ s , rangeStateStr := rangeGen .Generate (tag , seed , & settings , s )
73
74
eventExecutor := eventGen .Generate (seed , & settings )
74
75
generateClusterVisualization (buf , s , loadGen , eventGen , rangeStateStr , settings )
75
76
return asim .NewSimulator (
@@ -102,10 +103,10 @@ type MultiLoad []BasicLoad
102
103
// BasicLoad.
103
104
var _ LoadGen = MultiLoad {}
104
105
105
- func (ml MultiLoad ) String ( ) string {
106
+ func (ml MultiLoad ) StringWithTag ( tag string ) string {
106
107
var buf strings.Builder
107
108
for i , load := range ml {
108
- _ , _ = fmt .Fprintf (& buf , "%s" , load .String ( ))
109
+ _ , _ = fmt .Fprintf (& buf , "%s" , load .StringWithTag ( tag ))
109
110
if i != len (ml )- 1 {
110
111
_ , _ = fmt .Fprintf (& buf , "\n " )
111
112
}
@@ -135,9 +136,9 @@ type BasicLoad struct {
135
136
136
137
var _ LoadGen = BasicLoad {}
137
138
138
- func (bl BasicLoad ) String ( ) string {
139
+ func (bl BasicLoad ) StringWithTag ( tag string ) string {
139
140
var buf strings.Builder
140
- fmt .Fprintf (& buf , "\t [%d,%d): " , bl .MinKey , bl .MaxKey )
141
+ fmt .Fprintf (& buf , "%s [%d,%d): " , tag , bl .MinKey , bl .MaxKey )
141
142
if bl .RWRatio == 1 {
142
143
_ , _ = fmt .Fprint (& buf , "read-only" )
143
144
} else if bl .RWRatio == 0 {
@@ -214,7 +215,7 @@ func (lc LoadedCluster) Generate(seed int64, settings *config.SimulationSettings
214
215
}
215
216
216
217
func (lc LoadedCluster ) String () string {
217
- return fmt .Sprintf ("cluster: %s" , lc .Info .String ())
218
+ return fmt .Sprintf ("cluster: \n %s" , lc .Info .String ())
218
219
}
219
220
220
221
func (lc LoadedCluster ) Regions () []state.Region {
@@ -356,6 +357,11 @@ type BaseRanges struct {
356
357
ReplicaPlacement state.ReplicaPlacement
357
358
}
358
359
360
+ func (br BaseRanges ) String () string {
361
+ return fmt .Sprintf ("[%d,%d): %d(rf=%d), %dMiB" ,
362
+ br .MinKey , br .MaxKey , br .Ranges , br .ReplicationFactor , br .Bytes >> 20 )
363
+ }
364
+
359
365
// GetRangesInfo generates and distributes ranges across stores based on
360
366
// PlacementType while using other BaseRanges fields for range configuration.
361
367
func (b BaseRanges ) GetRangesInfo (
@@ -404,15 +410,15 @@ func (br BasicRanges) String() string {
404
410
// ranges generated based on the parameters specified in the fields of
405
411
// BasicRanges.
406
412
func (br BasicRanges ) Generate (
407
- seed int64 , settings * config.SimulationSettings , s state.State ,
413
+ tag string , seed int64 , settings * config.SimulationSettings , s state.State ,
408
414
) (state.State , string ) {
409
415
if br .PlacementType == Random || br .PlacementType == WeightedRandom {
410
416
panic ("BasicRanges generate only uniform or skewed distributions" )
411
417
}
412
418
rangesInfo , str := br .GetRangesInfo (br .PlacementType , len (s .Stores ()), nil , []float64 {})
413
419
br .LoadRangeInfo (s , rangesInfo )
414
420
var buf strings.Builder
415
- _ , _ = fmt .Fprintf (& buf , "\t %s , %s" , br , str )
421
+ _ , _ = fmt .Fprintf (& buf , "%s%s , %s" , tag , br , str )
416
422
return s , buf .String ()
417
423
}
418
424
@@ -434,14 +440,14 @@ func (mr MultiRanges) String() string {
434
440
}
435
441
436
442
func (mr MultiRanges ) Generate (
437
- seed int64 , settings * config.SimulationSettings , s state.State ,
443
+ tag string , seed int64 , settings * config.SimulationSettings , s state.State ,
438
444
) (state.State , string ) {
439
445
var rangeInfos []state.RangeInfo
440
446
var rangeInfoStrings []string
441
447
for _ , ranges := range mr {
442
448
rangeInfo , rangeInfoStr := ranges .GetRangesInfo (ranges .PlacementType , len (s .Stores ()), nil , []float64 {})
443
449
rangeInfos = append (rangeInfos , rangeInfo ... )
444
- rangeInfoStrings = append (rangeInfoStrings , fmt .Sprintf ("\t %s , %s" , ranges .String (), rangeInfoStr ))
450
+ rangeInfoStrings = append (rangeInfoStrings , fmt .Sprintf ("%s%s , %s" , tag , ranges .String (), rangeInfoStr ))
445
451
}
446
452
state .LoadRangeInfo (s , rangeInfos ... )
447
453
var buf strings.Builder
0 commit comments