20 package com.mysql.cluster.crund;
22 import java.util.Arrays;
25 import com.mysql.cluster.ndbj.NdbClusterConnection;
26 import com.mysql.cluster.ndbj.Ndb;
27 import com.mysql.cluster.ndbj.NdbDictionary;
28 import com.mysql.cluster.ndbj.NdbTable;
29 import com.mysql.cluster.ndbj.NdbColumn;
30 import com.mysql.cluster.ndbj.NdbIndex;
31 import com.mysql.cluster.ndbj.NdbError;
32 import com.mysql.cluster.ndbj.NdbApiException;
33 import com.mysql.cluster.ndbj.NdbTransaction;
35 import com.mysql.cluster.ndbj.NdbTransaction.ExecType;
36 import com.mysql.cluster.ndbj.NdbOperation;
37 import com.mysql.cluster.ndbj.NdbOperation.LockMode;
39 import com.mysql.cluster.ndbj.NdbOperation.AbortOption;
40 import com.mysql.cluster.ndbj.NdbScanOperation;
41 import com.mysql.cluster.ndbj.NdbIndexScanOperation;
42 import com.mysql.cluster.ndbj.NdbIndexScanOperation.BoundType;
43 import com.mysql.cluster.ndbj.NdbResultSet;
56 protected NdbClusterConnection mgmd;
62 protected Model model;
71 protected void initProperties() {
72 super.initProperties();
73 descr =
"->ndbj->ndbapi(" + mgmdConnect +
")";
76 protected void initLoad()
throws Exception {
82 loadSystemLibrary(
"ndbj");
86 out.print(
"creating cluster conn...");
88 mgmd = NdbClusterConnection.create(mgmdConnect);
93 out.print(
"connecting to mgmd ...");
95 final int retries = 0;
97 final boolean verbose =
true;
99 if (mgmd.connect(retries, delay, verbose) != 0) {
100 final String msg = (
"mgmd@" + mgmdConnect
101 +
" was not ready within "
102 + (retries * delay) +
"s.");
104 throw new RuntimeException(
"!!! " + msg);
106 out.println(
" [ok: " + mgmdConnect +
"]");
109 protected void closeLoad()
throws Exception {
111 out.print(
"closing mgmd connection ...");
116 out.println(
" [ok]");
128 return "NdbError[" + e.getCode() +
"]: " + e.getMessage();
132 static protected class Model {
133 public final NdbTable table_A;
134 public final NdbTable table_B0;
135 public final NdbColumn column_A_id;
136 public final NdbColumn column_A_cint;
137 public final NdbColumn column_A_clong;
138 public final NdbColumn column_A_cfloat;
139 public final NdbColumn column_A_cdouble;
140 public final NdbColumn column_B0_id;
141 public final NdbColumn column_B0_cint;
142 public final NdbColumn column_B0_clong;
143 public final NdbColumn column_B0_cfloat;
144 public final NdbColumn column_B0_cdouble;
145 public final NdbColumn column_B0_a_id;
146 public final NdbColumn column_B0_cvarbinary_def;
147 public final NdbColumn column_B0_cvarchar_def;
148 public final NdbIndex idx_B0_a_id;
149 public final int attr_id;
150 public final int attr_cint;
151 public final int attr_clong;
152 public final int attr_cfloat;
153 public final int attr_cdouble;
154 public final int attr_B0_a_id;
155 public final int attr_B0_cvarbinary_def;
156 public final int attr_B0_cvarchar_def;
160 public final String name_id;
161 public final String name_cint;
162 public final String name_clong;
163 public final String name_cfloat;
164 public final String name_cdouble;
165 public final String name_B0_a_id;
166 public final String name_B0_cvarbinary_def;
167 public final String name_B0_cvarchar_def;
170 public Model(
Ndb ndb)
throws NdbApiException {
171 final NdbDictionary dict = ndb.getDictionary();
174 if ((table_A = dict.getTable(
"a")) == null)
175 throw new RuntimeException(toStr(dict.getNdbError()));
176 if ((column_A_id = table_A.getColumn(
"id")) == null)
177 throw new RuntimeException(toStr(dict.getNdbError()));
178 if ((column_A_cint = table_A.getColumn(
"cint")) == null)
179 throw new RuntimeException(toStr(dict.getNdbError()));
180 if ((column_A_clong = table_A.getColumn(
"clong")) == null)
181 throw new RuntimeException(toStr(dict.getNdbError()));
182 if ((column_A_cfloat = table_A.getColumn(
"cfloat")) == null)
183 throw new RuntimeException(toStr(dict.getNdbError()));
184 if ((column_A_cdouble = table_A.getColumn(
"cdouble")) == null)
185 throw new RuntimeException(toStr(dict.getNdbError()));
188 if ((table_B0 = dict.getTable(
"b0")) == null)
189 throw new RuntimeException(toStr(dict.getNdbError()));
190 if ((column_B0_id = table_B0.getColumn(
"id")) == null)
191 throw new RuntimeException(toStr(dict.getNdbError()));
192 if ((column_B0_cint = table_B0.getColumn(
"cint")) == null)
193 throw new RuntimeException(toStr(dict.getNdbError()));
194 if ((column_B0_clong = table_B0.getColumn(
"clong")) == null)
195 throw new RuntimeException(toStr(dict.getNdbError()));
196 if ((column_B0_cfloat = table_B0.getColumn(
"cfloat")) == null)
197 throw new RuntimeException(toStr(dict.getNdbError()));
198 if ((column_B0_cdouble = table_B0.getColumn(
"cdouble")) == null)
199 throw new RuntimeException(toStr(dict.getNdbError()));
200 if ((column_B0_a_id = table_B0.getColumn(
"a_id")) == null)
201 throw new RuntimeException(toStr(dict.getNdbError()));
202 if ((column_B0_cvarbinary_def = table_B0.getColumn(
"cvarbinary_def")) == null)
203 throw new RuntimeException(toStr(dict.getNdbError()));
204 if ((column_B0_cvarchar_def = table_B0.getColumn(
"cvarchar_def")) == null)
205 throw new RuntimeException(toStr(dict.getNdbError()));
208 if ((idx_B0_a_id = dict.getIndex(
"I_B0_FK",
"b0")) == null)
209 throw new RuntimeException(toStr(dict.getNdbError()));
212 attr_id = column_A_id.getColumnNo();
213 if (attr_id != column_B0_id.getColumnNo())
214 throw new RuntimeException(
"attribute id mismatch");
215 attr_cint = column_A_cint.getColumnNo();
216 if (attr_cint != column_B0_cint.getColumnNo())
217 throw new RuntimeException(
"attribute id mismatch");
218 attr_clong = column_A_clong.getColumnNo();
219 if (attr_clong != column_B0_clong.getColumnNo())
220 throw new RuntimeException(
"attribute id mismatch");
221 attr_cfloat = column_A_cfloat.getColumnNo();
222 if (attr_cfloat != column_B0_cfloat.getColumnNo())
223 throw new RuntimeException(
"attribute id mismatch");
224 attr_cdouble = column_A_cdouble.getColumnNo();
225 if (attr_cdouble != column_B0_cdouble.getColumnNo())
226 throw new RuntimeException(
"attribute id mismatch");
229 attr_B0_a_id = column_B0_a_id.getColumnNo();
230 attr_B0_cvarbinary_def = column_B0_cvarbinary_def.getColumnNo();
231 attr_B0_cvarchar_def = column_B0_cvarchar_def.getColumnNo();
235 name_id = column_A_id.getName();
236 if (!name_id.equals(column_B0_id.getName()))
237 throw new RuntimeException(
"attribute name mismatch");
238 name_cint = column_A_cint.getName();
239 if (!name_cint.equals(column_B0_cint.getName()))
240 throw new RuntimeException(
"attribute name mismatch");
241 name_clong = column_A_clong.getName();
242 if (!name_clong.equals(column_B0_clong.getName()))
243 throw new RuntimeException(
"attribute name mismatch");
244 name_cfloat = column_A_cfloat.getName();
245 if (!name_cfloat.equals(column_B0_cfloat.getName()))
246 throw new RuntimeException(
"attribute name mismatch");
247 name_cdouble = column_A_cdouble.getName();
248 if (!name_cdouble.equals(column_B0_cdouble.getName()))
249 throw new RuntimeException(
"attribute name mismatch");
250 name_B0_a_id = column_B0_a_id.getName();
251 name_B0_cvarbinary_def = column_B0_cvarbinary_def.getName();
252 name_B0_cvarchar_def = column_B0_cvarchar_def.getName();
257 final String string1 =
"i";
258 final String string10 =
"xxxxxxxxxx";
259 final String string100 =
"cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc";
260 final String string1000 =
"mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm";
261 final byte[] bytes1 = string1.getBytes();
262 final byte[] bytes10 = string10.getBytes();
263 final byte[] bytes100 = string100.getBytes();
264 final byte[] bytes1000 = string1000.getBytes();
265 final String[] strings = { string1, string10, string100 };
266 final byte[][] bytes = { bytes1, bytes10, bytes100 };
268 protected void initOperations()
throws NdbApiException {
269 out.print(
"initializing operations ...");
275 for (
boolean f =
false, done =
false; !done; done = f, f =
true) {
277 final boolean batch = f;
278 final boolean forceSend = f;
279 final boolean setAttrs =
true;
282 new Op(
"insA" + (batch ?
"_batch" :
"")) {
283 public void run(
int nOps)
284 throws NdbApiException {
285 ins(model.table_A, 1, nOps, !setAttrs, batch);
290 new Op(
"insB0" + (batch ?
"_batch" :
"")) {
291 public void run(
int nOps)
292 throws NdbApiException {
293 ins(model.table_B0, 1, nOps, !setAttrs, batch);
298 new Op(
"setAByPK" + (batch ?
"_batch" :
"")) {
299 public void run(
int nOps)
300 throws NdbApiException {
301 setByPK(model.table_A, 1, nOps, batch);
306 new Op(
"setB0ByPK" + (batch ?
"_batch" :
"")) {
307 public void run(
int nOps)
308 throws NdbApiException {
309 setByPK(model.table_B0, 1, nOps, batch);
314 new Op(
"getAByPK" + (batch ?
"_batch" :
"")) {
315 public void run(
int nOps)
316 throws NdbApiException {
317 getByPK(model.table_A, 1, nOps, batch);
322 new Op(
"getB0ByPK" + (batch ?
"_batch" :
"")) {
323 public void run(
int nOps)
324 throws NdbApiException {
325 getByPK(model.table_B0, 1, nOps, batch);
329 for (
int i = 0, l = 1; l <= maxVarbinaryBytes; l *= 10,
i++) {
330 final byte[] b = bytes[
i];
331 assert l == b.length;
334 new Op(
"setVarbinary" + l + (batch ?
"_batch" :
"")) {
335 public void run(
int nOps)
336 throws NdbApiException {
337 setVarbinary(model.table_B0, 1, nOps, batch, b);
342 new Op(
"getVarbinary" + l + (batch ?
"_batch" :
"")) {
343 public void run(
int nOps)
344 throws NdbApiException {
345 getVarbinary(model.table_B0, 1, nOps, batch, b);
350 for (
int i = 0, l = 1; l <= maxVarcharChars; l *= 10,
i++) {
352 assert l == s.length();
355 new Op(
"setVarchar" + l + (batch ?
"_batch" :
"")) {
356 public void run(
int nOps)
357 throws NdbApiException {
358 setVarchar(model.table_B0, 1, nOps, batch, s);
363 new Op(
"getVarchar" + l + (batch ?
"_batch" :
"")) {
364 public void run(
int nOps)
365 throws NdbApiException {
366 getVarchar(model.table_B0, 1, nOps, batch, s);
372 new Op(
"setB0->A" + (batch ?
"_batch" :
"")) {
373 public void run(
int nOps)
374 throws NdbApiException {
375 setB0ToA(nOps, batch);
380 new Op(
"navB0->A" + (batch ?
"_batch" :
"")) {
381 public void run(
int nOps)
382 throws NdbApiException {
383 navB0ToA(nOps, batch);
388 new Op(
"navB0->A_alt" + (batch ?
"_batch" :
"")) {
389 public void run(
int nOps)
390 throws NdbApiException {
391 navB0ToAalt(nOps, batch);
397 new Op(
"navA->B0" + (forceSend ?
"_forceSend" :
"")) {
398 public void run(
int nOps)
399 throws NdbApiException {
400 navAToB0(nOps, forceSend);
406 new Op(
"navA->B0_alt" + (forceSend ?
"_forceSend" :
"")) {
407 public void run(
int nOps)
408 throws NdbApiException {
409 navAToB0alt(nOps, forceSend);
414 new Op(
"nullB0->A" + (batch ?
"_batch" :
"")) {
415 public void run(
int nOps)
416 throws NdbApiException {
417 nullB0ToA(nOps, batch);
422 new Op(
"delB0ByPK" + (batch ?
"_batch" :
"")) {
423 public void run(
int nOps)
424 throws NdbApiException {
425 delByPK(model.table_B0, 1, nOps, batch);
430 new Op(
"delAByPK" + (batch ?
"_batch" :
"")) {
431 public void run(
int nOps)
432 throws NdbApiException {
433 delByPK(model.table_A, 1, nOps, batch);
438 new Op(
"insA_attr" + (batch ?
"_batch" :
"")) {
439 public void run(
int nOps)
440 throws NdbApiException {
441 ins(model.table_A, 1, nOps, setAttrs, batch);
446 new Op(
"insB0_attr" + (batch ?
"_batch" :
"")) {
447 public void run(
int nOps)
448 throws NdbApiException {
449 ins(model.table_B0, 1, nOps, setAttrs, batch);
455 public void run(
int nOps)
456 throws NdbApiException {
457 final int count = delByScan(model.table_B0);
458 assert count == nOps;
464 public void run(
int nOps)
465 throws NdbApiException {
466 final int count = delByScan(model.table_A);
467 assert count == nOps;
472 out.println(
" [Op: " + ops.size() +
"]");
475 protected void closeOperations() {
476 out.print(
"closing operations ...");
479 out.println(
" [ok]");
482 protected void beginTransaction()
throws NdbApiException {
485 tx = ndb.startTransaction();
489 protected void executeOperations()
throws NdbApiException {
493 int stat = tx.execute(ExecType.NoCommit, AbortOption.AbortOnError);
495 throw new RuntimeException(
"stat == " + stat);
498 protected void commitTransaction()
throws NdbApiException {
503 int stat = tx.execute(ExecType.Commit, AbortOption.AbortOnError);
505 throw new RuntimeException(
"stat == " + stat);
508 protected void rollbackTransaction()
throws NdbApiException {
512 int stat = tx.execute(ExecType.Rollback);
514 throw new RuntimeException(
"stat == " + stat);
517 protected void closeTransaction() {
527 throws NdbApiException {
528 op.getValue(model.name_cint);
529 op.getValue(model.name_clong);
530 op.getValue(model.name_cfloat);
531 op.getValue(model.name_cdouble);
534 protected int getCommonAttributes(NdbResultSet rs)
535 throws NdbApiException {
536 final int cint = rs.getInt(model.name_cint);
537 final long clong = rs.getLong(model.name_clong);
538 verify(clong == cint);
539 final float cfloat = rs.getFloat(model.name_cfloat);
540 verify(cfloat == cint);
541 final double cdouble = rs.getDouble(model.name_cdouble);
542 verify(cdouble == cint);
546 protected void ins(NdbTable
table,
int from,
int to,
547 boolean setAttrs,
boolean batch)
548 throws NdbApiException {
550 for (
int i = from;
i <=
to;
i++) {
556 op.equalInt(model.name_id,
i);
560 op.setInt(model.name_cint, -
i);
561 op.setLong(model.name_clong, -
i);
562 op.setFloat(model.name_cfloat, -
i);
563 op.setDouble(model.name_cdouble, -
i);
574 protected void delByPK(NdbTable table,
int from,
int to,
576 throws NdbApiException {
578 for (
int i = from;
i <=
to;
i++) {
584 op.equalInt(model.name_id,
i);
594 protected int delByScan(NdbTable table)
throws NdbApiException {
599 = tx.getSelectScanOperation(table, LockMode.LM_Exclusive);
608 final boolean allowFetch =
true;
609 while ((stat = op.nextResult(allowFetch)) == 0) {
612 op.deleteCurrentTuple();
618 }
while ((stat = op.nextResult(!allowFetch)) == 0);
628 int s = tx.execute(ExecType.NoCommit, AbortOption.AbortOnError);
630 throw new RuntimeException(
"s == " + s);
633 throw new RuntimeException(
"stat == " + stat);
636 throw new RuntimeException(
"stat == " + stat);
646 protected void setByPK(NdbTable table,
int from,
int to,
648 throws NdbApiException {
650 for (
int i = from;
i <=
to;
i++) {
656 op.equalInt(model.name_id,
i);
659 op.setInt(model.name_cint,
i);
660 op.setLong(model.name_clong,
i);
661 op.setFloat(model.name_cfloat,
i);
662 op.setDouble(model.name_cdouble,
i);
674 protected void testBrokenGetValueByIndex()
675 throws NdbApiException {
677 tx = ndb.startTransaction();
681 final int int_val = 1;
682 op.equalInt(
"id", int_val);
684 final NdbResultSet rs = op.resultData();
685 tx.execute(ExecType.Commit, AbortOption.AbortOnError,
true);
687 int id = rs.getInt(
"id");
688 assert
id == int_val;
694 protected void getByPK(NdbTable table,
int from,
int to,
696 throws NdbApiException {
698 final int count = (to - from) + 1;
699 final NdbResultSet[] rss =
new NdbResultSet[count];
702 for (
int i = 0, j = from;
i < count;
i++, j++) {
708 op.equalInt(model.name_id, j);
711 op.getValue(model.name_id);
712 fetchCommonAttributes(op);
715 rss[
i] = op.resultData();
724 for (
int i = 0, j = from;
i < count;
i++, j++) {
725 final NdbResultSet rs = rss[
i];
726 final boolean hasNext = rs.next();
730 final int id = rs.getInt(model.name_id);
734 final int id1 = getCommonAttributes(rs);
742 protected void setVarbinary(NdbTable table,
int from,
int to,
743 boolean batch, byte[] bytes)
744 throws NdbApiException {
746 for (
int i = from;
i <=
to;
i++) {
752 op.equalInt(model.name_id,
i);
755 op.setBytes(model.name_B0_cvarbinary_def, bytes);
765 protected void setVarchar(NdbTable table,
int from,
int to,
766 boolean batch,
String string)
767 throws NdbApiException {
769 for (
int i = from;
i <=
to;
i++) {
775 op.equalInt(model.name_id,
i);
778 op.setString(model.name_B0_cvarchar_def,
string);
788 protected void getVarbinary(NdbTable table,
int from,
int to,
789 boolean batch, byte[] bytes)
790 throws NdbApiException {
792 final int count = (to - from) + 1;
793 final NdbResultSet[] rss =
new NdbResultSet[count];
796 for (
int i = 0, j = from;
i < count;
i++, j++) {
802 op.equalInt(model.name_id, j);
805 op.getValue(model.name_B0_cvarbinary_def);
808 rss[
i] = op.resultData();
818 for (
int i = 0, j = from;
i < count;
i++, j++) {
819 final NdbResultSet rs = rss[
i];
820 final boolean hasNext = rs.next();
824 final byte[] cvarbinary_def
825 = rs.getBytes(model.name_B0_cvarbinary_def);
826 verify(Arrays.equals(bytes, cvarbinary_def));
833 protected void getVarchar(NdbTable table,
int from,
int to,
834 boolean batch,
String string)
835 throws NdbApiException {
837 final int count = (to - from) + 1;
838 final NdbResultSet[] rss =
new NdbResultSet[count];
841 for (
int i = 0, j = from;
i < count;
i++, j++) {
847 op.equalInt(model.name_id, j);
850 op.getValue(model.name_B0_cvarchar_def);
853 rss[
i] = op.resultData();
863 for (
int i = 0, j = from;
i < count;
i++, j++) {
864 final NdbResultSet rs = rss[
i];
865 final boolean hasNext = rs.next();
871 = rs.getString(model.name_B0_cvarchar_def);
872 verify(
string.equals(cvarchar_def));
875 final byte[] cvarchar_def
876 = rs.getStringBytes(model.name_B0_cvarchar_def);
877 verify(Arrays.equals(
string.getBytes(), cvarchar_def));
885 protected void setB0ToA(
int nOps,
887 throws NdbApiException {
889 for (
int i = 1;
i <= nOps;
i++) {
891 final NdbOperation op = tx.getUpdateOperation(model.table_B0);
895 op.equalInt(model.name_id,
i);
898 int a_id = ((
i - 1) % nOps) + 1;
899 op.setInt(model.name_B0_a_id, a_id);
909 protected void nullB0ToA(
int nOps,
911 throws NdbApiException {
913 for (
int i = 1;
i <= nOps;
i++) {
915 final NdbOperation op = tx.getUpdateOperation(model.table_B0);
919 op.equalInt(model.name_id,
i);
922 int a_id = ((
i - 1) % nOps) + 1;
923 op.setNull(model.name_B0_a_id);
933 protected void navB0ToA(
int nOps,
935 throws NdbApiException {
939 final NdbResultSet[] abs =
new NdbResultSet[nOps];
940 for (
int i = 1, j = 0;
i <= nOps;
i++, j++) {
945 NdbOperation op = tx.getSelectOperation(model.table_B0);
949 op.equalInt(model.name_id,
i);
952 op.getValue(model.name_B0_a_id);
955 rs = op.resultData();
966 final int a_id = rs.getInt(model.name_B0_a_id);
967 assert a_id == ((
i - 1) % nOps) + 1;
968 op.equalInt(model.name_id, a_id);
971 op.getValue(model.name_id);
972 fetchCommonAttributes(op);
975 abs[j] = op.resultData();
985 for (
int i = 1, j = 0;
i <= nOps;
i++, j++) {
986 final NdbResultSet ab = abs[j];
987 final boolean hasNext = ab.next();
991 final int id = ab.getInt(model.name_id);
993 verify(
id == ((
i - 1) % nOps) + 1);
996 final int k = getCommonAttributes(ab);
1004 protected void navB0ToAalt(
int nOps,
1006 throws NdbApiException {
1010 final NdbResultSet[] a_ids =
new NdbResultSet[nOps];
1011 for (
int i = 1, j = 0;
i <= nOps;
i++, j++) {
1013 NdbOperation op = tx.getSelectOperation(model.table_B0);
1017 op.equalInt(model.name_id,
i);
1020 op.getValue(model.name_B0_a_id);
1023 a_ids[j] = op.resultData();
1025 executeOperations();
1028 final NdbResultSet[] abs =
new NdbResultSet[nOps];
1029 for (
int i = 1, j = 0;
i <= nOps;
i++, j++) {
1031 NdbOperation op = tx.getSelectOperation(model.table_A);
1035 final int a_id = a_ids[j].getInt(model.name_B0_a_id);
1036 assert a_id == ((
i - 1) % nOps) + 1;
1037 op.equalInt(model.name_id, a_id);
1040 op.getValue(model.name_id);
1041 fetchCommonAttributes(op);
1044 abs[j] = op.resultData();
1048 executeOperations();
1050 commitTransaction();
1053 for (
int i = 1, j = 0;
i <= nOps;
i++, j++) {
1054 final NdbResultSet ab = abs[j];
1055 final boolean hasNext = ab.next();
1059 final int id = ab.getInt(model.name_id);
1061 verify(
id == ((
i - 1) % nOps) + 1);
1064 final int k = getCommonAttributes(ab);
1072 protected void navAToB0(
int nOps,
1074 throws NdbApiException {
1182 protected void navAToB0alt(
int nOps,
1184 throws NdbApiException {
1195 protected void initConnection()
throws NdbApiException {
1199 out.print(
"waiting for ndbd ...");
1201 final int initial_wait = 10;
1202 final int final_wait = 0;
1206 mgmd.waitUntilReady(initial_wait, final_wait);
1207 }
catch (NdbApiException e) {
1209 out.println(
"!!! data nodes were not ready within "
1210 + (initial_wait + final_wait) +
"s.");
1213 out.println(
" [ok]");
1216 out.print(
"connecting to ndbd ...");
1226 ndb = mgmd.createNdb(catalog);
1227 }
catch (NdbApiException e) {
1229 out.println(
"!!! failed to connect: " + e);
1232 out.println(
" [ok]");
1235 model =
new Model(ndb);
1238 protected void closeConnection() {
1240 out.print(
"closing ndbd connection ...");
1245 out.println(
" [ok]");
1248 protected void clearData()
throws NdbApiException {
1249 out.print(
"deleting all rows ...");
1251 final int delB0 = delByScan(model.table_B0);
1252 out.print(
" [B0: " + delB0);
1254 final int delA = delByScan(model.table_A);
1255 out.print(
", A: " + delA);
1262 static public void main(
String[] args) {
1263 System.out.println(
"NdbjLoad.main()");
1266 System.out.println();
1267 System.out.println(
"NdbjLoad.main(): done.");