20 package com.mysql.cluster.benchmark.tws;
23 import com.mysql.clusterj.LockMode;
29 protected boolean renewConnection;
30 protected boolean doJdbc;
31 protected boolean doClusterj;
32 protected boolean doNdbjtie;
33 protected boolean doInsert;
34 protected boolean doLookup;
35 protected boolean doUpdate;
36 protected boolean doDelete;
37 protected boolean doSingle;
38 protected boolean doBulk;
39 protected boolean doBatch;
45 protected TwsLoad jdbcLoad;
46 protected TwsLoad clusterjLoad;
47 protected TwsLoad ndbjtieLoad;
50 System.setProperty(
"java.util.logging.config.file",
"run.properties");
53 static public void main(
String[] args)
throws Exception {
63 protected void init()
throws Exception {
67 assert (ndbjtieLoad == null);
68 ndbjtieLoad =
new NdbjtieLoad(
this);
70 ndbjtieLoad.initConnection();
73 assert (jdbcLoad == null);
74 jdbcLoad =
new JdbcLoad(
this, ndbjtieLoad.getMetaData());
76 jdbcLoad.initConnection();
79 assert (clusterjLoad == null);
80 clusterjLoad =
new ClusterjLoad(
this, ndbjtieLoad.getMetaData());
82 clusterjLoad.initConnection();
87 protected void close()
throws Exception {
91 assert (jdbcLoad != null);
96 assert (clusterjLoad != null);
101 assert (ndbjtieLoad != null);
109 protected void initProperties() {
110 super.initProperties();
112 out.print(
"setting tws properties ...");
114 final StringBuilder
msg =
new StringBuilder();
115 final String eol = System.getProperty(
"line.separator");
117 renewConnection = parseBoolean(
"renewConnection",
false);
118 doJdbc = parseBoolean(
"doJdbc",
false);
119 doClusterj = parseBoolean(
"doClusterj",
false);
120 doNdbjtie = parseBoolean(
"doNdbjtie",
false);
121 doInsert = parseBoolean(
"doInsert",
false);
122 doLookup = parseBoolean(
"doLookup",
false);
123 doUpdate = parseBoolean(
"doUpdate",
false);
124 doDelete = parseBoolean(
"doDelete",
false);
125 doSingle = parseBoolean(
"doSingle",
false);
126 doBulk = parseBoolean(
"doBulk",
false);
127 doBatch = parseBoolean(
"doBatch",
false);
129 final String lm = props.getProperty(
"lockMode");
131 lockMode = (lm == null
133 }
catch (IllegalArgumentException e) {
134 msg.append(
"[ignored] lockMode: " + lm + eol);
138 nRows = parseInt(
"nRows", 256);
140 msg.append(
"[ignored] nRows: '"
141 + props.getProperty(
"nRows") +
"'" + eol);
145 nRuns = parseInt(
"nRuns", 1);
147 msg.append(
"[ignored] nRuns: " + nRuns + eol);
151 if (msg.length() == 0) {
152 out.println(
" [ok]");
155 out.print(msg.toString());
159 protected void printProperties() {
160 super.printProperties();
162 out.println(
"tws settings ...");
163 out.println(
"renewConnection: " + renewConnection);
164 out.println(
"doJdbc: " + doJdbc);
165 out.println(
"doClusterj: " + doClusterj);
166 out.println(
"doNdbjtie: " + doNdbjtie);
167 out.println(
"doInsert: " + doInsert);
168 out.println(
"doLookup: " + doLookup);
169 out.println(
"doUpdate: " + doUpdate);
170 out.println(
"doDelete: " + doDelete);
171 out.println(
"doSingle: " + doSingle);
172 out.println(
"doBulk: " + doBulk);
173 out.println(
"doBatch: " + doBatch);
174 out.println(
"lockMode: " + lockMode);
175 out.println(
"nRows: " + nRows);
176 out.println(
"nRuns: " + nRuns);
183 protected void runTests()
throws Exception {
193 protected void runLoads()
throws Exception {
197 runSeries(clusterjLoad);
199 runSeries(ndbjtieLoad);
202 protected void runSeries(TwsLoad load)
throws Exception {
207 out.println(
"------------------------------------------------------------");
208 out.print(
"running " + nRuns +
" iterations on load: "
209 + load.getDescriptor());
211 for (
int i = 0;
i < nRuns;
i++) {
213 out.println(
"------------------------------------------------------------");
217 writeLogBuffers(load.getDescriptor());
221 enum XMode { SINGLE, BULK, BATCH }
223 protected void runOperations(TwsLoad load)
throws Exception {
229 rtimes.append(
"nRows=" + nRows);
233 musage.append(
"nRows=" + nRows);
238 if (renewConnection) {
239 load.closeConnection();
240 load.initConnection();
244 load.runOperations();
247 out.println(
"total");
249 out.println(
"tx real time " + ta
253 out.println(
"net mem usage "
254 + (ma >= 0 ?
"+" :
"") + ma
260 header.append(
"\ttotal");
264 rtimes.append(
"\t" + ta);
268 musage.append(
"\t" + ma);
277 protected void initConnections()
throws Exception {
279 assert (jdbcLoad != null);
280 jdbcLoad.initConnection();
283 assert (clusterjLoad != null);
284 clusterjLoad.initConnection();
287 assert (ndbjtieLoad != null);
288 ndbjtieLoad.initConnection();
292 protected void closeConnections()
throws Exception {
294 assert (jdbcLoad != null);
295 jdbcLoad.closeConnection();
298 assert (clusterjLoad != null);
299 clusterjLoad.closeConnection();
302 assert (ndbjtieLoad != null);
303 ndbjtieLoad.closeConnection();