MCPcopy Create free account
hub / github.com/cmu-db/benchbase / BenchmarkModule

Class BenchmarkModule

src/main/java/com/oltpbenchmark/api/BenchmarkModule.java:38–438  ·  view source on GitHub ↗

Base class for all benchmark implementations

Source from the content-addressed store, hash-verified

36
37/** Base class for all benchmark implementations */
38public abstract class BenchmarkModule {
39 private static final Logger LOG = LoggerFactory.getLogger(BenchmarkModule.class);
40
41 /** The workload configuration for this benchmark invocation */
42 protected final WorkloadConfiguration workConf;
43
44 /** Class loader variable for this benchmark */
45 protected ClassLoader classLoader;
46
47 /** These are the variations of the Procedure's Statement SQL */
48 protected final StatementDialects dialects;
49
50 /** Supplemental Procedures */
51 private final Set<Class<? extends Procedure>> supplementalProcedures = new HashSet<>();
52
53 /** A single Random object that should be re-used by all a benchmark's components */
54 private static final ThreadLocal<Random> rng = new ThreadLocal<>();
55
56 private AbstractCatalog catalog = null;
57
58 /**
59 * Constructor!
60 *
61 * @param workConf
62 */
63 public BenchmarkModule(WorkloadConfiguration workConf) {
64 this.workConf = workConf;
65 this.dialects = new StatementDialects(workConf);
66 // setClassLoader();
67 this.classLoader = Thread.currentThread().getContextClassLoader();
68 }
69
70 /**
71 * Instantiates the classLoader variable, needs to be overwritten if benchmark uses a custom
72 * implementation.
73 */
74 protected void setClassLoader() {
75 this.classLoader = Thread.currentThread().getContextClassLoader();
76 }
77
78 // --------------------------------------------------------------------------
79 // DATABASE CONNECTION
80 // --------------------------------------------------------------------------
81
82 public final Connection makeConnection() throws SQLException {
83
84 if (StringUtils.isEmpty(workConf.getUsername())) {
85 return DriverManager.getConnection(workConf.getUrl());
86 } else {
87 return DriverManager.getConnection(
88 workConf.getUrl(), workConf.getUsername(), workConf.getPassword());
89 }
90 }
91
92 private String afterLoadScriptPath = null;
93
94 public final void setAfterLoadScriptPath(String scriptPath) throws FileNotFoundException {
95 if (scriptPath != null) scriptPath = scriptPath.trim();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected