@@ -87,9 +87,8 @@ public String getName() {
8787 private enum WorkloadType {
8888 CREATE_TABLES ,
8989 SEED_DATA ,
90- RUN_SIMULATION ,
91- RUN_LIKE_QUERY_ON_GENERIC2 ,
92- RUN_LIKE_QUERY_ON_GENERIC3
90+ RUN_SIMULATION_FIXED_WORKLOAD ,
91+ RUN_SIMULATION
9392 }
9493
9594 private final FixedStepsWorkloadType createTablesWorkloadType ;
@@ -120,25 +119,36 @@ public GenericCassandraWorkload() {
120119 private WorkloadDesc seedingWorkload = new WorkloadDesc (
121120 GenericCassandraWorkload .WorkloadType .SEED_DATA .toString (),
122121 "Seed Data" ,
123- "Load data into the 3 tables (Latency on charts will show cumulative value for 3 inserts) " ,
122+ "Populate new data into the table " ,
124123 new WorkloadParamDesc ("Items to generate:" , 1 , Integer .MAX_VALUE , 1000 ),
125124 new WorkloadParamDesc ("Threads" , 1 , 500 , 32 )
126125 );
127126
128127 private WorkloadDesc runningWorkload = new WorkloadDesc (
129128 GenericCassandraWorkload .WorkloadType .RUN_SIMULATION .toString (),
130- "Simulation" ,
131- "Run a simulation of a reads from 3 tables (Latency on charts will show cumulative value for 3 selects and 3 inserts) " ,
129+ "Simulation - TPS " ,
130+ "Run a simulation of point reads and inserts" ,
132131 new WorkloadParamDesc ("Throughput (tps)" , 1 , 1000000 , 500 ),
133132 new WorkloadParamDesc ("Max Threads" , 1 , 500 , 64 ),
134- new WorkloadParamDesc ("Include new Inserts (to 3 tables) " , false )
133+ new WorkloadParamDesc ("Include new Inserts" , false )
135134 );
136135
136+ private WorkloadDesc simulationFixedWorkload = new WorkloadDesc (
137+ GenericCassandraWorkload .WorkloadType .RUN_SIMULATION_FIXED_WORKLOAD .toString (),
138+ "Simulation" ,
139+ "Run a simulation of point reads and inserts" ,
140+ new WorkloadParamDesc ("Invocations" , 1 , 10000000 , 1000000 ),
141+ new WorkloadParamDesc ("Max Threads" , 1 , 500 , 64 ),
142+ new WorkloadParamDesc ("Include new inserts" , false )
143+ );
144+
145+
137146 @ Override
138147 public List <WorkloadDesc > getWorkloads () {
139148 return Arrays .asList (
140149 createTablesWorkload
141150 , seedingWorkload
151+ , simulationFixedWorkload
142152 , runningWorkload
143153 );
144154 }
@@ -160,6 +170,9 @@ public InvocationResult invokeWorkload(String workloadId, ParamValue[] values) {
160170 case RUN_SIMULATION :
161171 this .runSimulation (values [0 ].getIntValue (), values [1 ].getIntValue (), values [2 ].getBoolValue ());
162172 return new InvocationResult ("Ok" );
173+ case RUN_SIMULATION_FIXED_WORKLOAD :
174+ this .runSimulationFixedWorkload (values );
175+ return new InvocationResult ("Ok" );
163176 }
164177 throw new IllegalArgumentException ("Unknown workload " + workloadId );
165178 }
@@ -177,21 +190,7 @@ private void seedData(int numberToGenerate, int threads) {
177190 .createInstance (serviceManager )
178191 .execute (threads , numberToGenerate , (customData , threadData ) -> {
179192 runInserts ();
180- UUID uuid = LoadGeneratorUtils .getUUID ();
181- CqlSession session = this .getCassandraClient ();
182- PreparedStatement ps = session .prepare (INSERT_RECORD_GENERIC1 );
183- //ps.bind(uuid,LoadGeneratorUtils.getName());
184- session .execute (ps .bind (uuid ,LoadGeneratorUtils .getName ()));
185-
186- // jdbcTemplate.update(INSERT_RECORD_GENERIC2,
187- // uuid,
188- // LoadGeneratorUtils.getAlphaString(LoadGeneratorUtils.getInt(1,30))
189- // );
190- // jdbcTemplate.update(INSERT_RECORD_GENERIC3,
191- // uuid,
192- // LoadGeneratorUtils.getAlphaString(LoadGeneratorUtils.getInt(1,255)),
193- // LoadGeneratorUtils.getAlphaString(LoadGeneratorUtils.getInt(1,30))
194- // );
193+
195194 return threadData ;
196195 });
197196 }
@@ -207,6 +206,27 @@ private List<UUID> getQueryList() {
207206 return results ;
208207 }
209208
209+ private void runSimulationFixedWorkload (ParamValue [] values ) {
210+ int numOfInvocations = values [0 ].getIntValue ();
211+ int maxThreads = values [1 ].getIntValue ();
212+ boolean runInserts = values [2 ].getBoolValue ();
213+ System .out .println ("**** Preloading data..." );
214+ final List <UUID > uuids = getQueryList ();
215+ System .out .println ("**** Preloading complete..." );
216+ Random random = ThreadLocalRandom .current ();
217+ seedingWorkloadType
218+ .createInstance (serviceManager )
219+ .execute (maxThreads , numOfInvocations , (customData , threadData ) -> {
220+ UUID id = uuids .get (random .nextInt (uuids .size ()));
221+ runPointReadgeneric1 (id );
222+ runPointReadgeneric2 (id );
223+ runPointReadgeneric3 (id );
224+ if (runInserts ){
225+ runInserts ();
226+ }
227+ return threadData ;
228+ });
229+ }
210230
211231 private void runSimulation (int tps , int maxThreads , boolean runInserts ) {
212232 System .out .println ("**** Preloading data..." );
@@ -240,7 +260,7 @@ private void runPointReadgeneric1(UUID id){
240260 for (Row row : rs ) {
241261 // process the row
242262 int count = 0 ;
243- System .out .println (row .getUuid ("pkid" )+"," +row .getString ("col1" ));
263+ // System.out.println(row.getUuid("pkid")+","+row.getString("col1"));
244264 }
245265 }
246266
@@ -256,7 +276,10 @@ private void runPointReadgeneric3(UUID id){
256276
257277 private void runInserts (){
258278 UUID uuid = LoadGeneratorUtils .getUUID ();
259- // TODO
279+ CqlSession session = this .getCassandraClient ();
280+ PreparedStatement ps = session .prepare (INSERT_RECORD_GENERIC1 );
281+ //ps.bind(uuid,LoadGeneratorUtils.getName());
282+ session .execute (ps .bind (uuid ,LoadGeneratorUtils .getName ()));
260283 }
261284
262285
0 commit comments