diff --git a/HOW-TO-RUN.txt b/HOW-TO-RUN.txt index a8da918..dcc9694 100755 --- a/HOW-TO-RUN.txt +++ b/HOW-TO-RUN.txt @@ -5,8 +5,9 @@ Use of JDK7 is required. Sample JDBC Connection Property files are provided as props.pg : for PostgreSQL/EnterpriseDB props.ora : for Oracle props.db2 : for DB2 + props.fb : for Firebird -0. As the user postgres, create the benchmarksql user with correct permissions. +0. (skip for Firebird) As the user postgres, create the benchmarksql user with correct permissions. postgres=# CREATE USER benchmarksql WITH SUPERUSER PASSWORD 'password'; postgres=# GRANT ALL PRIVILEGES ON DATABASE postgres TO benchmarksql; @@ -15,7 +16,7 @@ Use of JDK7 is required. Sample JDBC Connection Property files are provided as 2. Run the "sqlTableCreates" to create the base tables. - $ ./runSQL.sh props.pg sqlTableCreates + $ ./runSQL.sh props.?? sqlTableCreates.?? 3. Run the Loader command file to load all of the default data @@ -25,7 +26,7 @@ Use of JDK7 is required. Sample JDBC Connection Property files are provided as A.) Approximately half a million rows (per Warehouse) will be loaded across 9 tables. - $ ./runLoader.sh props.pg numWarehouses 1 + $ ./runLoader.sh props.?? numWarehouses 1 NOTE: You should run the sqlTableTruncates scripts if your tables are not already empty. @@ -35,25 +36,25 @@ Use of JDK7 is required. Sample JDBC Connection Property files are provided as bulk loaded into the database as many times as required by your testing. - $ ./runLoader.sh props.pg numWarehouses 1 fileLocation /tmp/csv/ + $ ./runLoader.sh props.?? numWarehouses 1 fileLocation /tmp/csv/ These CSV files can be bulk loaded as follows: $ ./runSQL.sh props.pg sqlTableCopies You may truncate the data via: - $ ./runSQL.sh props.pg sqlTableTruncates + $ ./runSQL.sh props.?? sqlTableTruncates.?? 4. Run the "runSQL" command file to execute the SQL script "sqlIndexCreates" to create the primary keys & other indexes on the tables. - $ ./runSQL.sh props.pg sqlIndexCreates + $ ./runSQL.sh props.?? sqlIndexCreates.?? 5. Run the "runBenchmark" command file to test the database. This command will create terminals and automatically start the transaction based on the parameters set in "props". - $ ./runBenchmark.sh props.pg + $ ./runBenchmark.sh props.?? diff --git a/build.xml b/build.xml index 77c2745..920c448 100755 --- a/build.xml +++ b/build.xml @@ -1,7 +1,7 @@ BenchmarkSQL Build File - + diff --git a/build/Customer.class b/build/Customer.class old mode 100755 new mode 100644 index 6af53cf..21d4bfb Binary files a/build/Customer.class and b/build/Customer.class differ diff --git a/build/District.class b/build/District.class old mode 100755 new mode 100644 index be9fee9..c4fcf56 Binary files a/build/District.class and b/build/District.class differ diff --git a/build/ExecJDBC.class b/build/ExecJDBC.class old mode 100755 new mode 100644 index 486f538..e8b4928 Binary files a/build/ExecJDBC.class and b/build/ExecJDBC.class differ diff --git a/build/History.class b/build/History.class old mode 100755 new mode 100644 index 0080b43..55333b3 Binary files a/build/History.class and b/build/History.class differ diff --git a/build/Item.class b/build/Item.class old mode 100755 new mode 100644 index e1d31fd..ef97386 Binary files a/build/Item.class and b/build/Item.class differ diff --git a/build/LoadData.class b/build/LoadData.class old mode 100755 new mode 100644 index d3b35a0..c0149d0 Binary files a/build/LoadData.class and b/build/LoadData.class differ diff --git a/build/NewOrder.class b/build/NewOrder.class old mode 100755 new mode 100644 index 62dfecf..d0336c2 Binary files a/build/NewOrder.class and b/build/NewOrder.class differ diff --git a/build/Oorder.class b/build/Oorder.class old mode 100755 new mode 100644 index 4ae73ce..a83d6b0 Binary files a/build/Oorder.class and b/build/Oorder.class differ diff --git a/build/OrderLine.class b/build/OrderLine.class old mode 100755 new mode 100644 index e145070..dada570 Binary files a/build/OrderLine.class and b/build/OrderLine.class differ diff --git a/build/Stock.class b/build/Stock.class old mode 100755 new mode 100644 index 4aa595b..090f565 Binary files a/build/Stock.class and b/build/Stock.class differ diff --git a/build/Warehouse.class b/build/Warehouse.class old mode 100755 new mode 100644 index b7607f8..f2cc870 Binary files a/build/Warehouse.class and b/build/Warehouse.class differ diff --git a/build/jTPCC.class b/build/jTPCC.class old mode 100755 new mode 100644 index a604da5..2fcd3c6 Binary files a/build/jTPCC.class and b/build/jTPCC.class differ diff --git a/build/jTPCCConfig.class b/build/jTPCCConfig.class old mode 100755 new mode 100644 index fd889a1..f5d3f6b Binary files a/build/jTPCCConfig.class and b/build/jTPCCConfig.class differ diff --git a/build/jTPCCTerminal.class b/build/jTPCCTerminal.class old mode 100755 new mode 100644 index 2e003f1..4c7ac4c Binary files a/build/jTPCCTerminal.class and b/build/jTPCCTerminal.class differ diff --git a/build/jTPCCUtil.class b/build/jTPCCUtil.class old mode 100755 new mode 100644 index 379aaf2..fd68e6a Binary files a/build/jTPCCUtil.class and b/build/jTPCCUtil.class differ diff --git a/build/jdbcIO.class b/build/jdbcIO.class old mode 100755 new mode 100644 index c8de532..15e363d Binary files a/build/jdbcIO.class and b/build/jdbcIO.class differ diff --git a/dist/BenchmarkSQL-4.1.jar b/dist/BenchmarkSQL-4.1.jar old mode 100755 new mode 100644 index 6b4582d..a143d0b Binary files a/dist/BenchmarkSQL-4.1.jar and b/dist/BenchmarkSQL-4.1.jar differ diff --git a/lib/connector-api-1.5.jar b/lib/connector-api-1.5.jar new file mode 100644 index 0000000..683762e Binary files /dev/null and b/lib/connector-api-1.5.jar differ diff --git a/lib/jaybird-jdk18-3.0.15.jar b/lib/jaybird-jdk18-3.0.15.jar new file mode 100644 index 0000000..9e11e09 Binary files /dev/null and b/lib/jaybird-jdk18-3.0.15.jar differ diff --git a/lib/postgresql-9.3-1101.jdbc41.jar b/lib/postgresql-9.3-1101.jdbc41.jar old mode 100755 new mode 100644 diff --git a/run/props.db2 b/run/props.db2 index 77199bf..ae1f686 100755 --- a/run/props.db2 +++ b/run/props.db2 @@ -2,6 +2,7 @@ driver=com.ibm.db2.jcc.DB2Driver conn=jdbc:db2://localhost:50000/bmarkdb user=db2inst1 password=db2admin +schema=benchmark. warehouses=1 diff --git a/run/props.fb b/run/props.fb new file mode 100755 index 0000000..1d5e6a0 --- /dev/null +++ b/run/props.fb @@ -0,0 +1,24 @@ +driver=org.firebirdsql.jdbc.FBDriver +conn=jdbc:firebirdsql:localhost:/mnt/ssd/jtpcc.fdb +user=sysdba +password=masterkey +schema= + +warehouses=10 +terminals=10 +//To run specified transactions per terminal- runMins must equal zero +runTxnsPerTerminal=0 +//To run for specified minutes- runTxnsPerTerminal must equal zero +runMins=10 +//Number of total transactions per minute +limitTxnsPerMin=0 + + +//The following five values must add up to 100 +//The default percentages of 45, 43, 4, 4 & 4 match the TPC-C spec +newOrderWeight=45 +paymentWeight=43 +orderStatusWeight=4 +deliveryWeight=4 +stockLevelWeight=4 + diff --git a/run/props.ora b/run/props.ora index bf1fbba..3fcd2ac 100755 --- a/run/props.ora +++ b/run/props.ora @@ -2,7 +2,7 @@ driver=oracle.jdbc.driver.OracleDriver conn=jdbc:oracle:thin:@localhost:1521:XE user=scott password=tiger - +schema=benchmark. warehouses=1 terminals=1 diff --git a/run/props.pg b/run/props.pg index 88c1e57..c622566 100755 --- a/run/props.pg +++ b/run/props.pg @@ -2,6 +2,7 @@ driver=org.postgresql.Driver conn=jdbc:postgresql://localhost:5432/postgres user=benchmarksql password=password +schema=benchmark. warehouses=1 terminals=1 diff --git a/run/runBenchmark.sh b/run/runBenchmark.sh index 18db5e9..0160c31 100755 --- a/run/runBenchmark.sh +++ b/run/runBenchmark.sh @@ -1 +1,2 @@ -java -cp .:../lib/postgresql-9.3-1101.jdbc41.jar:../lib/log4j-1.2.17.jar:../lib/apache-log4j-extras-1.1.jar:../dist/BenchmarkSQL-4.1.jar -Dprop=$1 jTPCC +#java -cp .:../lib/postgresql-9.3-1101.jdbc41.jar:../lib/log4j-1.2.17.jar:../lib/apache-log4j-extras-1.1.jar:../dist/BenchmarkSQL-4.1.jar -Dprop=$1 jTPCC +java -cp .:../lib/connector-api-1.5.jar:../lib/jaybird-jdk18-3.0.15.jar:../lib/log4j-1.2.17.jar:../lib/apache-log4j-extras-1.1.jar:../dist/BenchmarkSQL-4.1.jar -Dprop=$1 jTPCC diff --git a/run/runLoader.sh b/run/runLoader.sh index 5f91530..d76ed91 100755 --- a/run/runLoader.sh +++ b/run/runLoader.sh @@ -1 +1,2 @@ -java -cp .:../lib/postgresql-9.3-1101.jdbc41.jar:../dist/BenchmarkSQL-4.1.jar -Dprop=$1 LoadData $2 $3 $4 $5 +#java -cp .:../lib/postgresql-9.3-1101.jdbc41.jar:../dist/BenchmarkSQL-4.1.jar -Dprop=$1 LoadData $2 $3 $4 $5 +java -cp .:../lib/connector-api-1.5.jar:../lib/jaybird-jdk18-3.0.15.jar:../dist/BenchmarkSQL-4.1.jar -Dprop=$1 LoadData $2 $3 $4 $5 diff --git a/run/runSQL.sh b/run/runSQL.sh index 38a4d29..d546b1a 100755 --- a/run/runSQL.sh +++ b/run/runSQL.sh @@ -1,4 +1,5 @@ -myCP="../lib/postgresql-9.3-1101.jdbc41.jar" +#myCP="../lib/postgresql-9.3-1101.jdbc41.jar" +myCP="../lib/connector-api-1.5.jar:../lib/jaybird-jdk18-3.0.15.jar" myCP="$myCP:../dist/BenchmarkSQL-4.1.jar" myOPTS="-Dprop=$1" diff --git a/run/sqlIndexCreates.fb b/run/sqlIndexCreates.fb new file mode 100755 index 0000000..b3be34a --- /dev/null +++ b/run/sqlIndexCreates.fb @@ -0,0 +1,30 @@ + +alter table warehouse add constraint pk_warehouse + primary key (w_id); + +alter table district add constraint pk_district + primary key (d_w_id, d_id); + +alter table customer add constraint pk_customer + primary key (c_w_id, c_d_id, c_id); + +create index ndx_customer_name + on customer (c_w_id, c_d_id, c_last, c_first); + +alter table oorder add constraint pk_oorder + primary key (o_w_id, o_d_id, o_id); + +create unique index ndx_oorder_carrier + on oorder (o_w_id, o_d_id, o_carrier_id, o_id); + +alter table new_order add constraint pk_new_order + primary key (no_w_id, no_d_id, no_o_id); + +alter table order_line add constraint pk_order_line + primary key (ol_w_id, ol_d_id, ol_o_id, ol_number); + +alter table stock add constraint pk_stock + primary key (s_w_id, s_i_id); + +alter table item add constraint pk_item + primary key (i_id); diff --git a/run/sqlIndexDrops.fb b/run/sqlIndexDrops.fb new file mode 100755 index 0000000..390199c --- /dev/null +++ b/run/sqlIndexDrops.fb @@ -0,0 +1,21 @@ + +alter table warehouse drop constraint pk_warehouse; + +alter table district drop constraint pk_district; + +alter table customer drop constraint pk_customer; +drop index ndx_customer_name; + +-- history table has no primary key +-- commit; + +alter table oorder drop constraint pk_oorder; +drop index ndx_oorder_carrier; + +alter table new_order drop constraint pk_new_order; + +alter table order_line drop constraint pk_order_line; + +alter table stock drop constraint pk_stock; + +alter table item drop constraint pk_item; \ No newline at end of file diff --git a/run/sqlTableCreates.fb b/run/sqlTableCreates.fb new file mode 100755 index 0000000..0667071 --- /dev/null +++ b/run/sqlTableCreates.fb @@ -0,0 +1,124 @@ +create table warehouse ( + w_id integer not null, + w_ytd decimal(12,2), + w_tax decimal(4,4), + w_name varchar(10), + w_street_1 varchar(20), + w_street_2 varchar(20), + w_city varchar(20), + w_state char(2), + w_zip char(9) +); + +create table district ( + d_w_id integer not null, + d_id integer not null, + d_ytd decimal(12,2), + d_tax decimal(4,4), + d_next_o_id integer, + d_name varchar(10), + d_street_1 varchar(20), + d_street_2 varchar(20), + d_city varchar(20), + d_state char(2), + d_zip char(9) +); + +create table customer ( + c_w_id integer not null, + c_d_id integer not null, + c_id integer not null, + c_discount decimal(4,4), + c_credit char(2), + c_last varchar(16), + c_first varchar(16), + c_credit_lim decimal(12,2), + c_balance decimal(12,2), + c_ytd_payment float, + c_payment_cnt integer, + c_delivery_cnt integer, + c_street_1 varchar(20), + c_street_2 varchar(20), + c_city varchar(20), + c_state char(2), + c_zip char(9), + c_phone char(16), + c_since timestamp, + c_middle char(2), + c_data varchar(500) +); + +create table history ( + hist_id integer generated by default as identity primary key, + h_c_id integer, + h_c_d_id integer, + h_c_w_id integer, + h_d_id integer, + h_w_id integer, + h_date timestamp, + h_amount decimal(6,2), + h_data varchar(24) +); + +create table oorder ( + o_w_id integer not null, + o_d_id integer not null, + o_id integer not null, + o_c_id integer, + o_carrier_id integer, + o_ol_cnt decimal(2,0), + o_all_local decimal(1,0), + o_entry_d timestamp +); + + +create table new_order ( + no_w_id integer not null, + no_d_id integer not null, + no_o_id integer not null +); + + +create table order_line ( + ol_w_id integer not null, + ol_d_id integer not null, + ol_o_id integer not null, + ol_number integer not null, + ol_i_id integer not null, + ol_delivery_d timestamp, + ol_amount decimal(6,2), + ol_supply_w_id integer, + ol_quantity decimal(2,0), + ol_dist_info char(24) +); + + +create table stock ( + s_w_id integer not null, + s_i_id integer not null, + s_quantity decimal(4,0), + s_ytd decimal(8,2), + s_order_cnt integer, + s_remote_cnt integer, + s_data varchar(50), + s_dist_01 char(24), + s_dist_02 char(24), + s_dist_03 char(24), + s_dist_04 char(24), + s_dist_05 char(24), + s_dist_06 char(24), + s_dist_07 char(24), + s_dist_08 char(24), + s_dist_09 char(24), + s_dist_10 char(24) +); + + +create table item ( + i_id integer not null, + i_name varchar(24), + i_price decimal(5,2), + i_data varchar(50), + i_im_id integer +); + diff --git a/run/sqlTableDrops b/run/sqlTableDrops index 663fc07..2718a26 100755 --- a/run/sqlTableDrops +++ b/run/sqlTableDrops @@ -16,5 +16,3 @@ drop table benchmarksql.order_line; drop table benchmarksql.history; drop table benchmarksql.new_order; - -DROP SCHEMA IF EXISTS benchmarksql CASCADE; diff --git a/run/sqlTableDrops.fb b/run/sqlTableDrops.fb new file mode 100755 index 0000000..cb14e4f --- /dev/null +++ b/run/sqlTableDrops.fb @@ -0,0 +1,20 @@ + +drop table warehouse; + +drop table item; + +drop table stock; + +drop table district; + +drop table customer; + +drop table oorder; + +drop table order_line; + +drop table history; + +drop sequence hist_id_seq; + +drop table new_order; diff --git a/run/sqlTableTruncates.fb b/run/sqlTableTruncates.fb new file mode 100755 index 0000000..864f400 --- /dev/null +++ b/run/sqlTableTruncates.fb @@ -0,0 +1,18 @@ + +delete from warehouse; + +delete from item; + +delete from stock; + +delete from district; + +delete from customer; + +delete from history; + +delete from oorder; + +delete from order_line; + +delete from new_order; diff --git a/src/LoadData/LoadData.java b/src/LoadData/LoadData.java index 404b3aa..e34cf65 100755 --- a/src/LoadData/LoadData.java +++ b/src/LoadData/LoadData.java @@ -186,17 +186,17 @@ static void initJDBC() { stmt = conn.createStatement(); distPrepStmt = conn.prepareStatement - ("INSERT INTO benchmarksql.district " + + ("INSERT INTO " + ini.getProperty("schema") + "district " + " (d_id, d_w_id, d_ytd, d_tax, d_next_o_id, d_name, d_street_1, d_street_2, d_city, d_state, d_zip) " + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); itemPrepStmt = conn.prepareStatement - ("INSERT INTO benchmarksql.item " + + ("INSERT INTO " + ini.getProperty("schema") + "item " + " (i_id, i_name, i_price, i_data, i_im_id) " + "VALUES (?, ?, ?, ?, ?)"); custPrepStmt = conn.prepareStatement - ("INSERT INTO benchmarksql.customer " + + ("INSERT INTO " + ini.getProperty("schema") + "customer " + " (c_id, c_d_id, c_w_id, " + "c_discount, c_credit, c_last, c_first, c_credit_lim, " + "c_balance, c_ytd_payment, c_payment_cnt, c_delivery_cnt, " + @@ -205,39 +205,39 @@ static void initJDBC() { "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); histPrepStmt = conn.prepareStatement - ("INSERT INTO benchmarksql.history " + - " (hist_id, h_c_id, h_c_d_id, h_c_w_id, " + + ("INSERT INTO " + ini.getProperty("schema") + "history " + + " (h_c_id, h_c_d_id, h_c_w_id, " + "h_d_id, h_w_id, " + "h_date, h_amount, h_data) " + - "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"); + "VALUES (?, ?, ?, ?, ?, ?, ?, ?)"); ordrPrepStmt = conn.prepareStatement - ("INSERT INTO benchmarksql.oorder " + + ("INSERT INTO " + ini.getProperty("schema") + "oorder " + " (o_id, o_w_id, o_d_id, o_c_id, " + "o_carrier_id, o_ol_cnt, o_all_local, o_entry_d) " + "VALUES (?, ?, ?, ?, ?, ?, ?, ?)"); orlnPrepStmt = conn.prepareStatement - ("INSERT INTO benchmarksql.order_line " + + ("INSERT INTO " + ini.getProperty("schema") + "order_line " + " (ol_w_id, ol_d_id, ol_o_id, " + "ol_number, ol_i_id, ol_delivery_d, " + "ol_amount, ol_supply_w_id, ol_quantity, ol_dist_info) " + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); nworPrepStmt = conn.prepareStatement - ("INSERT INTO benchmarksql.new_order " + + ("INSERT INTO " + ini.getProperty("schema") + "new_order " + " (no_w_id, no_d_id, no_o_id) " + "VALUES (?, ?, ?)"); stckPrepStmt = conn.prepareStatement - ("INSERT INTO benchmarksql.stock " + + ("INSERT INTO " + ini.getProperty("schema") + "stock " + " (s_i_id, s_w_id, s_quantity, s_ytd, s_order_cnt, s_remote_cnt, s_data, " + "s_dist_01, s_dist_02, s_dist_03, s_dist_04, s_dist_05, " + "s_dist_06, s_dist_07, s_dist_08, s_dist_09, s_dist_10) " + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); whsePrepStmt = conn.prepareStatement - ("INSERT INTO benchmarksql.warehouse " + + ("INSERT INTO " + ini.getProperty("schema") + "warehouse " + " (w_id, w_ytd, w_tax, w_name, w_street_1, w_street_2, w_city, w_state, w_zip) " + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"); @@ -802,17 +802,16 @@ static int loadCust(int whseKount, int distWhseKount, int custDistKount) { custPrepStmt.addBatch(); - histPrepStmt.setInt(1, history.hist_id); - histPrepStmt.setInt(2, history.h_c_id); - histPrepStmt.setInt(3, history.h_c_d_id); - histPrepStmt.setInt(4, history.h_c_w_id); + histPrepStmt.setInt(1, history.h_c_id); + histPrepStmt.setInt(2, history.h_c_d_id); + histPrepStmt.setInt(3, history.h_c_w_id); - histPrepStmt.setInt(5, history.h_d_id); - histPrepStmt.setInt(6, history.h_w_id); + histPrepStmt.setInt(4, history.h_d_id); + histPrepStmt.setInt(5, history.h_w_id); Timestamp hdate = new Timestamp(history.h_date); - histPrepStmt.setTimestamp(7, hdate); - histPrepStmt.setDouble(8, history.h_amount); - histPrepStmt.setString(9, history.h_data); + histPrepStmt.setTimestamp(6, hdate); + histPrepStmt.setDouble(7, history.h_amount); + histPrepStmt.setString(8, history.h_data); histPrepStmt.addBatch(); diff --git a/src/client/jTPCC.java b/src/client/jTPCC.java index 0222cd2..7abc496 100755 --- a/src/client/jTPCC.java +++ b/src/client/jTPCC.java @@ -79,6 +79,7 @@ public jTPCC() log.info("Term-00, "); String iWarehouses = getProp(ini,"warehouses"); String iTerminals = getProp(ini,"terminals"); + String iSchema = getProp(ini, "schema"); String iRunTxnsPerTerminal = ini.getProperty("runTxnsPerTerminal"); String iRunMins = ini.getProperty("runMins"); @@ -284,7 +285,7 @@ else if(newOrderWeightValue == 0 && paymentWeightValue == 0 && orderStatusWeight jTPCCTerminal terminal = new jTPCCTerminal (terminalName, terminalWarehouseID, terminalDistrictID, conn, transactionsPerTerminal, paymentWeightValue, orderStatusWeightValue, - deliveryWeightValue, stockLevelWeightValue, numWarehouses, limPerMin_Terminal, this); + deliveryWeightValue, stockLevelWeightValue, numWarehouses, limPerMin_Terminal, this, iSchema); terminals[i] = terminal; terminalNames[i] = terminalName; @@ -312,22 +313,22 @@ else if(newOrderWeightValue == 0 && paymentWeightValue == 0 && orderStatusWeight //^Create Terminals, Start Transactions v // if(dummvar==true){ - sessionStart = getCurrentTime(); - sessionStartTimestamp = System.currentTimeMillis(); - sessionNextTimestamp = sessionStartTimestamp; - if(sessionEndTargetTime != -1) - sessionEndTargetTime += sessionStartTimestamp; - - synchronized(terminals) - { - printMessage("Starting all terminals..."); - transactionCount = 1; - for(int i = 0; i < terminals.length; i++) - (new Thread(terminals[i])).start(); + sessionStart = getCurrentTime(); + sessionStartTimestamp = System.currentTimeMillis(); + sessionNextTimestamp = sessionStartTimestamp; + if(sessionEndTargetTime != -1) + sessionEndTargetTime += sessionStartTimestamp; - } - - printMessage("All terminals started executing " + sessionStart); + synchronized(terminals) + { + printMessage("Starting all terminals..."); + transactionCount = 1; + for(int i = 0; i < terminals.length; i++) + (new Thread(terminals[i])).start(); + + } + + printMessage("All terminals started executing " + sessionStart); } } diff --git a/src/client/jTPCCTerminal.java b/src/client/jTPCCTerminal.java index 4d4f7ab..f00bfe8 100755 --- a/src/client/jTPCCTerminal.java +++ b/src/client/jTPCCTerminal.java @@ -26,6 +26,7 @@ public class jTPCCTerminal implements jTPCCConfig, Runnable private int terminalWarehouseID, terminalDistrictID; private int paymentWeight, orderStatusWeight, deliveryWeight, stockLevelWeight, limPerMin_Terminal; private jTPCC parent; + private String schema; private Random gen; private int transactionCount = 1, numTransactions, numWarehouses, newOrderCounter; @@ -86,7 +87,8 @@ public class jTPCCTerminal implements jTPCCConfig, Runnable public jTPCCTerminal (String terminalName, int terminalWarehouseID, int terminalDistrictID, Connection conn, int numTransactions, int paymentWeight, int orderStatusWeight, - int deliveryWeight, int stockLevelWeight, int numWarehouses, int limPerMin_Terminal, jTPCC parent) throws SQLException + int deliveryWeight, int stockLevelWeight, int numWarehouses, int limPerMin_Terminal, + jTPCC parent, String schema) throws SQLException { this.terminalName = terminalName; this.conn = conn; @@ -100,6 +102,7 @@ public class jTPCCTerminal implements jTPCCConfig, Runnable this.terminalWarehouseID = terminalWarehouseID; this.terminalDistrictID = terminalDistrictID; this.parent = parent; + this.schema = schema; this.numTransactions = numTransactions; this.paymentWeight = paymentWeight; this.orderStatusWeight = orderStatusWeight; @@ -395,7 +398,7 @@ private int deliveryTransaction(int w_id, int o_carrier_id) if (delivGetOrderId == null) { delivGetOrderId = conn.prepareStatement( - "SELECT no_o_id FROM benchmarksql.new_order WHERE no_d_id = ?" + + "SELECT no_o_id FROM " + schema + "new_order WHERE no_d_id = ?" + " AND no_w_id = ?" + " ORDER BY no_o_id ASC"); } @@ -419,7 +422,7 @@ private int deliveryTransaction(int w_id, int o_carrier_id) if (delivDeleteNewOrder == null) { delivDeleteNewOrder = conn.prepareStatement( - "DELETE FROM benchmarksql.new_order" + + "DELETE FROM " + schema + "new_order" + " WHERE no_d_id = ?" + " AND no_w_id = ?" + " AND no_o_id = ?"); @@ -444,7 +447,7 @@ private int deliveryTransaction(int w_id, int o_carrier_id) if (delivGetCustId == null) { delivGetCustId = conn.prepareStatement( "SELECT o_c_id" + - " FROM benchmarksql.oorder" + + " FROM " + schema + "oorder" + " WHERE o_id = ?" + " AND o_d_id = ?" + " AND o_w_id = ?"); @@ -466,7 +469,7 @@ private int deliveryTransaction(int w_id, int o_carrier_id) if (delivUpdateCarrierId == null) { delivUpdateCarrierId = conn.prepareStatement( - "UPDATE benchmarksql.oorder SET o_carrier_id = ?" + + "UPDATE " + schema + "oorder SET o_carrier_id = ?" + " WHERE o_id = ?" + " AND o_d_id = ?" + " AND o_w_id = ?"); @@ -485,7 +488,7 @@ private int deliveryTransaction(int w_id, int o_carrier_id) if (delivUpdateDeliveryDate == null) { delivUpdateDeliveryDate = conn.prepareStatement( - "UPDATE benchmarksql.order_line SET ol_delivery_d = ?" + + "UPDATE " + schema + "order_line SET ol_delivery_d = ?" + " WHERE ol_o_id = ?" + " AND ol_d_id = ?" + " AND ol_w_id = ?"); @@ -505,7 +508,7 @@ private int deliveryTransaction(int w_id, int o_carrier_id) if (delivSumOrderAmount == null) { delivSumOrderAmount = conn.prepareStatement( "SELECT SUM(ol_amount) AS ol_total" + - " FROM benchmarksql.order_line" + + " FROM " + schema + "order_line" + " WHERE ol_o_id = ?" + " AND ol_d_id = ?" + " AND ol_w_id = ?"); @@ -527,7 +530,7 @@ private int deliveryTransaction(int w_id, int o_carrier_id) if (delivUpdateCustBalDelivCnt == null) { delivUpdateCustBalDelivCnt = conn.prepareStatement( - "UPDATE benchmarksql.customer SET c_balance = c_balance + ?" + + "UPDATE " + schema + "customer SET c_balance = c_balance + ?" + ", c_delivery_cnt = c_delivery_cnt + 1" + " WHERE c_id = ?" + " AND c_d_id = ?" + @@ -610,7 +613,7 @@ private void orderStatusTransaction(int w_id, int d_id, int c_id, String c_last, { if (ordStatCountCust == null) { ordStatCountCust = conn.prepareStatement( - "SELECT count(*) AS namecnt FROM benchmarksql.customer" + + "SELECT count(*) AS namecnt FROM " + schema + "customer" + " WHERE c_last = ? AND c_d_id = ? AND c_w_id = ?"); } @@ -631,7 +634,7 @@ private void orderStatusTransaction(int w_id, int d_id, int c_id, String c_last, if (ordStatGetCust == null) { ordStatGetCust = conn.prepareStatement( - "SELECT c_balance, c_first, c_middle, c_id FROM benchmarksql.customer" + + "SELECT c_balance, c_first, c_middle, c_id FROM " + schema + "customer" + " WHERE c_last = ?" + " AND c_d_id = ?" + " AND c_w_id = ?" + @@ -665,7 +668,7 @@ private void orderStatusTransaction(int w_id, int d_id, int c_id, String c_last, if (ordStatGetCustBal == null) { ordStatGetCustBal = conn.prepareStatement( "SELECT c_balance, c_first, c_middle, c_last" + - " FROM benchmarksql.customer" + + " FROM " + schema + "customer" + " WHERE c_id = ?" + " AND c_d_id = ?" + " AND c_w_id = ?"); @@ -693,7 +696,7 @@ private void orderStatusTransaction(int w_id, int d_id, int c_id, String c_last, if (ordStatGetNewestOrd == null) { ordStatGetNewestOrd = conn.prepareStatement( - "SELECT MAX(o_id) AS maxorderid FROM benchmarksql.oorder" + + "SELECT MAX(o_id) AS maxorderid FROM " + schema + "oorder" + " WHERE o_w_id = ?" + " AND o_d_id = ?" + " AND o_c_id = ?"); @@ -714,7 +717,7 @@ private void orderStatusTransaction(int w_id, int d_id, int c_id, String c_last, if (ordStatGetOrder == null) { ordStatGetOrder = conn.prepareStatement( "SELECT o_carrier_id, o_entry_d" + - " FROM benchmarksql.oorder" + + " FROM " + schema + "oorder" + " WHERE o_w_id = ?" + " AND o_d_id = ?" + " AND o_c_id = ?" + @@ -741,7 +744,7 @@ private void orderStatusTransaction(int w_id, int d_id, int c_id, String c_last, ordStatGetOrderLines = conn.prepareStatement( "SELECT ol_i_id, ol_supply_w_id, ol_quantity," + " ol_amount, ol_delivery_d" + - " FROM benchmarksql.order_line" + + " FROM " + schema + "order_line" + " WHERE ol_o_id = ?" + " AND ol_d_id =?" + " AND ol_w_id = ?"); @@ -854,7 +857,7 @@ private void orderStatusTransaction(int w_id, int d_id, int c_id, String c_last, if (stmtGetCustWhse == null) { stmtGetCustWhse = conn.prepareStatement( "SELECT c_discount, c_last, c_credit, w_tax" + - " FROM benchmarksql.customer, benchmarksql.warehouse" + + " FROM " + schema + "customer, " + schema + "warehouse" + " WHERE w_id = ? AND w_id = c_w_id" + " AND c_d_id = ? AND c_id = ?"); } @@ -881,7 +884,7 @@ private void orderStatusTransaction(int w_id, int d_id, int c_id, String c_last, if (stmtGetDist == null) { stmtGetDist = conn.prepareStatement( - "SELECT d_next_o_id, d_tax FROM benchmarksql.district" + + "SELECT d_next_o_id, d_tax FROM " + schema + "district" + " WHERE d_id = ? AND d_w_id = ? FOR UPDATE"); } @@ -903,7 +906,7 @@ private void orderStatusTransaction(int w_id, int d_id, int c_id, String c_last, { if (stmtInsertNewOrder == null) { stmtInsertNewOrder = conn.prepareStatement( - "INSERT INTO benchmarksql.NEW_ORDER (no_o_id, no_d_id, no_w_id) " + + "INSERT INTO " + schema + "NEW_ORDER (no_o_id, no_d_id, no_w_id) " + "VALUES ( ?, ?, ?)"); } @@ -922,7 +925,7 @@ private void orderStatusTransaction(int w_id, int d_id, int c_id, String c_last, if (stmtUpdateDist == null) { stmtUpdateDist = conn.prepareStatement( - "UPDATE benchmarksql.district SET d_next_o_id = d_next_o_id + 1 " + + "UPDATE " + schema + "district SET d_next_o_id = d_next_o_id + 1 " + " WHERE d_id = ? AND d_w_id = ?"); } @@ -936,7 +939,7 @@ private void orderStatusTransaction(int w_id, int d_id, int c_id, String c_last, if (stmtInsertOOrder == null) { stmtInsertOOrder = conn.prepareStatement( - "INSERT INTO benchmarksql.OORDER " + + "INSERT INTO " + schema + "OORDER " + " (o_id, o_d_id, o_w_id, o_c_id, o_entry_d, o_ol_cnt, o_all_local)" + " VALUES (?, ?, ?, ?, ?, ?, ?)"); } @@ -964,7 +967,7 @@ private void orderStatusTransaction(int w_id, int d_id, int c_id, String c_last, if (stmtGetItem == null) { stmtGetItem = conn.prepareStatement( - "SELECT i_price, i_name , i_data FROM benchmarksql.item WHERE i_id = ?"); + "SELECT i_price, i_name , i_data FROM " + schema + "item WHERE i_id = ?"); } stmtGetItem.setInt(1, ol_i_id); @@ -986,7 +989,7 @@ private void orderStatusTransaction(int w_id, int d_id, int c_id, String c_last, stmtGetStock = conn.prepareStatement( "SELECT s_quantity, s_data, s_dist_01, s_dist_02, s_dist_03, s_dist_04, s_dist_05, " + " s_dist_06, s_dist_07, s_dist_08, s_dist_09, s_dist_10" + - " FROM benchmarksql.stock WHERE s_i_id = ? AND s_w_id = ? FOR UPDATE"); + " FROM " + schema + "stock WHERE s_i_id = ? AND s_w_id = ? FOR UPDATE"); } stmtGetStock.setInt(1, ol_i_id); @@ -1029,7 +1032,7 @@ private void orderStatusTransaction(int w_id, int d_id, int c_id, String c_last, if (stmtUpdateStock == null) { stmtUpdateStock = conn.prepareStatement( - "UPDATE benchmarksql.stock SET s_quantity = ? , s_ytd = s_ytd + ?, s_remote_cnt = s_remote_cnt + ? " + + "UPDATE " + schema + "stock SET s_quantity = ? , s_ytd = s_ytd + ?, s_remote_cnt = s_remote_cnt + ? " + " WHERE s_i_id = ? AND s_w_id = ?"); } stmtUpdateStock.setInt(1,s_quantity); @@ -1064,7 +1067,7 @@ private void orderStatusTransaction(int w_id, int d_id, int c_id, String c_last, if (stmtInsertOrderLine == null) { stmtInsertOrderLine = conn.prepareStatement( - "INSERT INTO benchmarksql.order_line (ol_o_id, ol_d_id, ol_w_id, ol_number, ol_i_id, ol_supply_w_id," + + "INSERT INTO " + schema + "order_line (ol_o_id, ol_d_id, ol_w_id, ol_number, ol_i_id, ol_supply_w_id," + " ol_quantity, ol_amount, ol_dist_info) VALUES (?,?,?,?,?,?,?,?,?)"); } stmtInsertOrderLine.setInt(1, o_id); @@ -1170,7 +1173,7 @@ private void stockLevelTransaction(int w_id, int d_id, int threshold) if (stockGetDistOrderId == null) { stockGetDistOrderId = conn.prepareStatement( "SELECT d_next_o_id" + - " FROM benchmarksql.district" + + " FROM " + schema + "district" + " WHERE d_w_id = ?" + " AND d_id = ?"); } @@ -1192,7 +1195,7 @@ private void stockLevelTransaction(int w_id, int d_id, int threshold) if (stockGetCountStock == null) { stockGetCountStock = conn.prepareStatement( "SELECT COUNT(DISTINCT (s_i_id)) AS stock_count" + - " FROM benchmarksql.order_line, benchmarksql.stock" + + " FROM " + schema + "order_line, " + schema + "stock" + " WHERE ol_w_id = ?" + " AND ol_d_id = ?" + " AND ol_o_id < ?" + @@ -1257,7 +1260,7 @@ private void paymentTransaction(int w_id, int c_w_id, float h_amount, int d_id, if (payUpdateWhse == null) { payUpdateWhse = conn.prepareStatement( - "UPDATE benchmarksql.warehouse SET w_ytd = w_ytd + ? WHERE w_id = ? "); + "UPDATE " + schema + "warehouse SET w_ytd = w_ytd + ? WHERE w_id = ? "); } payUpdateWhse.setFloat(1,h_amount); @@ -1271,7 +1274,7 @@ private void paymentTransaction(int w_id, int c_w_id, float h_amount, int d_id, if (payGetWhse == null) { payGetWhse = conn.prepareStatement( "SELECT w_street_1, w_street_2, w_city, w_state, w_zip, w_name" + - " FROM benchmarksql.warehouse WHERE w_id = ?"); + " FROM " + schema + "warehouse WHERE w_id = ?"); } payGetWhse.setInt(1, w_id); @@ -1292,7 +1295,7 @@ private void paymentTransaction(int w_id, int c_w_id, float h_amount, int d_id, if (payUpdateDist == null) { payUpdateDist = conn.prepareStatement( - "UPDATE benchmarksql.district SET d_ytd = d_ytd + ? WHERE d_w_id = ? AND d_id = ?"); + "UPDATE " + schema + "district SET d_ytd = d_ytd + ? WHERE d_w_id = ? AND d_id = ?"); } payUpdateDist.setFloat(1, h_amount); payUpdateDist.setInt(2, w_id); @@ -1305,7 +1308,7 @@ private void paymentTransaction(int w_id, int c_w_id, float h_amount, int d_id, if (payGetDist == null) { payGetDist = conn.prepareStatement( "SELECT d_street_1, d_street_2, d_city, d_state, d_zip, d_name" + - " FROM benchmarksql.district WHERE d_w_id = ? AND d_id = ?"); + " FROM " + schema + "district WHERE d_w_id = ? AND d_id = ?"); } payGetDist.setInt(1, w_id); @@ -1330,7 +1333,7 @@ private void paymentTransaction(int w_id, int c_w_id, float h_amount, int d_id, if (payCountCust == null) { //"SELECT count(c_id)) AS namecnt FROM customer " + payCountCust = conn.prepareStatement( - "SELECT count(*) AS namecnt FROM benchmarksql.customer " + + "SELECT count(*) AS namecnt FROM " + schema + "customer " + " WHERE c_last = ? AND c_d_id = ? AND c_w_id = ?"); } @@ -1354,7 +1357,7 @@ private void paymentTransaction(int w_id, int c_w_id, float h_amount, int d_id, payCursorCustByName = conn.prepareStatement( "SELECT c_first, c_middle, c_id, c_street_1, c_street_2, c_city, c_state, c_zip," + " c_phone, c_credit, c_credit_lim, c_discount, c_balance, c_since " + - " FROM benchmarksql.customer WHERE c_w_id = ? AND c_d_id = ? AND c_last = ? " + + " FROM " + schema + "customer WHERE c_w_id = ? AND c_d_id = ? AND c_last = ? " + "ORDER BY c_w_id, c_d_id, c_last, c_first "); } @@ -1392,7 +1395,7 @@ private void paymentTransaction(int w_id, int c_w_id, float h_amount, int d_id, payGetCust = conn.prepareStatement( "SELECT c_first, c_middle, c_last, c_street_1, c_street_2, c_city, c_state, c_zip," + " c_phone, c_credit, c_credit_lim, c_discount, c_balance, c_since " + - " FROM benchmarksql.customer WHERE c_w_id = ? AND c_d_id = ? AND c_id = ?"); + " FROM " + schema + "customer WHERE c_w_id = ? AND c_d_id = ? AND c_id = ?"); } payGetCust.setInt(1, c_w_id); @@ -1429,7 +1432,7 @@ private void paymentTransaction(int w_id, int c_w_id, float h_amount, int d_id, if (payGetCustCdata == null) { payGetCustCdata = conn.prepareStatement( - "SELECT c_data FROM benchmarksql.customer WHERE c_w_id = ? AND c_d_id = ? AND c_id = ?"); + "SELECT c_data FROM " + schema + "customer WHERE c_w_id = ? AND c_d_id = ? AND c_id = ?"); } payGetCustCdata.setInt(1, c_w_id); @@ -1455,7 +1458,7 @@ private void paymentTransaction(int w_id, int c_w_id, float h_amount, int d_id, if (payUpdateCustBalCdata == null) { payUpdateCustBalCdata = conn.prepareStatement( - "UPDATE benchmarksql.customer SET c_balance = ?, c_data = ? " + + "UPDATE " + schema + "customer SET c_balance = ?, c_data = ? " + " WHERE c_w_id = ? AND c_d_id = ? AND c_id = ?"); } payUpdateCustBalCdata.setFloat(1, c_balance); @@ -1475,7 +1478,7 @@ private void paymentTransaction(int w_id, int c_w_id, float h_amount, int d_id, if (payUpdateCustBal == null) { payUpdateCustBal = conn.prepareStatement( - "UPDATE benchmarksql.customer SET c_balance = ? WHERE c_w_id = ? AND c_d_id = ? AND c_id = ?"); + "UPDATE " + schema + "customer SET c_balance = ? WHERE c_w_id = ? AND c_d_id = ? AND c_id = ?"); } payUpdateCustBal.setFloat(1, c_balance); @@ -1498,7 +1501,7 @@ private void paymentTransaction(int w_id, int c_w_id, float h_amount, int d_id, if (payInsertHist == null) { payInsertHist = conn.prepareStatement( - "INSERT INTO benchmarksql.history (h_c_d_id, h_c_w_id, h_c_id, h_d_id, h_w_id, h_date, h_amount, h_data) " + + "INSERT INTO " + schema + "history (h_c_d_id, h_c_w_id, h_c_id, h_d_id, h_w_id, h_date, h_amount, h_data) " + " VALUES (?,?,?,?,?,?,?,?)"); } payInsertHist.setInt(1, c_d_id); diff --git a/src/jdbc/ExecJDBC.java b/src/jdbc/ExecJDBC.java index cd64550..c610127 100755 --- a/src/jdbc/ExecJDBC.java +++ b/src/jdbc/ExecJDBC.java @@ -9,6 +9,7 @@ import java.io.*; import java.sql.*; import java.util.*; +import java.util.regex.Pattern; public class ExecJDBC { @@ -38,9 +39,10 @@ public static void main(String[] args) { stmt = conn.createStatement(); // Open inputFile - BufferedReader in = new BufferedReader - (new FileReader(jTPCCUtil.getSysProp("commandFile",null))); - + BufferedReader in = new BufferedReader(new FileReader(jTPCCUtil.getSysProp("commandFile",null))); + + char term = ';'; + // loop thru input file and concatenate SQL statement fragments while((rLine = in.readLine()) != null) { @@ -51,9 +53,13 @@ public static void main(String[] args) { System.out.println(line); // print comment line } else { sql.append(line); - if (line.endsWith(";")) { - execJDBC(stmt, sql); - sql = new StringBuffer(); + if (line.endsWith(String.valueOf(term))) { + if (line.startsWith("set term")) { + term = line.charAt(9); + } else { + execJDBC(stmt, sql, term); + } + sql = new StringBuffer(); } else { sql.append("\n"); } @@ -88,13 +94,13 @@ public static void main(String[] args) { } // end main - static void execJDBC(Statement stmt, StringBuffer sql) { + static void execJDBC(Statement stmt, StringBuffer sql, char term) { System.out.println(sql); try { - stmt.execute(sql.toString().replace(';',' ')); + stmt.execute(sql.toString().replace(term,' ')); }catch(SQLException se) { System.out.println(se.getMessage());