#At file:///Users/mz/mysql/ndb-7.1-dbg64/ based on revid:martin.zaun@stripped
4237 Martin Zaun 2011-06-07
crund - initial support for new indy|each|bulk execution modes
modified:
storage/ndb/test/crund/config_samples/crundRun.properties
storage/ndb/test/crund/src/com/mysql/cluster/crund/CrundDriver.java
storage/ndb/test/crund/src/com/mysql/cluster/crund/JdbcLoad.java
=== modified file 'storage/ndb/test/crund/config_samples/crundRun.properties'
--- a/storage/ndb/test/crund/config_samples/crundRun.properties 2011-06-07 14:12:24 +0000
+++ b/storage/ndb/test/crund/config_samples/crundRun.properties 2011-06-07 17:12:16 +0000
@@ -13,12 +13,15 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-# the benchmark's metrics: measure time, memory use
-logRealTime=true
-logCpuTime=true
-logMemUsage=false
-includeFullGC=false
-logSumOfOps=true
+# the number of warmup and finally recorded runs
+nRuns=1
+#nRuns=20
+
+# the pattern/execution modes to be run
+#xMode=
+#xMode=INDY
+#xMode=INDY,BULK
+xMode=INDY,EACH,BULK
# optional number of ops per transaction with a scale factor
#nOpsStart=4
@@ -43,6 +46,13 @@ maxVarcharChars=100
maxBlobBytes=100000
maxTextChars=100000
+# the benchmark's metrics: measure time, memory use
+logRealTime=true
+logCpuTime=true
+logMemUsage=false
+includeFullGC=false
+logSumOfOps=true
+
# whether operations or connections are to be renewed after a run
renewOperations=false
renewConnection=false
@@ -50,10 +60,6 @@ renewConnection=false
# whether data objects can be cached/reused after a transaction
allowExtendedPC=false
-# the number of warmup and finally recorded runs
-nRuns=1
-#nRuns=20
-
# CURRENT LIMITS:
#
# ndbd errors (increase SendBufferMemory) at:
=== modified file 'storage/ndb/test/crund/src/com/mysql/cluster/crund/CrundDriver.java'
--- a/storage/ndb/test/crund/src/com/mysql/cluster/crund/CrundDriver.java 2011-06-07 14:12:24 +0000
+++ b/storage/ndb/test/crund/src/com/mysql/cluster/crund/CrundDriver.java 2011-06-07 17:12:16 +0000
@@ -22,6 +22,7 @@ package com.mysql.cluster.crund;
import java.util.Properties;
import java.util.List;
import java.util.Set;
+import java.util.EnumSet;
import java.util.HashSet;
import java.util.ArrayList;
import java.util.Date;
@@ -33,7 +34,6 @@ import java.io.IOException;
import java.io.PrintWriter;
import java.io.InputStream;
-
/**
* This class benchmarks standard database operations over a series
* of transactions on an increasing data set.
@@ -55,7 +55,10 @@ import java.io.InputStream;
*/
abstract public class CrundDriver extends Driver {
+ enum XMode { INDY, EACH, BULK }
+
// benchmark settings
+ protected final EnumSet< XMode > xMode = EnumSet.noneOf(XMode.class);
protected boolean renewConnection;
protected boolean renewOperations;
protected boolean logSumOfOps;
@@ -140,6 +143,13 @@ abstract public class CrundDriver extend
final StringBuilder msg = new StringBuilder();
final String eol = System.getProperty("line.separator");
+ // parse execution modes
+ final String[] xm = props.getProperty("xMode", "").split(",");
+ for (int i = 0; i < xm.length; i++) {
+ if (!"".equals(xm[i]))
+ xMode.add(XMode.valueOf(XMode.class, xm[i]));
+ }
+
renewConnection = parseBoolean("renewConnection", false);
renewOperations = parseBoolean("renewOperations", false);
logSumOfOps = parseBoolean("logSumOfOps", true);
@@ -207,6 +217,7 @@ abstract public class CrundDriver extend
out.println();
out.println("crund settings ...");
+ out.println("xMode: " + xMode);
out.println("renewConnection: " + renewConnection);
out.println("renewOperations: " + renewOperations);
out.println("logSumOfOps: " + logSumOfOps);
=== modified file 'storage/ndb/test/crund/src/com/mysql/cluster/crund/JdbcLoad.java'
--- a/storage/ndb/test/crund/src/com/mysql/cluster/crund/JdbcLoad.java 2011-06-07 14:12:24 +0000
+++ b/storage/ndb/test/crund/src/com/mysql/cluster/crund/JdbcLoad.java 2011-06-07 17:12:16 +0000
@@ -39,7 +39,6 @@ public class JdbcLoad extends CrundDrive
protected String url;
protected String user;
protected String password;
- protected boolean autoCommit;
// JDBC resources
protected Connection conn;
@@ -80,13 +79,6 @@ public class JdbcLoad extends CrundDrive
user = props.getProperty("jdbc.user");
password = props.getProperty("jdbc.password");
- // single ops not supported yet
- autoCommit = parseBoolean("jdbc.autoCommit", false);
- if (autoCommit) {
- msg.append("[ignored] autoCommit: " + autoCommit + eol);
- autoCommit = false;
- }
-
if (msg.length() == 0) {
out.println(" [ok]");
} else {
@@ -107,7 +99,6 @@ public class JdbcLoad extends CrundDrive
out.println("jdbc.url: " + url);
out.println("jdbc.user: \"" + user + "\"");
out.println("jdbc.password: \"" + password + "\"");
- out.println("jdbc.autoCommit: " + autoCommit);
}
protected void initLoad() throws Exception {
@@ -169,62 +160,78 @@ public class JdbcLoad extends CrundDrive
out.print("initializing statements ...");
out.flush();
- for (boolean f = false, done = false; !done; done = f, f = true) {
+/*
+ for (CrundDriver.XMode m : CrundDriver.XMode.values()) {
+ // inner classes can only refer to a constant
+ final CrundDriver.XMode mode = m;
+
+ if (mode == CrundDriver.XMode.INDY && !doIndy)
+ continue;
+ if (mode == CrundDriver.XMode.EACH && !doEach)
+ continue;
+ if (mode == CrundDriver.XMode.BULK && !doBulk)
+ continue;
+*/
+
+ for (CrundDriver.XMode m : xMode) {
// inner classes can only refer to a constant
- final boolean batch = f;
- final boolean ignore = f;
- final boolean setAttrs = true;
+ final CrundDriver.XMode mode = m;
ops.add(
- new JdbcOp("insA" + (batch ? "_batch" : ""),
+ new JdbcOp("insA_" + mode.toString().toLowerCase(),
"INSERT INTO a (id) VALUES (?)") {
public void run(int nOps) throws SQLException {
+ conn.setAutoCommit(mode == CrundDriver.XMode.INDY);
for (int i = 1; i <= nOps; i++) {
stmt.setInt(1, i);
- if (batch) {
+ if (mode == CrundDriver.XMode.BULK) {
stmt.addBatch();
} else {
int cnt = stmt.executeUpdate();
verify(cnt == 1);
}
}
- if (batch) {
+ if (mode == CrundDriver.XMode.BULK) {
int[] cnts = stmt.executeBatch();
for (int i = 0; i < cnts.length; i++) {
verify(cnts[i] == 1);
}
}
- conn.commit();
+ if (mode != CrundDriver.XMode.INDY)
+ conn.commit();
}
});
ops.add(
- new JdbcOp("insB0" + (batch ? "_batch" : ""),
+ new JdbcOp("insB0_" + mode.toString().toLowerCase(),
"INSERT INTO b0 (id) VALUES (?)") {
public void run(int nOps) throws SQLException {
+ conn.setAutoCommit(mode == CrundDriver.XMode.INDY);
for (int i = 1; i <= nOps; i++) {
stmt.setInt(1, i);
- if (batch) {
+ if (mode == CrundDriver.XMode.BULK) {
stmt.addBatch();
} else {
int cnt = stmt.executeUpdate();
verify(cnt == 1);
}
}
- if (batch) {
+ if (mode == CrundDriver.XMode.BULK) {
int[] cnts = stmt.executeBatch();
for (int i = 0; i < cnts.length; i++) {
verify(cnts[i] == 1);
}
}
- conn.commit();
+ if (mode != CrundDriver.XMode.INDY)
+ conn.commit();
}
});
ops.add(
- new JdbcOp("setAByPK" + (batch ? "_batch" : ""),
+ new JdbcOp("setAByPK_" + mode.toString().toLowerCase(),
"UPDATE a a SET a.cint = ?, a.clong = ?, a.cfloat = ?, a.cdouble = ? WHERE (a.id = ?)") {
public void run(int nOps) throws SQLException {
+ conn.setAutoCommit(mode == CrundDriver.XMode.INDY);
for (int i = 1; i <= nOps; i++) {
// refactor by numbered args
stmt.setInt(1, i);
@@ -232,27 +239,29 @@ public class JdbcLoad extends CrundDrive
stmt.setInt(3, i);
stmt.setInt(4, i);
stmt.setInt(5, i);
- if (batch) {
+ if (mode == CrundDriver.XMode.BULK) {
stmt.addBatch();
} else {
int cnt = stmt.executeUpdate();
verify(cnt == 1);
}
}
- if (batch) {
+ if (mode == CrundDriver.XMode.BULK) {
int[] cnts = stmt.executeBatch();
for (int i = 0; i < cnts.length; i++) {
verify(cnts[i] == 1);
}
}
- conn.commit();
+ if (mode != CrundDriver.XMode.INDY)
+ conn.commit();
}
});
ops.add(
- new JdbcOp("setB0ByPK" + (batch ? "_batch" : ""),
+ new JdbcOp("setB0ByPK_" + mode.toString().toLowerCase(),
"UPDATE b0 b0 SET b0.cint = ?, b0.clong = ?, b0.cfloat = ?, b0.cdouble = ? WHERE (b0.id = ?)") {
public void run(int nOps) throws SQLException {
+ conn.setAutoCommit(mode == CrundDriver.XMode.INDY);
for (int i = 1; i <= nOps; i++) {
// refactor by numbered args
stmt.setInt(1, i);
@@ -260,86 +269,63 @@ public class JdbcLoad extends CrundDrive
stmt.setInt(3, i);
stmt.setInt(4, i);
stmt.setInt(5, i);
- if (batch) {
+ if (mode == CrundDriver.XMode.BULK) {
stmt.addBatch();
} else {
int cnt = stmt.executeUpdate();
verify(cnt == 1);
}
}
- if (batch) {
+ if (mode == CrundDriver.XMode.BULK) {
int[] cnts = stmt.executeBatch();
for (int i = 0; i < cnts.length; i++) {
verify(cnts[i] == 1);
}
}
- conn.commit();
+ if (mode != CrundDriver.XMode.INDY)
+ conn.commit();
}
});
ops.add(
- new JdbcOp((batch ? "getAllA_asc" : "getAByPK"),
- "SELECT id, cint, clong, cfloat, cdouble FROM a "
- + (batch ? "ORDER BY id ASC" : "WHERE (id = ?)")) {
+ new JdbcOp("getAByPK_" + mode.toString().toLowerCase(),
+ "SELECT id, cint, clong, cfloat, cdouble FROM a WHERE (id = ?)") {
public void run(int nOps) throws SQLException {
- if (batch) {
+ conn.setAutoCommit(mode == CrundDriver.XMode.INDY);
+ for (int i = 1; i <= nOps; i++) {
+ stmt.setInt(1, i);
ResultSet rs = stmt.executeQuery();
- for (int i = 1; i <= nOps; i++) {
- rs.next();
- final int id = rs.getInt(1);
- verify(id == i);
- final int j = getCommonAttributes(rs);
- verify(j == id);
- }
+ rs.next();
+ final int id = rs.getInt(1);
+ verify(id == i);
+ final int j = getCommonAttributes(rs);
+ verify(j == id);
verify(!rs.next());
rs.close();
- } else {
- for (int i = 1; i <= nOps; i++) {
- stmt.setInt(1, i);
- ResultSet rs = stmt.executeQuery();
- rs.next();
- final int id = rs.getInt(1);
- verify(id == i);
- final int j = getCommonAttributes(rs);
- verify(j == id);
- verify(!rs.next());
- rs.close();
- }
}
- conn.commit();
+ if (mode != CrundDriver.XMode.INDY)
+ conn.commit();
}
});
ops.add(
- new JdbcOp((batch ? "getAllB0_asc" : "getB0ByPK"),
- "SELECT id, cint, clong, cfloat, cdouble FROM b0 "
- + (batch ? "ORDER BY id ASC" : "WHERE (id = ?)")) {
+ new JdbcOp("getB0ByPK_" + mode.toString().toLowerCase(),
+ "SELECT id, cint, clong, cfloat, cdouble FROM b0 WHERE (id = ?)") {
public void run(int nOps) throws SQLException {
- if (batch) {
+ conn.setAutoCommit(mode == CrundDriver.XMode.INDY);
+ for (int i = 1; i <= nOps; i++) {
+ stmt.setInt(1, i);
ResultSet rs = stmt.executeQuery();
- for (int i = 1; i <= nOps; i++) {
- rs.next();
- final int id = rs.getInt(1);
- verify(id == i);
- final int j = getCommonAttributes(rs);
- verify(j == id);
- }
+ rs.next();
+ final int id = rs.getInt(1);
+ verify(id == i);
+ final int j = getCommonAttributes(rs);
+ verify(j == id);
verify(!rs.next());
rs.close();
- } else {
- for (int i = 1; i <= nOps; i++) {
- stmt.setInt(1, i);
- ResultSet rs = stmt.executeQuery();
- rs.next();
- final int id = rs.getInt(1);
- verify(id == i);
- final int j = getCommonAttributes(rs);
- verify(j == id);
- verify(!rs.next());
- rs.close();
- }
}
- conn.commit();
+ if (mode != CrundDriver.XMode.INDY)
+ conn.commit();
}
});
@@ -348,35 +334,36 @@ public class JdbcLoad extends CrundDrive
assert l == b.length;
ops.add(
- new JdbcOp("setVarbinary" + l + (batch ? "_batch" : ""),
+ new JdbcOp("setVarbinary" + l + "_" + mode.toString().toLowerCase(),
"UPDATE b0 b0 SET b0.cvarbinary_def = ? WHERE (b0.id = ?)") {
- public void run(int nOps)
- throws SQLException {
+ public void run(int nOps) throws SQLException {
+ conn.setAutoCommit(mode == CrundDriver.XMode.INDY);
for (int i = 1; i <= nOps; i++) {
stmt.setBytes(1, b);
stmt.setInt(2, i);
- if (batch) {
+ if (mode == CrundDriver.XMode.BULK) {
stmt.addBatch();
} else {
int cnt = stmt.executeUpdate();
verify(cnt == 1);
}
}
- if (batch) {
+ if (mode == CrundDriver.XMode.BULK) {
int[] cnts = stmt.executeBatch();
for (int i = 0; i < cnts.length; i++) {
verify(cnts[i] == 1);
}
}
- conn.commit();
+ if (mode != CrundDriver.XMode.INDY)
+ conn.commit();
}
});
ops.add(
- new JdbcOp("getVarbinary" + l,
+ new JdbcOp("getVarbinary" + l + "_" + mode.toString().toLowerCase(),
"SELECT cvarbinary_def FROM b0 WHERE (id = ?)") {
- public void run(int nOps)
- throws SQLException {
+ public void run(int nOps) throws SQLException {
+ conn.setAutoCommit(mode == CrundDriver.XMode.INDY);
for (int i = 1; i <= nOps; i++) {
stmt.setInt(1, i);
ResultSet rs = stmt.executeQuery();
@@ -386,31 +373,33 @@ public class JdbcLoad extends CrundDrive
verify(!rs.next());
rs.close();
}
- conn.commit();
+ if (mode != CrundDriver.XMode.INDY)
+ conn.commit();
}
});
ops.add(
- new JdbcOp("clearVarbinary" + l + (batch ? "_batch" : ""),
+ new JdbcOp("clearVarbinary" + l + "_" + mode.toString().toLowerCase(),
"UPDATE b0 b0 SET b0.cvarbinary_def = NULL WHERE (b0.id = ?)") {
- public void run(int nOps)
- throws SQLException {
+ public void run(int nOps) throws SQLException {
+ conn.setAutoCommit(mode == CrundDriver.XMode.INDY);
for (int i = 1; i <= nOps; i++) {
stmt.setInt(1, i);
- if (batch) {
+ if (mode == CrundDriver.XMode.BULK) {
stmt.addBatch();
} else {
int cnt = stmt.executeUpdate();
verify(cnt == 1);
}
}
- if (batch) {
+ if (mode == CrundDriver.XMode.BULK) {
int[] cnts = stmt.executeBatch();
for (int i = 0; i < cnts.length; i++) {
verify(cnts[i] == 1);
}
}
- conn.commit();
+ if (mode != CrundDriver.XMode.INDY)
+ conn.commit();
}
});
}
@@ -420,35 +409,36 @@ public class JdbcLoad extends CrundDrive
assert l == s.length();
ops.add(
- new JdbcOp("setVarchar" + l + (batch ? "_batch" : ""),
+ new JdbcOp("setVarchar" + l + "_" + mode.toString().toLowerCase(),
"UPDATE b0 b0 SET b0.cvarchar_def = ? WHERE (b0.id = ?)") {
- public void run(int nOps)
- throws SQLException {
+ public void run(int nOps) throws SQLException {
+ conn.setAutoCommit(mode == CrundDriver.XMode.INDY);
for (int i = 1; i <= nOps; i++) {
stmt.setString(1, s);
stmt.setInt(2, i);
- if (batch) {
+ if (mode == CrundDriver.XMode.BULK) {
stmt.addBatch();
} else {
int cnt = stmt.executeUpdate();
verify(cnt == 1);
}
}
- if (batch) {
+ if (mode == CrundDriver.XMode.BULK) {
int[] cnts = stmt.executeBatch();
for (int i = 0; i < cnts.length; i++) {
verify(cnts[i] == 1);
}
}
- conn.commit();
+ if (mode != CrundDriver.XMode.INDY)
+ conn.commit();
}
});
ops.add(
- new JdbcOp("getVarchar" + l,
+ new JdbcOp("getVarchar" + l + "_" + mode.toString().toLowerCase(),
"SELECT cvarchar_def FROM b0 WHERE (id = ?)") {
- public void run(int nOps)
- throws SQLException {
+ public void run(int nOps) throws SQLException {
+ conn.setAutoCommit(mode == CrundDriver.XMode.INDY);
for (int i = 1; i <= nOps; i++) {
stmt.setInt(1, i);
ResultSet rs = stmt.executeQuery();
@@ -458,31 +448,33 @@ public class JdbcLoad extends CrundDrive
verify(!rs.next());
rs.close();
}
- conn.commit();
+ if (mode != CrundDriver.XMode.INDY)
+ conn.commit();
}
});
ops.add(
- new JdbcOp("clearVarchar" + l + (batch ? "_batch" : ""),
+ new JdbcOp("clearVarchar" + l + "_" + mode.toString().toLowerCase(),
"UPDATE b0 b0 SET b0.cvarchar_def = NULL WHERE (b0.id = ?)") {
- public void run(int nOps)
- throws SQLException {
+ public void run(int nOps) throws SQLException {
+ conn.setAutoCommit(mode == CrundDriver.XMode.INDY);
for (int i = 1; i <= nOps; i++) {
stmt.setInt(1, i);
- if (batch) {
+ if (mode == CrundDriver.XMode.BULK) {
stmt.addBatch();
} else {
int cnt = stmt.executeUpdate();
verify(cnt == 1);
}
}
- if (batch) {
+ if (mode == CrundDriver.XMode.BULK) {
int[] cnts = stmt.executeBatch();
for (int i = 0; i < cnts.length; i++) {
verify(cnts[i] == 1);
}
}
- conn.commit();
+ if (mode != CrundDriver.XMode.INDY)
+ conn.commit();
}
});
}
@@ -493,35 +485,36 @@ public class JdbcLoad extends CrundDrive
assert l == b.length;
ops.add(
- new JdbcOp("setBlob" + l + (batch ? "_batch" : ""),
+ new JdbcOp("setBlob" + l + "_" + mode.toString().toLowerCase(),
"UPDATE b0 b0 SET b0.cblob_def = ? WHERE (b0.id = ?)") {
- public void run(int nOps)
- throws SQLException {
+ public void run(int nOps) throws SQLException {
+ conn.setAutoCommit(mode == CrundDriver.XMode.INDY);
for (int i = 1; i <= nOps; i++) {
stmt.setBytes(1, b);
stmt.setInt(2, i);
- if (batch) {
+ if (mode == CrundDriver.XMode.BULK) {
stmt.addBatch();
} else {
int cnt = stmt.executeUpdate();
verify(cnt == 1);
}
}
- if (batch) {
+ if (mode == CrundDriver.XMode.BULK) {
int[] cnts = stmt.executeBatch();
for (int i = 0; i < cnts.length; i++) {
verify(cnts[i] == 1);
}
}
- conn.commit();
+ if (mode != CrundDriver.XMode.INDY)
+ conn.commit();
}
});
ops.add(
- new JdbcOp("getBlob" + l,
+ new JdbcOp("getBlob" + l + "_" + mode.toString().toLowerCase(),
"SELECT cblob_def FROM b0 WHERE (id = ?)") {
- public void run(int nOps)
- throws SQLException {
+ public void run(int nOps) throws SQLException {
+ conn.setAutoCommit(mode == CrundDriver.XMode.INDY);
for (int i = 1; i <= nOps; i++) {
stmt.setInt(1, i);
ResultSet rs = stmt.executeQuery();
@@ -531,7 +524,8 @@ public class JdbcLoad extends CrundDrive
verify(!rs.next());
rs.close();
}
- conn.commit();
+ if (mode != CrundDriver.XMode.INDY)
+ conn.commit();
}
});
}
@@ -543,35 +537,36 @@ public class JdbcLoad extends CrundDrive
assert l == s.length();
ops.add(
- new JdbcOp("setText" + l + (batch ? "_batch" : ""),
+ new JdbcOp("setText" + l + "_" + mode.toString().toLowerCase(),
"UPDATE b0 b0 SET b0.ctext_def = ? WHERE (b0.id = ?)") {
- public void run(int nOps)
- throws SQLException {
+ public void run(int nOps) throws SQLException {
+ conn.setAutoCommit(mode == CrundDriver.XMode.INDY);
for (int i = 1; i <= nOps; i++) {
stmt.setString(1, s);
stmt.setInt(2, i);
- if (batch) {
+ if (mode == CrundDriver.XMode.BULK) {
stmt.addBatch();
} else {
int cnt = stmt.executeUpdate();
verify(cnt == 1);
}
}
- if (batch) {
+ if (mode == CrundDriver.XMode.BULK) {
int[] cnts = stmt.executeBatch();
for (int i = 0; i < cnts.length; i++) {
verify(cnts[i] == 1);
}
}
- conn.commit();
+ if (mode != CrundDriver.XMode.INDY)
+ conn.commit();
}
});
ops.add(
- new JdbcOp("getText" + l,
+ new JdbcOp("getText" + l + "_" + mode.toString().toLowerCase(),
"SELECT ctext_def FROM b0 WHERE (id = ?)") {
- public void run(int nOps)
- throws SQLException {
+ public void run(int nOps) throws SQLException {
+ conn.setAutoCommit(mode == CrundDriver.XMode.INDY);
for (int i = 1; i <= nOps; i++) {
stmt.setInt(1, i);
ResultSet rs = stmt.executeQuery();
@@ -581,41 +576,45 @@ public class JdbcLoad extends CrundDrive
verify(!rs.next());
rs.close();
}
- conn.commit();
+ if (mode != CrundDriver.XMode.INDY)
+ conn.commit();
}
});
}
}
ops.add(
- new JdbcOp("setB0->A" + (batch ? "_batch" : ""),
+ new JdbcOp("setB0->A_" + mode.toString().toLowerCase(),
"UPDATE b0 b0 SET b0.a_id = ? WHERE (b0.id = ?)") {
public void run(int nOps) throws SQLException {
+ conn.setAutoCommit(mode == CrundDriver.XMode.INDY);
for (int i = 1; i <= nOps; i++) {
int aId = ((i - 1) % nOps) + 1;
stmt.setInt(1, aId);
stmt.setInt(2, i);
- if (batch) {
+ if (mode == CrundDriver.XMode.BULK) {
stmt.addBatch();
} else {
int cnt = stmt.executeUpdate();
verify(cnt == 1);
}
}
- if (batch) {
+ if (mode == CrundDriver.XMode.BULK) {
int[] cnts = stmt.executeBatch();
for (int i = 0; i < cnts.length; i++) {
verify(cnts[i] == 1);
}
}
- conn.commit();
+ if (mode != CrundDriver.XMode.INDY)
+ conn.commit();
}
});
ops.add(
- new JdbcOp("navB0->A_subsel",
+ new JdbcOp("navB0->A_subsel_" + mode.toString().toLowerCase(),
"SELECT id, cint, clong, cfloat, cdouble FROM a WHERE id = (SELECT b0.a_id FROM b0 b0 WHERE b0.id = ?)") {
public void run(int nOps) throws SQLException {
+ conn.setAutoCommit(mode == CrundDriver.XMode.INDY);
for (int i = 1; i <= nOps; i++) {
stmt.setInt(1, i);
ResultSet rs = stmt.executeQuery();
@@ -627,14 +626,16 @@ public class JdbcLoad extends CrundDrive
verify(!rs.next());
rs.close();
}
- conn.commit();
+ if (mode != CrundDriver.XMode.INDY)
+ conn.commit();
}
});
ops.add(
- new JdbcOp("navB0->A_joinproj",
+ new JdbcOp("navB0->A_joinproj_" + mode.toString().toLowerCase(),
"SELECT a.id, a.cint, a.clong, a.cfloat, a.cdouble FROM a a, b0 b0 WHERE (a.id = b0.a_id AND b0.id = ?)") {
public void run(int nOps) throws SQLException {
+ conn.setAutoCommit(mode == CrundDriver.XMode.INDY);
for (int i = 1; i <= nOps; i++) {
stmt.setInt(1, i);
ResultSet rs = stmt.executeQuery();
@@ -646,12 +647,13 @@ public class JdbcLoad extends CrundDrive
verify(!rs.next());
rs.close();
}
- conn.commit();
+ if (mode != CrundDriver.XMode.INDY)
+ conn.commit();
}
});
ops.add(
- new JdbcOp("navB0->A_2stmts",
+ new JdbcOp("navB0->A_2stmts_" + mode.toString().toLowerCase(),
"SELECT id, cint, clong, cfloat, cdouble FROM a WHERE id = ?") {
protected PreparedStatement stmt0;
@@ -668,6 +670,7 @@ public class JdbcLoad extends CrundDrive
}
public void run(int nOps) throws SQLException {
+ conn.setAutoCommit(mode == CrundDriver.XMode.INDY);
for (int i = 1; i <= nOps; i++) {
// fetch a.id
stmt0.setInt(1, i);
@@ -688,14 +691,16 @@ public class JdbcLoad extends CrundDrive
verify(!rs.next());
rs.close();
}
- conn.commit();
+ if (mode != CrundDriver.XMode.INDY)
+ conn.commit();
}
});
ops.add(
- new JdbcOp("navA->B0",
+ new JdbcOp("navA->B0_" + mode.toString().toLowerCase(),
"SELECT id, cint, clong, cfloat, cdouble FROM b0 WHERE (a_id = ?)") {
public void run(int nOps) throws SQLException {
+ conn.setAutoCommit(mode == CrundDriver.XMode.INDY);
int cnt = 0;
for (int i = 1; i <= nOps; i++) {
stmt.setInt(1, i);
@@ -710,146 +715,161 @@ public class JdbcLoad extends CrundDrive
rs.close();
}
verify(cnt == nOps);
- conn.commit();
+ if (mode != CrundDriver.XMode.INDY)
+ conn.commit();
}
});
ops.add(
- new JdbcOp("nullB0->A" + (batch ? "_batch" : ""),
+ new JdbcOp("nullB0->A_" + mode.toString().toLowerCase(),
"UPDATE b0 b0 SET b0.a_id = NULL WHERE (b0.id = ?)") {
public void run(int nOps) throws SQLException {
+ conn.setAutoCommit(mode == CrundDriver.XMode.INDY);
for (int i = 1; i <= nOps; i++) {
stmt.setInt(1, i);
- if (batch) {
+ if (mode == CrundDriver.XMode.BULK) {
stmt.addBatch();
} else {
int cnt = stmt.executeUpdate();
verify(cnt == 1);
}
}
- if (batch) {
+ if (mode == CrundDriver.XMode.BULK) {
int[] cnts = stmt.executeBatch();
for (int i = 0; i < cnts.length; i++) {
verify(cnts[i] == 1);
}
}
- conn.commit();
+ if (mode != CrundDriver.XMode.INDY)
+ conn.commit();
}
});
ops.add(
// MySQL rejects this syntax: "DELETE FROM b0 b0 WHERE b0.id = ?"
- new JdbcOp("delB0ByPK" + (batch ? "_batch" : ""),
+ new JdbcOp("delB0ByPK_" + mode.toString().toLowerCase(),
"DELETE FROM b0 WHERE id = ?") {
public void run(int nOps) throws SQLException {
+ conn.setAutoCommit(mode == CrundDriver.XMode.INDY);
for (int i = 1; i <= nOps; i++) {
stmt.setInt(1, i);
- if (batch) {
+ if (mode == CrundDriver.XMode.BULK) {
stmt.addBatch();
} else {
int cnt = stmt.executeUpdate();
verify(cnt == 1);
}
}
- if (batch) {
+ if (mode == CrundDriver.XMode.BULK) {
int[] cnts = stmt.executeBatch();
for (int i = 0; i < cnts.length; i++) {
verify(cnts[i] == 1);
}
}
- conn.commit();
+ if (mode != CrundDriver.XMode.INDY)
+ conn.commit();
}
});
ops.add(
// MySQL rejects this syntax: "DELETE FROM a a WHERE a.id = ?"
- new JdbcOp("delAByPK" + (batch ? "_batch" : ""),
+ new JdbcOp("delAByPK_" + mode.toString().toLowerCase(),
"DELETE FROM a WHERE id = ?") {
public void run(int nOps) throws SQLException {
+ conn.setAutoCommit(mode == CrundDriver.XMode.INDY);
for (int i = 1; i <= nOps; i++) {
stmt.setInt(1, i);
- if (batch) {
+ if (mode == CrundDriver.XMode.BULK) {
stmt.addBatch();
} else {
int cnt = stmt.executeUpdate();
verify(cnt == 1);
}
}
- if (batch) {
+ if (mode == CrundDriver.XMode.BULK) {
int[] cnts = stmt.executeBatch();
for (int i = 0; i < cnts.length; i++) {
verify(cnts[i] == 1);
}
}
- conn.commit();
+ if (mode != CrundDriver.XMode.INDY)
+ conn.commit();
}
});
ops.add(
- new JdbcOp("insA_attr" + (batch ? "_batch" : ""),
+ new JdbcOp("insA_attr_" + mode.toString().toLowerCase(),
"INSERT INTO a (id, cint, clong, cfloat, cdouble) VALUES (?, ?, ?, ?, ?)") {
public void run(int nOps) throws SQLException {
+ conn.setAutoCommit(mode == CrundDriver.XMode.INDY);
for (int i = 1; i <= nOps; i++) {
stmt.setInt(1, i);
setCommonAttributes(stmt, -i);
- if (batch) {
+ if (mode == CrundDriver.XMode.BULK) {
stmt.addBatch();
} else {
int cnt = stmt.executeUpdate();
verify(cnt == 1);
}
}
- if (batch) {
+ if (mode == CrundDriver.XMode.BULK) {
int[] cnts = stmt.executeBatch();
for (int i = 0; i < cnts.length; i++) {
verify(cnts[i] == 1);
}
}
- conn.commit();
+ if (mode != CrundDriver.XMode.INDY)
+ conn.commit();
}
});
ops.add(
- new JdbcOp("insB0_attr" + (batch ? "_batch" : ""),
+ new JdbcOp("insB0_attr_" + mode.toString().toLowerCase(),
"INSERT INTO b0 (id, cint, clong, cfloat, cdouble) VALUES (?, ?, ?, ?, ?)") {
public void run(int nOps) throws SQLException {
+ conn.setAutoCommit(mode == CrundDriver.XMode.INDY);
for (int i = 1; i <= nOps; i++) {
stmt.setInt(1, i);
setCommonAttributes(stmt, -i);
- if (batch) {
+ if (mode == CrundDriver.XMode.BULK) {
stmt.addBatch();
} else {
int cnt = stmt.executeUpdate();
verify(cnt == 1);
}
}
- if (batch) {
+ if (mode == CrundDriver.XMode.BULK) {
int[] cnts = stmt.executeBatch();
for (int i = 0; i < cnts.length; i++) {
verify(cnts[i] == 1);
}
}
- conn.commit();
+ if (mode != CrundDriver.XMode.INDY)
+ conn.commit();
}
});
ops.add(
- new JdbcOp("delAllB0",
+ new JdbcOp("delAllB0_" + mode.toString().toLowerCase(),
"DELETE FROM b0") {
public void run(int nOps) throws SQLException {
+ conn.setAutoCommit(mode == CrundDriver.XMode.INDY);
int cnt = stmt.executeUpdate();
verify(cnt == nOps);
- conn.commit();
+ if (mode != CrundDriver.XMode.INDY)
+ conn.commit();
}
});
ops.add(
- new JdbcOp("delAllA",
+ new JdbcOp("delAllA_" + mode.toString().toLowerCase(),
"DELETE FROM a") {
public void run(int nOps) throws SQLException {
+ conn.setAutoCommit(mode == CrundDriver.XMode.INDY);
int cnt = stmt.executeUpdate();
verify(cnt == nOps);
- conn.commit();
+ if (mode != CrundDriver.XMode.INDY)
+ conn.commit();
}
});
}
@@ -877,19 +897,54 @@ public class JdbcLoad extends CrundDrive
// ----------------------------------------------------------------------
protected void initConnection() throws SQLException {
+ assert (conn == null);
+
+ out.println();
+ out.println("initializing jdbc resources ...");
+
out.println();
- out.print("creating JDBC connection ...");
+ out.print("creating jdbc connection ...");
out.flush();
conn = DriverManager.getConnection(url, user, password);
- conn.setAutoCommit(autoCommit);
+ // XXX remove this default when fully implemented all of XMode
+ conn.setAutoCommit(false);
delAllA = conn.prepareStatement("DELETE FROM a");
delAllB0 = conn.prepareStatement("DELETE FROM b0");
- out.println(" [Conn: 1]");
+ out.println(" [ok: " + url + "]");
+
+ out.print("setting isolation level ...");
+ out.flush();
+ // ndb storage engine only supports READ_COMMITTED
+ final int il = Connection.TRANSACTION_READ_COMMITTED;
+ conn.setTransactionIsolation(il);
+ out.print(" [ok: ");
+ switch (conn.getTransactionIsolation()) {
+ case Connection.TRANSACTION_READ_UNCOMMITTED:
+ out.print("READ_UNCOMMITTED");
+ break;
+ case Connection.TRANSACTION_READ_COMMITTED:
+ out.print("READ_COMMITTED");
+ break;
+ case Connection.TRANSACTION_REPEATABLE_READ:
+ out.print("REPEATABLE_READ");
+ break;
+ case Connection.TRANSACTION_SERIALIZABLE:
+ out.print("SERIALIZABLE");
+ break;
+ default:
+ assert false;
+ }
+ out.println("]");
}
protected void closeConnection() throws SQLException {
+ assert (conn != null);
+
+ out.println();
+ out.println("releasing jdbc resources ...");
+
out.println();
- out.print("closing JDBC connection ...");
+ out.print("closing jdbc connection ...");
out.flush();
if (delAllB0 != null)
delAllB0.close();
@@ -908,6 +963,7 @@ public class JdbcLoad extends CrundDrive
}
protected void clearData() throws SQLException {
+ conn.setAutoCommit(false);
out.print("deleting all rows ...");
out.flush();
int delB0 = delAllB0.executeUpdate();
Attachment: [text/bzr-bundle] bzr/martin.zaun@oracle.com-20110607171216-vn36tov1r3do77ua.bundle
| Thread |
|---|
| • bzr commit into mysql-5.1-telco-7.1 branch (martin.zaun:4237) | Martin Zaun | 7 Jun |