@@ -31,7 +31,7 @@ type LoadGen interface {
3131 // Generate returns a workload generator that is parameterized randomly by
3232 // the seed and simulation settings provided.
3333 Generate (seed int64 , settings * config.SimulationSettings ) []workload.Generator
34- String ( ) string
34+ StringWithTag ( tag string ) string
3535}
3636
3737// ClusterGen provides a method to generate the initial cluster state, given a
@@ -51,7 +51,7 @@ type RangeGen interface {
5151 // Generate returns an updated state, given the initial state, seed and
5252 // simulation settings provided. In the updated state, ranges will have been
5353 // 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 )
5555 String () string
5656}
5757
@@ -66,10 +66,11 @@ func GenerateSimulation(
6666 eventGen EventGen ,
6767 seed int64 ,
6868 buf * strings.Builder ,
69+ tag string ,
6970) * asim.Simulator {
7071 settings := settingsGen .Generate (seed )
7172 s := clusterGen .Generate (seed , & settings )
72- s , rangeStateStr := rangeGen .Generate (seed , & settings , s )
73+ s , rangeStateStr := rangeGen .Generate (tag , seed , & settings , s )
7374 eventExecutor := eventGen .Generate (seed , & settings )
7475 generateClusterVisualization (buf , s , loadGen , eventGen , rangeStateStr , settings )
7576 return asim .NewSimulator (
@@ -102,10 +103,10 @@ type MultiLoad []BasicLoad
102103// BasicLoad.
103104var _ LoadGen = MultiLoad {}
104105
105- func (ml MultiLoad ) String ( ) string {
106+ func (ml MultiLoad ) StringWithTag ( tag string ) string {
106107 var buf strings.Builder
107108 for i , load := range ml {
108- _ , _ = fmt .Fprintf (& buf , "%s" , load .String ( ))
109+ _ , _ = fmt .Fprintf (& buf , "%s" , load .StringWithTag ( tag ))
109110 if i != len (ml )- 1 {
110111 _ , _ = fmt .Fprintf (& buf , "\n " )
111112 }
@@ -135,9 +136,9 @@ type BasicLoad struct {
135136
136137var _ LoadGen = BasicLoad {}
137138
138- func (bl BasicLoad ) String ( ) string {
139+ func (bl BasicLoad ) StringWithTag ( tag string ) string {
139140 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 )
141142 if bl .RWRatio == 1 {
142143 _ , _ = fmt .Fprint (& buf , "read-only" )
143144 } else if bl .RWRatio == 0 {
@@ -214,7 +215,7 @@ func (lc LoadedCluster) Generate(seed int64, settings *config.SimulationSettings
214215}
215216
216217func (lc LoadedCluster ) String () string {
217- return fmt .Sprintf ("cluster: %s" , lc .Info .String ())
218+ return fmt .Sprintf ("cluster: \n %s" , lc .Info .String ())
218219}
219220
220221func (lc LoadedCluster ) Regions () []state.Region {
@@ -356,6 +357,11 @@ type BaseRanges struct {
356357 ReplicaPlacement state.ReplicaPlacement
357358}
358359
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+
359365// GetRangesInfo generates and distributes ranges across stores based on
360366// PlacementType while using other BaseRanges fields for range configuration.
361367func (b BaseRanges ) GetRangesInfo (
@@ -404,15 +410,15 @@ func (br BasicRanges) String() string {
404410// ranges generated based on the parameters specified in the fields of
405411// BasicRanges.
406412func (br BasicRanges ) Generate (
407- seed int64 , settings * config.SimulationSettings , s state.State ,
413+ tag string , seed int64 , settings * config.SimulationSettings , s state.State ,
408414) (state.State , string ) {
409415 if br .PlacementType == Random || br .PlacementType == WeightedRandom {
410416 panic ("BasicRanges generate only uniform or skewed distributions" )
411417 }
412418 rangesInfo , str := br .GetRangesInfo (br .PlacementType , len (s .Stores ()), nil , []float64 {})
413419 br .LoadRangeInfo (s , rangesInfo )
414420 var buf strings.Builder
415- _ , _ = fmt .Fprintf (& buf , "\t %s , %s" , br , str )
421+ _ , _ = fmt .Fprintf (& buf , "%s%s , %s" , tag , br , str )
416422 return s , buf .String ()
417423}
418424
@@ -434,14 +440,14 @@ func (mr MultiRanges) String() string {
434440}
435441
436442func (mr MultiRanges ) Generate (
437- seed int64 , settings * config.SimulationSettings , s state.State ,
443+ tag string , seed int64 , settings * config.SimulationSettings , s state.State ,
438444) (state.State , string ) {
439445 var rangeInfos []state.RangeInfo
440446 var rangeInfoStrings []string
441447 for _ , ranges := range mr {
442448 rangeInfo , rangeInfoStr := ranges .GetRangesInfo (ranges .PlacementType , len (s .Stores ()), nil , []float64 {})
443449 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 ))
445451 }
446452 state .LoadRangeInfo (s , rangeInfos ... )
447453 var buf strings.Builder
0 commit comments