20 package com.mysql.cluster.crund;
28 protected void initProperties() {
29 super.initProperties();
30 descr =
"->ndbapi(" + mgmdConnect +
")";
35 static protected native
int ndbinit(
String mgmd_host_portno);
36 static protected native
int ndbclose();
38 protected void initLoad()
throws Exception {
44 loadSystemLibrary(
"ndbclient");
45 loadSystemLibrary(
"crundndb");
48 final int ret = ndbinit(mgmdConnect);
50 String msg = (
"NdbApiLoad: failed initializing NDBAPI;"
51 +
" return value = " +
ret);
53 throw new Exception(msg);
57 protected void closeLoad()
throws Exception {
59 final int ret = ndbclose();
61 String msg = (
"NdbApiLoad: failed closing NDBAPI;"
62 +
" return value = " +
ret);
64 throw new Exception(msg);
75 protected native
void delAllA(
int nOps,
boolean batch);
76 protected native
void delAllB0(
int nOps,
boolean batch);
77 protected native
void insA(
int nOps,
boolean setAttrs,
boolean batch);
78 protected native
void insB0(
int nOps,
boolean setAttrs,
boolean batch);
79 protected native
void delAByPK(
int nOps,
boolean batch);
80 protected native
void delB0ByPK(
int nOps,
boolean batch);
81 protected native
void setAByPK(
int nOps,
boolean batch);
82 protected native
void setB0ByPK(
int nOps,
boolean batch);
83 protected native
void getAByPK_bb(
int nOps,
boolean batch);
84 protected native
void getB0ByPK_bb(
int nOps,
boolean batch);
85 protected native
void getAByPK_ar(
int nOps,
boolean batch);
86 protected native
void getB0ByPK_ar(
int nOps,
boolean batch);
87 protected native
void setVarbinary(
int nOps,
boolean batch,
int length);
88 protected native
void getVarbinary(
int nOps,
boolean batch,
int length);
89 protected native
void setVarchar(
int nOps,
boolean batch,
int length);
90 protected native
void getVarchar(
int nOps,
boolean batch,
int length);
91 protected native
void setB0ToA(
int nOps,
boolean batch);
92 protected native
void navB0ToA(
int nOps,
boolean batch);
93 protected native
void navB0ToAalt(
int nOps,
boolean batch);
94 protected native
void navAToB0(
int nOps,
boolean batch);
95 protected native
void navAToB0alt(
int nOps,
boolean batch);
96 protected native
void nullB0ToA(
int nOps,
boolean batch);
98 protected void initOperations() {
99 out.print(
"initializing operations ...");
102 for (
boolean f =
false, done =
false; !done; done = f, f =
true) {
104 final boolean batch = f;
105 final boolean forceSend = f;
106 final boolean setAttrs =
true;
109 new Op(
"insA" + (batch ?
"_batch" :
"")) {
110 public void run(
int nOps) {
111 insA(nOps, !setAttrs, batch);
116 new Op(
"insB0" + (batch ?
"_batch" :
"")) {
117 public void run(
int nOps) {
118 insB0(nOps, !setAttrs, batch);
123 new Op(
"setAByPK" + (batch ?
"_batch" :
"")) {
124 public void run(
int nOps) {
125 setAByPK(nOps, batch);
130 new Op(
"setB0ByPK" + (batch ?
"_batch" :
"")) {
131 public void run(
int nOps) {
132 setB0ByPK(nOps, batch);
137 new Op(
"getAByPK_bb" + (batch ?
"_batch" :
"")) {
138 public void run(
int nOps) {
139 getAByPK_bb(nOps, batch);
144 new Op(
"getAByPK_ar" + (batch ?
"_batch" :
"")) {
145 public void run(
int nOps) {
146 getAByPK_ar(nOps, batch);
151 new Op(
"getB0ByPK_bb" + (batch ?
"_batch" :
"")) {
152 public void run(
int nOps) {
153 getB0ByPK_bb(nOps, batch);
158 new Op(
"getB0ByPK_ar" + (batch ?
"_batch" :
"")) {
159 public void run(
int nOps) {
160 getB0ByPK_ar(nOps, batch);
164 for (
int i = 1;
i <= maxVarbinaryBytes;
i *= 10) {
165 final int length =
i;
168 new Op(
"setVarbinary" + length + (batch ?
"_batch" :
"")) {
169 public void run(
int nOps) {
170 setVarbinary(nOps, batch, length);
175 new Op(
"getVarbinary" + length + (batch ?
"_batch" :
"")) {
176 public void run(
int nOps) {
177 getVarbinary(nOps, batch, length);
182 new Op(
"clearVarbinary" + length + (batch ?
"_batch" :
"")) {
183 public void run(
int nOps) {
184 setVarbinary(nOps, batch, 0);
189 for (
int i = 1;
i <= maxVarcharChars;
i *= 10) {
190 final int length =
i;
193 new Op(
"setVarchar" + length + (batch ?
"_batch" :
"")) {
194 public void run(
int nOps) {
195 setVarchar(nOps, batch, length);
200 new Op(
"getVarchar" + length + (batch ?
"_batch" :
"")) {
201 public void run(
int nOps) {
202 getVarchar(nOps, batch, length);
207 new Op(
"clearVarchar" + length + (batch ?
"_batch" :
"")) {
208 public void run(
int nOps) {
209 setVarchar(nOps, batch, 0);
216 new Op(
"setB0->A" + (batch ?
"_batch" :
"")) {
217 public void run(
int nOps) {
218 setB0ToA(nOps, batch);
223 new Op(
"navB0->A" + (batch ?
"_batch" :
"")) {
224 public void run(
int nOps) {
225 navB0ToA(nOps, batch);
230 new Op(
"navB0->A_alt" + (batch ?
"_batch" :
"")) {
231 public void run(
int nOps) {
232 navB0ToAalt(nOps, batch);
237 new Op(
"navA->B0" + (forceSend ?
"_forceSend" :
"")) {
238 public void run(
int nOps) {
239 navAToB0(nOps, forceSend);
244 new Op(
"navA->B0_alt" + (forceSend ?
"_forceSend" :
"")) {
245 public void run(
int nOps) {
246 navAToB0alt(nOps, forceSend);
251 new Op(
"nullB0->A" + (batch ?
"_batch" :
"")) {
252 public void run(
int nOps) {
253 nullB0ToA(nOps, batch);
258 new Op(
"delB0ByPK" + (batch ?
"_batch" :
"")) {
259 public void run(
int nOps) {
260 delB0ByPK(nOps, batch);
265 new Op(
"delAByPK" + (batch ?
"_batch" :
"")) {
266 public void run(
int nOps) {
267 delAByPK(nOps, batch);
272 new Op(
"insA_attr" + (batch ?
"_batch" :
"")) {
273 public void run(
int nOps) {
274 insA(nOps, setAttrs, batch);
279 new Op(
"insB0_attr" + (batch ?
"_batch" :
"")) {
280 public void run(
int nOps) {
281 insB0(nOps, setAttrs, batch);
286 new Op(
"delAllB0" + (batch ?
"_batch" :
"")) {
287 public void run(
int nOps) {
288 delAllB0(nOps, batch);
293 new Op(
"delAllA" + (batch ?
"_batch" :
"")) {
294 public void run(
int nOps) {
295 delAllA(nOps, batch);
300 out.println(
" [Op: " + ops.size() +
"]");
303 protected void closeOperations() {
304 out.print(
"closing operations ...");
307 out.println(
" [ok]");
314 protected native
void initConnection(
String catalog,
316 int defaultLockMode);
317 protected void initConnection() {
319 final int LM_Read = 0;
320 final int LM_Exclusive = 1;
321 final int LM_CommittedRead = 2;
322 initConnection(catalog, schema, LM_CommittedRead);
324 protected native
void closeConnection();
325 protected native
void clearData();
329 static public void main(
String[] args) {
330 System.out.println(
"NdbApiLoad.main()");
333 System.out.println();
334 System.out.println(
"NdbApiLoad.main(): done.");