Skip to content

Commit 95899c3

Browse files
akscjoAmit Chauhan
andauthored
Added a new simulation of fixed workload type to generic. Also change… (#7)
Co-authored-by: Amit Chauhan <[email protected]>
1 parent fedd5d4 commit 95899c3

File tree

3 files changed

+41
-8
lines changed

3 files changed

+41
-8
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</parent>
1111
<groupId>com.yugabyte</groupId>
1212
<artifactId>yb-workload-simulator</artifactId>
13-
<version>0.0.2</version>
13+
<version>0.0.3</version>
1414
<name>yb-workload-simulator</name>
1515
<description>YugabyteDB Workload Simulation Demo App</description>
1616
<properties>

src/main/java/com/yugabyte/simulation/service/GenericWorkload.java

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public String getName() {
8181
private enum WorkloadType {
8282
CREATE_TABLES,
8383
SEED_DATA,
84+
RUN_SIMULATION_FIXED_WORKLOAD,
8485
RUN_SIMULATION,
8586
RUN_LIKE_QUERY_ON_GENERIC2,
8687
RUN_LIKE_QUERY_ON_GENERIC3,
@@ -91,6 +92,7 @@ private enum WorkloadType {
9192
private final FixedStepsWorkloadType createTablesWorkloadType;
9293
private final FixedTargetWorkloadType seedingWorkloadType;
9394
private final ThroughputWorkloadType runInstanceType;
95+
private final FixedTargetWorkloadType simulationFixedWorkloadType;
9496

9597
public GenericWorkload() {
9698
this.createTablesWorkloadType = new FixedStepsWorkloadType(
@@ -104,6 +106,7 @@ public GenericWorkload() {
104106

105107
this.seedingWorkloadType = new FixedTargetWorkloadType();
106108
this.runInstanceType = new ThroughputWorkloadType();
109+
this.simulationFixedWorkloadType = new FixedTargetWorkloadType();
107110
}
108111

109112
private WorkloadDesc createTablesWorkload = new WorkloadDesc(
@@ -122,20 +125,30 @@ public GenericWorkload() {
122125

123126
private WorkloadDesc runningWorkload = new WorkloadDesc(
124127
GenericWorkload.WorkloadType.RUN_SIMULATION.toString(),
125-
"Simulation",
128+
"Simulation - old",
126129
"Run a simulation of a reads from 3 tables (Latency on charts will show cumulative value for 3 selects and 3 inserts)",
127130
new WorkloadParamDesc("Throughput (tps)", 1, 1000000, 500),
128131
new WorkloadParamDesc("Max Threads", 1, 500, 64),
129132
new WorkloadParamDesc("Include new Inserts (to 3 tables)", false)
130133
);
131134

135+
private WorkloadDesc simulationFixedWorkload = new WorkloadDesc(
136+
GenericWorkload.WorkloadType.RUN_SIMULATION_FIXED_WORKLOAD.toString(),
137+
"Simulation",
138+
"Run a simulation of a reads from 3 tables (Latency on charts will show cumulative value for 3 selects and 3 inserts)",
139+
new WorkloadParamDesc("Invocations", 1, 10000000, 1000000),
140+
new WorkloadParamDesc("Max Threads", 1, 500, 64),
141+
new WorkloadParamDesc("Include new Inserts (to 3 tables)", false)
142+
);
143+
132144

133145
@Override
134146
public List<WorkloadDesc> getWorkloads() {
135147
return Arrays.asList(
136148
createTablesWorkload
137149
, seedingWorkload
138-
, runningWorkload
150+
, simulationFixedWorkload
151+
// , runningWorkload
139152
);
140153
}
141154

@@ -148,16 +161,15 @@ public InvocationResult invokeWorkload(String workloadId, ParamValue[] values) {
148161
case CREATE_TABLES:
149162
this.createTables();
150163
return new InvocationResult("Ok");
151-
152164
case SEED_DATA:
153165
this.seedData(values[0].getIntValue(), values[1].getIntValue());
154166
return new InvocationResult("Ok");
155-
156167
case RUN_SIMULATION:
157168
this.runSimulation(values);
158169
return new InvocationResult("Ok");
159-
160-
170+
case RUN_SIMULATION_FIXED_WORKLOAD:
171+
this.runSimulationFixedWorkload(values);
172+
return new InvocationResult("Ok");
161173
case STOP_NODE:
162174
return new InvocationResult("Ok");
163175
case START_NODE:
@@ -219,6 +231,27 @@ public void processRow(ResultSet rs) throws SQLException {
219231
return results;
220232
}
221233

234+
private void runSimulationFixedWorkload(ParamValue[] values) {
235+
int numOfInvocations = values[0].getIntValue();
236+
int maxThreads = values[1].getIntValue();
237+
boolean runInserts = values[2].getBoolValue();
238+
System.out.println("**** Preloading data...");
239+
final List<UUID> uuids = getQueryList();
240+
System.out.println("**** Preloading complete...");
241+
Random random = ThreadLocalRandom.current();
242+
seedingWorkloadType
243+
.createInstance(serviceManager)
244+
.execute(maxThreads, numOfInvocations, (customData, threadData) -> {
245+
UUID id = uuids.get(random.nextInt(uuids.size()));
246+
runPointReadgeneric1(id);
247+
runPointReadgeneric2(id);
248+
runPointReadgeneric3(id);
249+
if(runInserts){
250+
runInserts();
251+
}
252+
return threadData;
253+
});
254+
}
222255

223256
private void runSimulation(ParamValue[] values) {
224257
int tps = values[0].getIntValue();

src/main/resources/application.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ spring:
3232
logging.level:
3333
root: ERROR
3434
java.sql: ERROR
35-
com.zaxxer.hikari: INFO
35+
com.zaxxer.hikari: TRACE
3636
com.yugabyte: ERROR
3737
com.yugabyte.simulation.workload: ERROR
3838
org.springframework.jdbc.core: ERROR

0 commit comments

Comments
 (0)