Skip to content

Commit

Permalink
Added a new simulation of fixed workload type to generic. Also change… (
Browse files Browse the repository at this point in the history
#7)

Co-authored-by: Amit Chauhan <[email protected]>
  • Loading branch information
akscjo and Amit Chauhan authored Jan 24, 2023
1 parent fedd5d4 commit 95899c3
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>com.yugabyte</groupId>
<artifactId>yb-workload-simulator</artifactId>
<version>0.0.2</version>
<version>0.0.3</version>
<name>yb-workload-simulator</name>
<description>YugabyteDB Workload Simulation Demo App</description>
<properties>
Expand Down
45 changes: 39 additions & 6 deletions src/main/java/com/yugabyte/simulation/service/GenericWorkload.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public String getName() {
private enum WorkloadType {
CREATE_TABLES,
SEED_DATA,
RUN_SIMULATION_FIXED_WORKLOAD,
RUN_SIMULATION,
RUN_LIKE_QUERY_ON_GENERIC2,
RUN_LIKE_QUERY_ON_GENERIC3,
Expand All @@ -91,6 +92,7 @@ private enum WorkloadType {
private final FixedStepsWorkloadType createTablesWorkloadType;
private final FixedTargetWorkloadType seedingWorkloadType;
private final ThroughputWorkloadType runInstanceType;
private final FixedTargetWorkloadType simulationFixedWorkloadType;

public GenericWorkload() {
this.createTablesWorkloadType = new FixedStepsWorkloadType(
Expand All @@ -104,6 +106,7 @@ public GenericWorkload() {

this.seedingWorkloadType = new FixedTargetWorkloadType();
this.runInstanceType = new ThroughputWorkloadType();
this.simulationFixedWorkloadType = new FixedTargetWorkloadType();
}

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

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

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


@Override
public List<WorkloadDesc> getWorkloads() {
return Arrays.asList(
createTablesWorkload
, seedingWorkload
, runningWorkload
, simulationFixedWorkload
// , runningWorkload
);
}

Expand All @@ -148,16 +161,15 @@ public InvocationResult invokeWorkload(String workloadId, ParamValue[] values) {
case CREATE_TABLES:
this.createTables();
return new InvocationResult("Ok");

case SEED_DATA:
this.seedData(values[0].getIntValue(), values[1].getIntValue());
return new InvocationResult("Ok");

case RUN_SIMULATION:
this.runSimulation(values);
return new InvocationResult("Ok");


case RUN_SIMULATION_FIXED_WORKLOAD:
this.runSimulationFixedWorkload(values);
return new InvocationResult("Ok");
case STOP_NODE:
return new InvocationResult("Ok");
case START_NODE:
Expand Down Expand Up @@ -219,6 +231,27 @@ public void processRow(ResultSet rs) throws SQLException {
return results;
}

private void runSimulationFixedWorkload(ParamValue[] values) {
int numOfInvocations = values[0].getIntValue();
int maxThreads = values[1].getIntValue();
boolean runInserts = values[2].getBoolValue();
System.out.println("**** Preloading data...");
final List<UUID> uuids = getQueryList();
System.out.println("**** Preloading complete...");
Random random = ThreadLocalRandom.current();
seedingWorkloadType
.createInstance(serviceManager)
.execute(maxThreads, numOfInvocations, (customData, threadData) -> {
UUID id = uuids.get(random.nextInt(uuids.size()));
runPointReadgeneric1(id);
runPointReadgeneric2(id);
runPointReadgeneric3(id);
if(runInserts){
runInserts();
}
return threadData;
});
}

private void runSimulation(ParamValue[] values) {
int tps = values[0].getIntValue();
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ spring:
logging.level:
root: ERROR
java.sql: ERROR
com.zaxxer.hikari: INFO
com.zaxxer.hikari: TRACE
com.yugabyte: ERROR
com.yugabyte.simulation.workload: ERROR
org.springframework.jdbc.core: ERROR
Expand Down

0 comments on commit 95899c3

Please sign in to comment.