Permalink
Browse files

Refactored API so that the Loader object is templated based on the ta…

…rget BenchmarkModule. This enables us to have benchmark-specific utility functions in the BenchmarkModule class. Cleaning up TPC-C to make it work on Peloton more easily without breaking other systems
  • Loading branch information...
apavlo committed Dec 1, 2016
1 parent e0a1c4e commit 533b8115c5b1aa74026f8cc59d1e12144f63949f
Showing with 121 additions and 153 deletions.
  1. +1 −1 .classpath
  2. +3 −3 src/com/oltpbenchmark/api/Loader.java
  3. +1 −1 src/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkBenchmark.java
  4. +1 −1 src/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkLoader.java
  5. +1 −1 src/com/oltpbenchmark/benchmarks/chbenchmark/CHBenCHmark.java
  6. +2 −3 src/com/oltpbenchmark/benchmarks/chbenchmark/CHBenCHmarkLoader.java
  7. +1 −1 src/com/oltpbenchmark/benchmarks/epinions/EpinionsBenchmark.java
  8. +5 −5 src/com/oltpbenchmark/benchmarks/epinions/EpinionsLoader.java
  9. +1 −1 src/com/oltpbenchmark/benchmarks/hyadapt/HYADAPTBenchmark.java
  10. +2 −2 src/com/oltpbenchmark/benchmarks/hyadapt/HYADAPTLoader.java
  11. +1 −1 src/com/oltpbenchmark/benchmarks/jpab/JPABBenchmark.java
  12. +2 −5 src/com/oltpbenchmark/benchmarks/jpab/JPABLoader.java
  13. +1 −1 src/com/oltpbenchmark/benchmarks/linkbench/LinkBenchBenchmark.java
  14. +2 −2 src/com/oltpbenchmark/benchmarks/linkbench/LinkBenchLoader.java
  15. +1 −1 src/com/oltpbenchmark/benchmarks/noop/NoOpBenchmark.java
  16. +1 −1 src/com/oltpbenchmark/benchmarks/noop/NoOpLoader.java
  17. +1 −1 src/com/oltpbenchmark/benchmarks/resourcestresser/ResourceStresserBenchmark.java
  18. +1 −1 src/com/oltpbenchmark/benchmarks/seats/SEATSBenchmark.java
  19. +3 −3 src/com/oltpbenchmark/benchmarks/seats/SEATSLoader.java
  20. +1 −1 src/com/oltpbenchmark/benchmarks/sibench/SIBenchmark.java
  21. +3 −3 src/com/oltpbenchmark/benchmarks/sibench/SILoader.java
  22. +1 −1 src/com/oltpbenchmark/benchmarks/smallbank/SmallBankBenchmark.java
  23. +4 −4 src/com/oltpbenchmark/benchmarks/smallbank/SmallBankLoader.java
  24. +1 −1 src/com/oltpbenchmark/benchmarks/tatp/TATPBenchmark.java
  25. +5 −5 src/com/oltpbenchmark/benchmarks/tatp/TATPLoader.java
  26. +21 −1 src/com/oltpbenchmark/benchmarks/tpcc/TPCCBenchmark.java
  27. +20 −56 src/com/oltpbenchmark/benchmarks/tpcc/TPCCLoader.java
  28. +1 −7 src/com/oltpbenchmark/benchmarks/tpcc/TPCCUtil.java
  29. +1 −1 src/com/oltpbenchmark/benchmarks/tpch/TPCHBenchmark.java
  30. +10 −16 src/com/oltpbenchmark/benchmarks/tpch/TPCHLoader.java
  31. +1 −1 src/com/oltpbenchmark/benchmarks/twitter/TwitterBenchmark.java
  32. +5 −5 src/com/oltpbenchmark/benchmarks/twitter/TwitterLoader.java
  33. +1 −1 src/com/oltpbenchmark/benchmarks/voter/VoterBenchmark.java
  34. +3 −3 src/com/oltpbenchmark/benchmarks/voter/VoterLoader.java
  35. +1 −1 src/com/oltpbenchmark/benchmarks/wikipedia/WikipediaBenchmark.java
  36. +8 −8 src/com/oltpbenchmark/benchmarks/wikipedia/WikipediaLoader.java
  37. +1 −1 src/com/oltpbenchmark/benchmarks/ycsb/YCSBBenchmark.java
  38. +2 −2 src/com/oltpbenchmark/benchmarks/ycsb/YCSBLoader.java
