Skip to content

Commit

Permalink
Merge pull request #7 from yugabyte/AddKeyingAndThinkTimes
Browse files Browse the repository at this point in the history
Adding the keying/think time to each transaction.
  • Loading branch information
psudheer21 authored Apr 7, 2020
2 parents aeafa18 + 83d57ca commit 658a8a2
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 63 deletions.
5 changes: 4 additions & 1 deletion config/workload_all.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@
</transactiontype>
</transactiontypes>

<terminals>2</terminals>
<scalefactor>2</scalefactor>
<!-- TPC-C 4.2.2: The number of terminals should be 10 per warehouse -->
<terminals>20</terminals>
<useKeyingTime>true</useKeyingTime>
<useThinkTime>true</useThinkTime>
<works>
<work>
<time>30</time>
Expand Down
7 changes: 7 additions & 0 deletions src/com/oltpbenchmark/DBWorkload.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,13 @@ public static void main(String[] args) throws Exception {
// Nothing to do here !
}

try {
wrkld.setUseKeyingTime(xmlConfig.getBoolean("useKeyingTime"));
wrkld.setUseThinkTime(xmlConfig.getBoolean("useThinkTime"));
} catch(NoSuchElementException nse) {
// Nothing to do here !
}

// ----------------------------------------------------------------
// CREATE BENCHMARK MODULE
// ----------------------------------------------------------------
Expand Down
75 changes: 46 additions & 29 deletions src/com/oltpbenchmark/WorkloadConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
import com.oltpbenchmark.util.ThreadUtil;

public class WorkloadConfiguration {
private DatabaseType db_type;

private DatabaseType db_type;
private String benchmarkName;
public String getBenchmarkName() {
return benchmarkName;
Expand All @@ -47,20 +47,23 @@ public void setBenchmarkName(String benchmarkName) {
private String db_name;
private String db_username;
private String db_password;
private String db_driver;
private String db_driver;
private double scaleFactor = 1.0;
private double selectivity = -1.0;
private int terminals;
private int loaderThreads = ThreadUtil.availableProcessors();
private int numTxnTypes;
private TraceReader traceReader = null;
private boolean useKeyingTime = true;
private boolean useThinkTime = true;

public TraceReader getTraceReader() {
return traceReader;
}
public void setTraceReader(TraceReader traceReader) {
this.traceReader = traceReader;
}

private XMLConfiguration xmlConfig = null;

private List<Phase> works = new ArrayList<Phase>();
Expand All @@ -69,7 +72,7 @@ public void setTraceReader(TraceReader traceReader) {
public WorkloadState getWorkloadState() {
return workloadState;
}

/**
* Initiate a new benchmark and workload state
*/
Expand All @@ -85,106 +88,104 @@ public WorkloadState initializeState(BenchmarkState benchmarkState) {
private boolean recordAbortMessages = false;
private String dataDir = null;



public void addWork(int time, int warmup, int rate, List<String> weights, boolean rateLimited, boolean disabled, boolean serial, boolean timed, int active_terminals, Phase.Arrival arrival) {
works.add(new Phase(benchmarkName, numberOfPhases, time, warmup, rate, weights, rateLimited, disabled, serial, timed, active_terminals, arrival));
numberOfPhases++;
}

public void setDBType(DatabaseType dbType) {
db_type = dbType;
}

public DatabaseType getDBType() {
return db_type;
}

public void setDBConnection(String database) {
this.db_connection = database;
}

public String getDBConnection() {
return db_connection;
}

public void setDBName(String dbname) {
this.db_name = dbname;
}

public void setLoaderThreads(int loaderThreads) {
this.loaderThreads = loaderThreads;
}

/**
* The number of loader threads that the framework is allowed to use.
* @return
*/
public int getLoaderThreads() {
return this.loaderThreads;
}

public int getNumTxnTypes() {
return numTxnTypes;
}

public void setNumTxnTypes(int numTxnTypes) {
this.numTxnTypes = numTxnTypes;
}

public String getDBName() {
return db_name;
}

public void setDBUsername(String username) {
this.db_username = username;
}

public String getDBUsername() {
return db_username;
}

public void setDBPassword(String password) {
this.db_password = password;
}

public String getDBPassword() {
return this.db_password;
}

public void setSelectivity(double selectivity) {
this.selectivity = selectivity;
}

public double getSelectivity() {
return this.selectivity;
}

public void setDBDriver(String driver) {
this.db_driver = driver;
}

public String getDBDriver() {
return this.db_driver;
}

public void setRecordAbortMessages(boolean recordAbortMessages) {
this.recordAbortMessages = recordAbortMessages;
}

/**
* Whether each worker should record the transaction's UserAbort messages
* This primarily useful for debugging a benchmark
*/
public boolean getRecordAbortMessages() {
return (this.recordAbortMessages);
}

/**
* Set the scale factor for the database
* A value of 1 means the default size.
* A value greater than 1 means the database is larger
* A value less than 1 means the database is smaller
* A value less than 1 means the database is smaller
* @param scaleFactor
*/
public void setScaleFactor(double scaleFactor) {
Expand All @@ -209,15 +210,15 @@ public int getNumberOfPhases() {
/**
* Set the directory in which we can find the data files (for example, CSV
* files) for loading the database.
*/
*/
public void setDataDir(String dir) {
this.dataDir = dir;
}

/**
* Return the directory in which we can find the data files (for example, CSV
* files) for loading the database.
*/
*/
public String getDataDir() {
return this.dataDir;
}
Expand All @@ -240,7 +241,7 @@ public void setTerminals(int terminals) {
public int getTerminals() {
return terminals;
}

public TransactionTypes getTransTypes() {
return transTypes;
}
Expand Down Expand Up @@ -290,7 +291,23 @@ else if(mode.equals("TRANSACTION_READ_UNCOMMITTED"))
else if(!mode.isEmpty())
System.out.println("Indefined isolation mode, set to default [TRANSACTION_SERIALIZABLE]");
}


public boolean getUseKeyingTime() {
return useKeyingTime;
}

public void setUseKeyingTime(boolean useKeyingTime) {
this.useKeyingTime = useKeyingTime;
}

public boolean getUseThinkTime() {
return useThinkTime;
}

public void setUseThinkTime(boolean useThinkTime) {
this.useThinkTime = useThinkTime;
}

@Override
public String toString() {
Class<?> confClass = this.getClass();
Expand Down
Loading

0 comments on commit 658a8a2

Please sign in to comment.