From 2b96494ceaead57b48d83a3451b164662934a202 Mon Sep 17 00:00:00 2001 From: xunzhang Date: Tue, 7 Apr 2020 20:03:48 -0700 Subject: [PATCH 1/2] Add OLTPBENCH_HOME env variable to support running oltpbench as a library, no effect on previous usage. --- classpath.sh | 4 ++-- oltpbenchmark | 4 ++-- src/com/oltpbenchmark/DBWorkload.java | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/classpath.sh b/classpath.sh index d38309122..a2ab8fe47 100755 --- a/classpath.sh +++ b/classpath.sh @@ -1,7 +1,7 @@ #!/bin/bash -echo -ne "build" -for i in `ls lib/*.jar`; do +echo -ne "$OLTPBENCH_HOME./build" +for i in `ls $OLTPBENCH_HOME./lib/*.jar`; do # IMPORTANT: Make sure that we do not include hsqldb v1 if [[ $i =~ .*hsqldb-1.* ]]; then continue diff --git a/oltpbenchmark b/oltpbenchmark index f2d511427..393a9a05b 100755 --- a/oltpbenchmark +++ b/oltpbenchmark @@ -1,3 +1,3 @@ #!/bin/bash -java -Xmx8G -cp `./classpath.sh bin` -Dlog4j.configuration=log4j.properties com.oltpbenchmark.DBWorkload $@ - +# OLTPBENCH_HOME should be empty or end with "/" +java -Xmx8G -cp `$OLTPBENCH_HOME./classpath.sh bin` -Dlog4j.configuration=$OLTPBENCH_HOME./log4j.properties com.oltpbenchmark.DBWorkload $@ diff --git a/src/com/oltpbenchmark/DBWorkload.java b/src/com/oltpbenchmark/DBWorkload.java index 89f2559fa..347513cb5 100644 --- a/src/com/oltpbenchmark/DBWorkload.java +++ b/src/com/oltpbenchmark/DBWorkload.java @@ -84,7 +84,8 @@ public static void main(String[] args) throws Exception { CommandLineParser parser = new PosixParser(); XMLConfiguration pluginConfig=null; try { - pluginConfig = new XMLConfiguration("config/plugin.xml"); + // OLTPBENCH_HOME should be empty or end with "/" + pluginConfig = new XMLConfiguration(System.getenv("OLTPBENCH_HOME")+"config/plugin.xml"); } catch (ConfigurationException e1) { LOG.info("Plugin configuration file config/plugin.xml is missing"); e1.printStackTrace(); From 4bab954fb5bdcb4b9e9dcbc028ef1cb64cfa1eaf Mon Sep 17 00:00:00 2001 From: xunzhang Date: Wed, 8 Apr 2020 11:08:21 -0700 Subject: [PATCH 2/2] null value fix --- src/com/oltpbenchmark/DBWorkload.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/com/oltpbenchmark/DBWorkload.java b/src/com/oltpbenchmark/DBWorkload.java index 347513cb5..5772aad1a 100644 --- a/src/com/oltpbenchmark/DBWorkload.java +++ b/src/com/oltpbenchmark/DBWorkload.java @@ -84,8 +84,10 @@ public static void main(String[] args) throws Exception { CommandLineParser parser = new PosixParser(); XMLConfiguration pluginConfig=null; try { + String oltpbench_home = System.getenv("OLTPBENCH_HOME"); // OLTPBENCH_HOME should be empty or end with "/" - pluginConfig = new XMLConfiguration(System.getenv("OLTPBENCH_HOME")+"config/plugin.xml"); + oltpbench_home = oltpbench_home == null ? "" : oltpbench_home + "/"; + pluginConfig = new XMLConfiguration(oltpbench_home + "config/plugin.xml"); } catch (ConfigurationException e1) { LOG.info("Plugin configuration file config/plugin.xml is missing"); e1.printStackTrace();