View
@@ -8,7 +8,6 @@
<classpathentry kind="lib" path="lib/commons-logging-1.1.1.jar"/>
<classpathentry kind="lib" path="lib/commons-collections-3.2.1.jar"/>
<classpathentry kind="lib" path="lib/commons-lang-2.6.jar"/>
<classpathentry kind="lib" path="lib/postgresql-9.1-901.jdbc4.jar"/>
<classpathentry kind="lib" path="lib/hsqldb.jar"/>
<classpathentry kind="lib" path="lib/ganymed-ssh2-build250.jar"/>
<classpathentry kind="lib" path="lib/commons-jxpath-1.3.jar"/>
@@ -38,5 +37,6 @@
<classpathentry kind="lib" path="lib/httpcore-4.3.jar"/>
<classpathentry kind="lib" path="lib/httpclient-4.3.1.jar"/>
<classpathentry kind="lib" path="lib/httpmime-4.3.1.jar"/>
<classpathentry kind="lib" path="lib/postgresql-9.4.1209.jre6.jar"/>
<classpathentry kind="output" path="build"/>
</classpath>
@@ -35,16 +35,16 @@
/**
* @author pavlo
*/
public abstract class Loader {
public abstract class Loader<T extends BenchmarkModule> {
private static final Logger LOG = Logger.getLogger(Loader.class);
protected final BenchmarkModule benchmark;
protected final T benchmark;
protected Connection conn;
protected final WorkloadConfiguration workConf;
protected final double scaleFactor;
private final Histogram<String> tableSizes = new Histogram<String>(true);
public Loader(BenchmarkModule benchmark, Connection conn) {
public Loader(T benchmark, Connection conn) {
this.benchmark = benchmark;
this.conn = conn;
this.workConf = benchmark.getWorkloadConfiguration();
@@ -75,7 +75,7 @@ protected Package getProcedurePackageImpl() {
}
@Override
protected Loader makeLoaderImpl(Connection conn) throws SQLException {
protected Loader<AuctionMarkBenchmark> makeLoaderImpl(Connection conn) throws SQLException {
return new AuctionMarkLoader(this, conn);
}
@@ -54,7 +54,7 @@
* @author pavlo
* @author visawee
*/
public class AuctionMarkLoader extends Loader {
public class AuctionMarkLoader extends Loader<AuctionMarkBenchmark> {
private static final Logger LOG = Logger.getLogger(AuctionMarkLoader.class);
// -----------------------------------------------------------------
@@ -76,7 +76,7 @@ protected Package getProcedurePackageImpl() {
return ret;
}
protected Loader makeLoaderImpl(Connection conn) throws SQLException {
protected Loader<CHBenCHmark> makeLoaderImpl(Connection conn) throws SQLException {
return new CHBenCHmarkLoader(this, conn);
}
@@ -30,14 +30,13 @@
import org.apache.log4j.Logger;
import com.oltpbenchmark.api.BenchmarkModule;
import com.oltpbenchmark.api.Loader;
import com.oltpbenchmark.benchmarks.chbenchmark.pojo.Nation;
import com.oltpbenchmark.benchmarks.chbenchmark.pojo.Region;
import com.oltpbenchmark.benchmarks.chbenchmark.pojo.Supplier;
import com.oltpbenchmark.util.RandomGenerator;
public class CHBenCHmarkLoader extends Loader {
public class CHBenCHmarkLoader extends Loader<CHBenCHmark> {
private static final Logger LOG = Logger.getLogger(CHBenCHmarkLoader.class);
private final static int configCommitCount = 1000; // commit every n records
private static final RandomGenerator ran = new RandomGenerator(0);
@@ -63,7 +62,7 @@
}
}
public CHBenCHmarkLoader(BenchmarkModule benchmark, Connection c) {
public CHBenCHmarkLoader(CHBenCHmark benchmark, Connection c) {
super(benchmark, c);
conn =c;
}
@@ -94,7 +94,7 @@ protected Package getProcedurePackageImpl() {
}
@Override
protected Loader makeLoaderImpl(Connection conn) throws SQLException {
protected Loader<EpinionsBenchmark> makeLoaderImpl(Connection conn) throws SQLException {
return new EpinionsLoader(this, conn);
}
@@ -32,7 +32,7 @@
import com.oltpbenchmark.util.SQLUtil;
import com.oltpbenchmark.util.TextGenerator;
public class EpinionsLoader extends Loader {
public class EpinionsLoader extends Loader<EpinionsBenchmark> {
private static final Logger LOG = Logger.getLogger(EpinionsLoader.class);
@@ -68,7 +68,7 @@ public void load() throws SQLException {
* @throws SQLException
*/
private void loadUsers() throws SQLException {
Table catalog_tbl = this.getTableCatalog("user");
Table catalog_tbl = this.benchmark.getTableCatalog("user");
assert (catalog_tbl != null);
String sql = SQLUtil.getInsertSQL(catalog_tbl);
PreparedStatement userInsert = this.conn.prepareStatement(sql);
@@ -107,7 +107,7 @@ private void loadUsers() throws SQLException {
* @throws SQLException
*/
private void loadItems() throws SQLException {
Table catalog_tbl = this.getTableCatalog("item");
Table catalog_tbl = this.benchmark.getTableCatalog("item");
assert (catalog_tbl != null);
String sql = SQLUtil.getInsertSQL(catalog_tbl);
PreparedStatement itemInsert = this.conn.prepareStatement(sql);
@@ -150,7 +150,7 @@ private void loadItems() throws SQLException {
* @throws SQLException
*/
private void loadReviews() throws SQLException {
Table catalog_tbl = this.getTableCatalog("review");
Table catalog_tbl = this.benchmark.getTableCatalog("review");
assert (catalog_tbl != null);
String sql = SQLUtil.getInsertSQL(catalog_tbl);
PreparedStatement reviewInsert = this.conn.prepareStatement(sql);
@@ -210,7 +210,7 @@ private void loadReviews() throws SQLException {
* @throws SQLException
*/
public void loadTrust() throws SQLException {
Table catalog_tbl = this.getTableCatalog("trust");
Table catalog_tbl = this.benchmark.getTableCatalog("trust");
assert (catalog_tbl != null);
String sql = SQLUtil.getInsertSQL(catalog_tbl);
PreparedStatement trustInsert = this.conn.prepareStatement(sql);
@@ -79,7 +79,7 @@ public HYADAPTBenchmark(WorkloadConfiguration workConf) {
}
@Override
protected Loader makeLoaderImpl(Connection conn) throws SQLException {
protected Loader<HYADAPTBenchmark> makeLoaderImpl(Connection conn) throws SQLException {
return new HYADAPTLoader(this, conn);
}
@@ -28,7 +28,7 @@
import java.util.Random;
public class HYADAPTLoader extends Loader {
public class HYADAPTLoader extends Loader<HYADAPTBenchmark> {
private static final Logger LOG = Logger.getLogger(HYADAPTLoader.class);
private final int num_record;
private static final Random rand = new Random();
@@ -61,7 +61,7 @@ public static int getRandInt() {
@Override
public void load() throws SQLException {
Table catalog_tbl = this.getTableCatalog("HTABLE");
Table catalog_tbl = this.benchmark.getTableCatalog("HTABLE");
assert (catalog_tbl != null);
String sql = SQLUtil.getInsertSQL(catalog_tbl);
@@ -72,7 +72,7 @@ public JPABBenchmark(WorkloadConfiguration workConf) {
}
@Override
protected Loader makeLoaderImpl(Connection conn) throws SQLException {
protected Loader<JPABBenchmark> makeLoaderImpl(Connection conn) throws SQLException {
return new JPABLoader(this, conn, jpabConf.getPersistanceUnit());
}
@@ -23,17 +23,14 @@
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import org.apache.commons.lang.NotImplementedException;
import com.oltpbenchmark.api.BenchmarkModule;
import com.oltpbenchmark.api.Loader;
import com.oltpbenchmark.benchmarks.jpab.tests.BasicTest;
import com.oltpbenchmark.benchmarks.jpab.tests.Test;
public class JPABLoader extends Loader {
public class JPABLoader extends Loader<JPABBenchmark> {
String persistanceUnit;
public JPABLoader(BenchmarkModule benchmark, Connection conn, String persistanceUnit) throws SQLException {
public JPABLoader(JPABBenchmark benchmark, Connection conn, String persistanceUnit) throws SQLException {
super(benchmark, conn);
this.persistanceUnit=persistanceUnit;
}
@@ -63,7 +63,7 @@ public LinkBenchBenchmark(WorkloadConfiguration workConf) throws Exception {
}
@Override
protected Loader makeLoaderImpl(Connection conn) throws SQLException {
protected Loader<LinkBenchBenchmark> makeLoaderImpl(Connection conn) throws SQLException {
return new LinkBenchLoader(this, conn);
}
@@ -27,7 +27,7 @@
import com.oltpbenchmark.util.SQLUtil;
import com.oltpbenchmark.util.TextGenerator;
public class LinkBenchLoader extends Loader {
public class LinkBenchLoader extends Loader<LinkBenchBenchmark> {
private static final Logger LOG = Logger.getLogger(LinkBenchLoader.class);
private final int num_record;
@@ -41,7 +41,7 @@ public LinkBenchLoader(LinkBenchBenchmark benchmark, Connection c) {
@Override
public void load() throws SQLException {
Table catalog_tbl = this.getTableCatalog("USERTABLE");
Table catalog_tbl = this.benchmark.getTableCatalog("USERTABLE");
assert (catalog_tbl != null);
String sql = SQLUtil.getInsertSQL(catalog_tbl);
@@ -50,7 +50,7 @@ public NoOpBenchmark(WorkloadConfiguration workConf) {
}
@Override
protected Loader makeLoaderImpl(Connection conn) throws SQLException {
protected Loader<NoOpBenchmark> makeLoaderImpl(Connection conn) throws SQLException {
return new NoOpLoader(this, conn);
}
@@ -28,7 +28,7 @@
* @author pavlo
* @author eric-haibin-lin
*/
public class NoOpLoader extends Loader {
public class NoOpLoader extends Loader<NoOpBenchmark> {
private static final Logger LOG = Logger.getLogger(NoOpLoader.class);
public NoOpLoader(NoOpBenchmark benchmark, Connection c) {
@@ -54,7 +54,7 @@ protected Package getProcedurePackageImpl() {
}
@Override
protected Loader makeLoaderImpl(Connection conn) throws SQLException {
protected Loader<ResourceStresserBenchmark> makeLoaderImpl(Connection conn) throws SQLException {
throw new NotImplementedException();
}
}
@@ -69,7 +69,7 @@ protected Package getProcedurePackageImpl() {
}
@Override
protected Loader makeLoaderImpl(Connection conn) throws SQLException {
protected Loader<SEATSBenchmark> makeLoaderImpl(Connection conn) throws SQLException {
return new SEATSLoader(this, conn);
}
@@ -54,7 +54,7 @@
import com.oltpbenchmark.util.*;
import com.oltpbenchmark.util.RandomDistribution.*;
public class SEATSLoader extends Loader {
public class SEATSLoader extends Loader<SEATSBenchmark> {
private static final Logger LOG = Logger.getLogger(SEATSLoader.class);
// -----------------------------------------------------------------
@@ -201,7 +201,7 @@ protected void loadFixedTables() {
for (String table_name : SEATSConstants.TABLES_DATAFILES) {
LOG.debug(String.format("Loading table '%s' from fixed file", table_name));
try {
Table catalog_tbl = this.getTableCatalog(table_name);
Table catalog_tbl = this.benchmark.getTableCatalog(table_name);
assert(catalog_tbl != null);
Iterable<Object[]> iterable = this.getFixedIterable(catalog_tbl);
this.loadTable(catalog_tbl, iterable, 5000);
@@ -225,7 +225,7 @@ protected void loadScalingTables() {
// create a new FREQUENT_FLYER account for a CUSTOMER
for (String table_name : SEATSConstants.TABLES_SCALING) {
try {
Table catalog_tbl = this.getTableCatalog(table_name);
Table catalog_tbl = this.benchmark.getTableCatalog(table_name);
assert(catalog_tbl != null);
Iterable<Object[]> iterable = this.getScalingIterable(catalog_tbl);
this.loadTable(catalog_tbl, iterable, 5000);
@@ -71,7 +71,7 @@ public SIBenchmark(WorkloadConfiguration workConf) {
}
@Override
protected Loader makeLoaderImpl(Connection conn) throws SQLException {
protected Loader<SIBenchmark> makeLoaderImpl(Connection conn) throws SQLException {
return new SILoader(this, conn);
}
@@ -27,7 +27,7 @@
import com.oltpbenchmark.catalog.Table;
import com.oltpbenchmark.util.SQLUtil;
public class SILoader extends Loader {
public class SILoader extends Loader<SIBenchmark> {
private static final Logger LOG = Logger.getLogger(SILoader.class);
private final int num_record;
@@ -41,8 +41,8 @@ public SILoader(SIBenchmark benchmark, Connection c) {
@Override
public void load() throws SQLException {
Random rand = new Random(System.currentTimeMillis());
Table catalog_tbl = this.getTableCatalog("SITEST");
Random rand = this.benchmark.rng();
Table catalog_tbl = this.benchmark.getTableCatalog("SITEST");
assert (catalog_tbl != null);
String sql = SQLUtil.getInsertSQL(catalog_tbl);
@@ -34,7 +34,7 @@ public SmallBankBenchmark(WorkloadConfiguration workConf) {
}
@Override
protected Loader makeLoaderImpl(Connection conn) throws SQLException {
protected Loader<SmallBankBenchmark> makeLoaderImpl(Connection conn) throws SQLException {
return new SmallBankLoader(this, conn);
}
@@ -15,7 +15,7 @@
* SmallBankBenchmark Loader
* @author pavlo
*/
public class SmallBankLoader extends Loader {
public class SmallBankLoader extends Loader<SmallBankBenchmark> {
private static final Logger LOG = Logger.getLogger(SmallBankLoader.class);
private final Table catalogAccts;
@@ -32,11 +32,11 @@
public SmallBankLoader(SmallBankBenchmark benchmark, Connection conn) {
super(benchmark, conn);
this.catalogAccts = this.getTableCatalog(SmallBankConstants.TABLENAME_ACCOUNTS);
this.catalogAccts = this.benchmark.getTableCatalog(SmallBankConstants.TABLENAME_ACCOUNTS);
assert(this.catalogAccts != null);
this.catalogSavings = this.getTableCatalog(SmallBankConstants.TABLENAME_SAVINGS);
this.catalogSavings = this.benchmark.getTableCatalog(SmallBankConstants.TABLENAME_SAVINGS);
assert(this.catalogSavings != null);
this.catalogChecking = this.getTableCatalog(SmallBankConstants.TABLENAME_CHECKING);
this.catalogChecking = this.benchmark.getTableCatalog(SmallBankConstants.TABLENAME_CHECKING);
assert(this.catalogChecking != null);
this.sqlAccts = SQLUtil.getInsertSQL(this.catalogAccts);
@@ -50,7 +50,7 @@ protected Package getProcedurePackageImpl() {
}
@Override
protected Loader makeLoaderImpl(Connection conn) throws SQLException {
protected Loader<TATPBenchmark> makeLoaderImpl(Connection conn) throws SQLException {
return (new TATPLoader(this, conn));
}
}
@@ -27,7 +27,7 @@
import com.oltpbenchmark.catalog.*;
import com.oltpbenchmark.util.SQLUtil;
public class TATPLoader extends Loader {
public class TATPLoader extends Loader<TATPBenchmark> {
private static final Logger LOG = Logger.getLogger(TATPLoader.class);
private final long subscriberSize;
@@ -48,7 +48,7 @@ public void load() {
new Thread() {
public void run() {
if (LOG.isDebugEnabled()) LOG.debug("Start loading " + TATPConstants.TABLENAME_SUBSCRIBER);
Table catalog_tbl = getTableCatalog(TATPConstants.TABLENAME_SUBSCRIBER);
Table catalog_tbl = benchmark.getTableCatalog(TATPConstants.TABLENAME_SUBSCRIBER);
try {
genSubscriber(catalog_tbl);
} catch (SQLException ex) {
@@ -61,7 +61,7 @@ public void run() {
new Thread() {
public void run() {
if (LOG.isDebugEnabled()) LOG.debug("Start loading " + TATPConstants.TABLENAME_ACCESS_INFO);
Table catalog_tbl = getTableCatalog(TATPConstants.TABLENAME_ACCESS_INFO);
Table catalog_tbl = benchmark.getTableCatalog(TATPConstants.TABLENAME_ACCESS_INFO);
try {
genAccessInfo(catalog_tbl);
} catch (SQLException ex) {
@@ -74,8 +74,8 @@ public void run() {
new Thread() {
public void run() {
if (LOG.isDebugEnabled()) LOG.debug("Start loading " + TATPConstants.TABLENAME_SPECIAL_FACILITY + " and " + TATPConstants.TABLENAME_CALL_FORWARDING);
Table catalog_spe = getTableCatalog(TATPConstants.TABLENAME_SPECIAL_FACILITY);
Table catalog_cal = getTableCatalog(TATPConstants.TABLENAME_CALL_FORWARDING);
Table catalog_spe = benchmark.getTableCatalog(TATPConstants.TABLENAME_SPECIAL_FACILITY);
Table catalog_cal = benchmark.getTableCatalog(TATPConstants.TABLENAME_CALL_FORWARDING);
try {
genSpeAndCal(catalog_spe, catalog_cal);
} catch (SQLException ex) {
Oops, something went wrong.

0 comments on commit 533b811

Please sign in to comment.