11 public static final int NUMBER_OF_TESTS = 15;
13 public static void main(String[] args) throws ServerException {
14 if (args[0].equals("2")) {
16 } else if (args[0].equals("3")) {
18 } else if (args[0].equals("4")) {
20 } else if (args[0].equals("5")) {
22 } else if (args[0].equals("6")) {
24 } else if (args[0].equals("7")) {
26 } else if (args[0].equals("8")) {
28 } else if (args[0].equals("9")) {
33 // static void test9() throws ServerException {
34 // // Setup the 2 clients
35 // Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
37 // Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
42 // System.out.println("Setting up keys");
43 // for (int i = 0; i < NUMBER_OF_TESTS; i++) {
44 // String a = "a" + i;
45 // String b = "b" + i;
46 // String c = "c" + i;
47 // String d = "d" + i;
48 // IoTString ia = new IoTString(a);
49 // IoTString ib = new IoTString(b);
50 // IoTString ic = new IoTString(c);
51 // IoTString id = new IoTString(d);
52 // t1.createNewKey(ia, 321);
53 // t1.createNewKey(ib, 351);
54 // t2.createNewKey(ic, 321);
55 // t2.createNewKey(id, 351);
58 // for (int i = 0; i < NUMBER_OF_TESTS; i++) {
59 // String a = "a" + i;
60 // String b = "b" + i;
61 // String c = "c" + i;
62 // String d = "d" + i;
63 // IoTString ia = new IoTString(a);
64 // IoTString ib = new IoTString(b);
65 // IoTString ic = new IoTString(c);
66 // IoTString id = new IoTString(d);
67 // t1.createNewKey(ia, 1000);
68 // t1.createNewKey(ib, 1000);
69 // t2.createNewKey(ic, 1000);
70 // t2.createNewKey(id, 1000);
73 // System.out.println("Updating Clients...");
79 // boolean foundError = false;
81 // System.out.println("Checking Key-Values...");
82 // for (int i = 0; i < NUMBER_OF_TESTS; i++) {
84 // String keyA = "a" + i;
85 // String keyB = "b" + i;
86 // String keyC = "c" + i;
87 // String keyD = "d" + i;
89 // IoTString iKeyA = new IoTString(keyA);
90 // IoTString iKeyB = new IoTString(keyB);
91 // IoTString iKeyC = new IoTString(keyC);
92 // IoTString iKeyD = new IoTString(keyD);
95 // Long testValA1 = t1.getArbitrator(iKeyA);
96 // Long testValB1 = t1.getArbitrator(iKeyB);
97 // Long testValC1 = t1.getArbitrator(iKeyC);
98 // Long testValD1 = t1.getArbitrator(iKeyD);
100 // Long testValA2 = t2.getArbitrator(iKeyA);
101 // Long testValB2 = t2.getArbitrator(iKeyB);
102 // Long testValC2 = t2.getArbitrator(iKeyC);
103 // Long testValD2 = t2.getArbitrator(iKeyD);
105 // if ((testValA1 == null) || (testValA1 != 321)) {
106 // System.out.println("Key-Value t1 incorrect: " + keyA + " " + testValA1);
107 // foundError = true;
110 // if ((testValB1 == null) || (testValB1 != 351)) {
111 // System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1);
112 // foundError = true;
115 // if ((testValC1 == null) || (testValC1 != 321)) {
116 // System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
117 // foundError = true;
120 // if ((testValD1 == null) || (testValD1 != 351)) {
121 // System.out.println("Key-Value t1 incorrect: " + keyD + " " + testValD1);
122 // foundError = true;
125 // if ((testValA2 == null) || (testValA2 != 321)) {
126 // System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
127 // foundError = true;
130 // if ((testValB2 == null) || (testValB2 != 351)) {
131 // System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
132 // foundError = true;
135 // if ((testValC2 == null) || (testValC2 != 321)) {
136 // System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
137 // foundError = true;
140 // if ((testValD2 == null) || (testValD2 != 351)) {
141 // System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
142 // foundError = true;
147 // System.out.println("Found Errors...");
149 // System.out.println("No Errors Found...");
153 // static void test8() throws ServerException {
155 // boolean foundError = false;
157 // // Setup the 2 clients
158 // Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
160 // Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
167 // System.out.println("Setting up keys");
168 // for (int i = 0; i < NUMBER_OF_TESTS; i++) {
169 // String a = "a" + i;
170 // String b = "b" + i;
171 // String c = "c" + i;
172 // String d = "d" + i;
173 // IoTString ia = new IoTString(a);
174 // IoTString ib = new IoTString(b);
175 // IoTString ic = new IoTString(c);
176 // IoTString id = new IoTString(d);
177 // t1.createNewKey(ia, 321);
178 // t1.createNewKey(ib, 351);
179 // t2.createNewKey(ic, 321);
180 // t2.createNewKey(id, 351);
184 // // Do Updates for the keys
185 // System.out.println("Setting Key-Values...");
188 // String keyA0 = "a0";
189 // String keyB0 = "b0";
190 // String keyC0 = "c0";
191 // String keyD0 = "d0";
192 // String valueA0 = "a0";
193 // String valueB0 = "b0";
194 // String valueC0 = "c0";
195 // String valueD0 = "d0";
197 // IoTString iKeyA0 = new IoTString(keyA0);
198 // IoTString iKeyB0 = new IoTString(keyB0);
199 // IoTString iKeyC0 = new IoTString(keyC0);
200 // IoTString iKeyD0 = new IoTString(keyD0);
201 // IoTString iValueA0 = new IoTString(valueA0);
202 // IoTString iValueB0 = new IoTString(valueB0);
203 // IoTString iValueC0 = new IoTString(valueC0);
204 // IoTString iValueD0 = new IoTString(valueD0);
206 // t1.startTransaction();
207 // t1.addKV( iKeyA0, iValueA0);
208 // t1.commitTransaction();
210 // t1.startTransaction();
211 // t1.addKV(iKeyB0, iValueB0);
212 // t1.commitTransaction();
214 // t2.startTransaction();
215 // t2.addKV(iKeyC0, iValueC0);
216 // t2.commitTransaction();
218 // t2.startTransaction();
219 // t2.addKV(iKeyD0, iValueD0);
220 // t2.commitTransaction();
222 // for (int i = 1; i < NUMBER_OF_TESTS; i++) {
223 // String keyB = "b" + i;
224 // String valueB = "b" + i;
225 // IoTString iKeyB = new IoTString(keyB);
226 // IoTString iValueB = new IoTString(valueB);
228 // String keyBOld = "b" + (i - 1);
229 // String valueBOld = "b" + (i - 1);
230 // IoTString iKeyBOld = new IoTString(keyBOld);
231 // IoTString iValueBOld = new IoTString(valueBOld);
234 // t1.startTransaction();
235 // t1.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyBOld, iValueBOld, Guard.Equal))));
236 // t1.addKV(iKeyB, iValueB);
237 // t1.commitTransaction();
240 // System.out.println("Checking Key-Values...");
241 // for (int i = 0; i < NUMBER_OF_TESTS; i++) {
243 // String keyB = "b" + i;
244 // String valueB = "b" + i;
246 // IoTString iKeyB = new IoTString(keyB);
247 // IoTString iValueB = new IoTString(valueB);
249 // IoTString testValB1 = t1.getSpeculative(iKeyB);
251 // if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
252 // System.out.println("Key-Value t1 incorrect: " + keyB);
253 // foundError = true;
259 // System.out.println("Updating Clients...");
265 // System.out.println("Checking Key-Values...");
266 // for (int i = 0; i < NUMBER_OF_TESTS; i++) {
268 // String keyA = "a" + i;
269 // String keyB = "b" + i;
270 // String keyC = "c" + i;
271 // String keyD = "d" + i;
272 // String valueA = "a" + i;
273 // String valueB = "b" + i;
274 // String valueC = "c" + i;
275 // String valueD = "d" + i;
277 // IoTString iKeyA = new IoTString(keyA);
278 // IoTString iKeyB = new IoTString(keyB);
279 // IoTString iKeyC = new IoTString(keyC);
280 // IoTString iKeyD = new IoTString(keyD);
281 // IoTString iValueA = new IoTString(valueA);
282 // IoTString iValueB = new IoTString(valueB);
283 // IoTString iValueC = new IoTString(valueC);
284 // IoTString iValueD = new IoTString(valueD);
287 // IoTString testValA1 = t1.getCommitted(iKeyA);
288 // IoTString testValB1 = t1.getCommitted(iKeyB);
289 // IoTString testValC1 = t1.getCommitted(iKeyC);
290 // IoTString testValD1 = t1.getCommitted(iKeyD);
292 // IoTString testValA2 = t2.getCommitted(iKeyA);
293 // IoTString testValB2 = t2.getCommitted(iKeyB);
294 // IoTString testValC2 = t2.getCommitted(iKeyC);
295 // IoTString testValD2 = t2.getCommitted(iKeyD);
299 // if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
300 // System.out.println("Key-Value t1 incorrect: " + keyA);
301 // foundError = true;
304 // if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
305 // System.out.println("Key-Value t1 incorrect: " + keyB);
306 // foundError = true;
309 // if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
310 // System.out.println("Key-Value t1 incorrect: " + keyC);
311 // foundError = true;
314 // if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
315 // System.out.println("Key-Value t1 incorrect: " + keyD);
316 // foundError = true;
320 // if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
321 // System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
322 // foundError = true;
325 // if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
326 // System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
327 // foundError = true;
330 // if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
331 // System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
332 // foundError = true;
335 // if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
336 // System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
337 // foundError = true;
340 // if (testValA1 != null) {
341 // System.out.println("Key-Value t1 incorrect: " + keyA);
342 // foundError = true;
345 // if (testValB1 != null) {
346 // System.out.println("Key-Value t1 incorrect: " + keyB);
347 // foundError = true;
350 // if (testValC1 != null) {
351 // System.out.println("Key-Value t1 incorrect: " + keyC);
352 // foundError = true;
355 // if (testValD1 != null) {
356 // System.out.println("Key-Value t1 incorrect: " + keyD);
357 // foundError = true;
360 // if (testValA2 != null) {
361 // System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
362 // foundError = true;
365 // if (testValB2 != null) {
366 // System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
367 // foundError = true;
370 // if (testValC2 != null) {
371 // System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
372 // foundError = true;
375 // if (testValD2 != null) {
376 // System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
377 // foundError = true;
383 // System.out.println("Found Errors...");
385 // System.out.println("No Errors Found...");
389 // static void test7() throws ServerException {
391 // long startTime = 0;
394 // // Setup the 2 clients
395 // Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
397 // Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
404 // System.out.println("Setting up keys");
405 // startTime = System.currentTimeMillis();
406 // for (int i = 0; i < NUMBER_OF_TESTS; i++) {
407 // String a = "a" + i;
408 // String b = "b" + i;
409 // String c = "c" + i;
410 // String d = "d" + i;
411 // IoTString ia = new IoTString(a);
412 // IoTString ib = new IoTString(b);
413 // IoTString ic = new IoTString(c);
414 // IoTString id = new IoTString(d);
415 // t1.createNewKey(ia, 321);
416 // t1.createNewKey(ib, 351);
417 // t2.createNewKey(ic, 321);
418 // t2.createNewKey(id, 351);
420 // endTime = System.currentTimeMillis();
422 // System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
423 // System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
424 // System.out.println();
427 // // Do Updates for the keys
428 // System.out.println("Setting Key-Values...");
429 // startTime = System.currentTimeMillis();
433 // String keyA0 = "a0";
434 // String keyB0 = "b0";
435 // String keyC0 = "c0";
436 // String keyD0 = "d0";
437 // String valueA0 = "a0";
438 // String valueB0 = "b0";
439 // String valueC0 = "c0";
440 // String valueD0 = "d0";
442 // IoTString iKeyA0 = new IoTString(keyA0);
443 // IoTString iKeyB0 = new IoTString(keyB0);
444 // IoTString iKeyC0 = new IoTString(keyC0);
445 // IoTString iKeyD0 = new IoTString(keyD0);
446 // IoTString iValueA0 = new IoTString(valueA0);
447 // IoTString iValueB0 = new IoTString(valueB0);
448 // IoTString iValueC0 = new IoTString(valueC0);
449 // IoTString iValueD0 = new IoTString(valueD0);
451 // t1.startTransaction();
452 // t1.addKV( iKeyA0, iValueA0);
453 // t1.commitTransaction();
455 // t1.startTransaction();
456 // t1.addKV(iKeyB0, iValueB0);
457 // t1.commitTransaction();
459 // t2.startTransaction();
460 // t2.addKV(iKeyC0, iValueC0);
461 // t2.commitTransaction();
463 // t2.startTransaction();
464 // t2.addKV(iKeyD0, iValueD0);
465 // t2.commitTransaction();
467 // for (int i = 1; i < NUMBER_OF_TESTS; i++) {
468 // String keyB = "b" + i;
469 // String valueB = "b" + i;
470 // IoTString iKeyB = new IoTString(keyB);
471 // IoTString iValueB = new IoTString(valueB);
473 // String keyBOld = "b" + (i - 1);
474 // String valueBOld = "b" + (i - 2);
475 // IoTString iKeyBOld = new IoTString(keyBOld);
476 // IoTString iValueBOld = new IoTString(valueBOld);
479 // t1.startTransaction();
480 // t1.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyBOld, iValueBOld, Guard.Equal))));
481 // t1.addKV(iKeyB, iValueB);
482 // t1.commitTransaction();
485 // for (int i = 1; i < NUMBER_OF_TESTS; i++) {
486 // String keyC = "c" + i;
487 // String valueC = "c" + i;
488 // IoTString iKeyC = new IoTString(keyC);
489 // IoTString iValueC = new IoTString(valueC);
491 // String keyCOld = "c" + (i - 1);
492 // String valueCOld = "c" + (i - 2);
493 // IoTString iKeyCOld = new IoTString(keyCOld);
494 // IoTString iValueCOld = new IoTString(valueCOld);
497 // t2.startTransaction();
498 // t2.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyCOld, iValueCOld, Guard.Equal))));
499 // t2.addKV(iKeyC, iValueC);
500 // t2.commitTransaction();
503 // for (int i = 1; i < NUMBER_OF_TESTS; i++) {
504 // String keyA = "a" + i;
505 // String keyD = "d" + i;
506 // String valueA = "a" + i;
507 // String valueD = "d" + i;
509 // IoTString iKeyA = new IoTString(keyA);
510 // IoTString iKeyD = new IoTString(keyD);
511 // IoTString iValueA = new IoTString(valueA);
512 // IoTString iValueD = new IoTString(valueD);
515 // String keyAOld = "a" + (i - 1);
516 // String keyDOld = "d" + (i - 1);
517 // String valueAOld = "a" + (i - 2);
518 // String valueDOld = "d" + (i - 2);
519 // IoTString iKeyAOld = new IoTString(keyAOld);
520 // IoTString iKeyDOld = new IoTString(keyDOld);
521 // IoTString iValueAOld = new IoTString(valueAOld);
522 // IoTString iValueDOld = new IoTString(valueDOld);
525 // t1.startTransaction();
526 // t1.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyAOld, iValueAOld, Guard.Equal))));
527 // t1.addKV(iKeyA, iValueA);
528 // t1.commitTransaction();
530 // t2.startTransaction();
531 // t2.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyDOld, iValueDOld, Guard.Equal))));
532 // t2.addKV(iKeyD, iValueD);
533 // t2.commitTransaction();
536 // endTime = System.currentTimeMillis();
538 // System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
539 // System.out.println("Time Taken Per Update: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
540 // System.out.println();
543 // System.out.println("Updating Clients...");
549 // boolean foundError = false;
551 // System.out.println("Checking Key-Values...");
552 // for (int i = 0; i < NUMBER_OF_TESTS; i++) {
554 // String keyA = "a" + i;
555 // String keyB = "b" + i;
556 // String keyC = "c" + i;
557 // String keyD = "d" + i;
558 // String valueA = "a" + i;
559 // String valueB = "b" + i;
560 // String valueC = "c" + i;
561 // String valueD = "d" + i;
563 // IoTString iKeyA = new IoTString(keyA);
564 // IoTString iKeyB = new IoTString(keyB);
565 // IoTString iKeyC = new IoTString(keyC);
566 // IoTString iKeyD = new IoTString(keyD);
567 // IoTString iValueA = new IoTString(valueA);
568 // IoTString iValueB = new IoTString(valueB);
569 // IoTString iValueC = new IoTString(valueC);
570 // IoTString iValueD = new IoTString(valueD);
573 // IoTString testValA1 = t1.getCommitted(iKeyA);
574 // IoTString testValB1 = t1.getCommitted(iKeyB);
575 // IoTString testValC1 = t1.getCommitted(iKeyC);
576 // IoTString testValD1 = t1.getCommitted(iKeyD);
578 // IoTString testValA2 = t2.getCommitted(iKeyA);
579 // IoTString testValB2 = t2.getCommitted(iKeyB);
580 // IoTString testValC2 = t2.getCommitted(iKeyC);
581 // IoTString testValD2 = t2.getCommitted(iKeyD);
585 // if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
586 // System.out.println("Key-Value t1 incorrect: " + keyA);
587 // foundError = true;
590 // if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
591 // System.out.println("Key-Value t1 incorrect: " + keyB);
592 // foundError = true;
595 // if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
596 // System.out.println("Key-Value t1 incorrect: " + keyC);
597 // foundError = true;
600 // if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
601 // System.out.println("Key-Value t1 incorrect: " + keyD);
602 // foundError = true;
606 // if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
607 // System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
608 // foundError = true;
611 // if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
612 // System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
613 // foundError = true;
616 // if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
617 // System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
618 // foundError = true;
621 // if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
622 // System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
623 // foundError = true;
626 // if (testValA1 != null) {
627 // System.out.println("Key-Value t1 incorrect: " + keyA);
628 // foundError = true;
631 // if (testValB1 != null) {
632 // System.out.println("Key-Value t1 incorrect: " + keyB);
633 // foundError = true;
636 // if (testValC1 != null) {
637 // System.out.println("Key-Value t1 incorrect: " + keyC);
638 // foundError = true;
641 // if (testValD1 != null) {
642 // System.out.println("Key-Value t1 incorrect: " + keyD);
643 // foundError = true;
646 // if (testValA2 != null) {
647 // System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
648 // foundError = true;
651 // if (testValB2 != null) {
652 // System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
653 // foundError = true;
656 // if (testValC2 != null) {
657 // System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
658 // foundError = true;
661 // if (testValD2 != null) {
662 // System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
663 // foundError = true;
669 // System.out.println("Found Errors...");
671 // System.out.println("No Errors Found...");
675 static void test9() {
677 boolean foundError = false;
679 // Setup the 2 clients
680 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
686 } catch (Exception e) {}
689 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
695 } catch (Exception e) {}
699 System.out.println("Setting up keys");
700 for (int i = 0; i < 4; i++) {
705 IoTString ia = new IoTString(a);
706 IoTString ib = new IoTString(b);
707 IoTString ic = new IoTString(c);
708 IoTString id = new IoTString(d);
711 t1.createNewKey(ia, 321);
713 } catch (Exception e) {}
718 t1.createNewKey(ib, 351);
720 } catch (Exception e) {}
725 t2.createNewKey(ic, 321);
727 } catch (Exception e) {}
732 t2.createNewKey(id, 351);
734 } catch (Exception e) {}
738 // Do Updates for the keys
739 System.out.println("Setting Key-Values...");
741 System.out.println("Setting b...");
742 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
743 for (int i = 0; i < 4; i++) {
744 String keyB = "b" + i;
745 String valueB = "b" + (i + t);
747 IoTString iKeyB = new IoTString(keyB);
748 IoTString iValueB = new IoTString(valueB);
751 t1.startTransaction();
752 t1.getSpeculativeAtomic(iKeyB);
753 t1.addKV(iKeyB, iValueB);
754 t1.commitTransaction();
755 System.out.println("Server Success");
756 } catch (Exception e) {
757 System.out.println("Server Fail");
763 System.out.println("Checking b");
764 for (int i = 0; i < 4; i++) {
766 String keyB = "b" + i;
767 String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
768 IoTString iKeyB = new IoTString(keyB);
769 IoTString iValueB = new IoTString(valueB);
771 IoTString testValB1 = t1.getSpeculative(iKeyB);
772 IoTString testValB2 = t2.getSpeculative(iKeyB);
774 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
775 System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1);
779 if ((testValB2 != null)) {
780 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
785 System.out.println("Setting c...");
786 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
787 for (int i = 0; i < 4; i++) {
788 String keyC = "c" + i;
789 String valueC = "c" + (i + t);
791 IoTString iKeyC = new IoTString(keyC);
792 IoTString iValueC = new IoTString(valueC);
795 t2.startTransaction();
796 t2.getSpeculativeAtomic(iKeyC);
797 t2.addKV(iKeyC, iValueC);
798 t2.commitTransaction();
799 System.out.println("Server Success");
800 } catch (Exception e) {
801 System.out.println("Server Fail");
807 System.out.println("Checking c");
808 for (int i = 0; i < 4; i++) {
809 String keyC = "c" + i;
810 String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
811 IoTString iKeyC = new IoTString(keyC);
812 IoTString iValueC = new IoTString(valueC);
814 IoTString testValC1 = t1.getSpeculative(iKeyC);
815 IoTString testValC2 = t2.getSpeculative(iKeyC);
817 if ((testValC1 != null)) {
818 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
822 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
823 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
828 System.out.println("Setting a and b...");
829 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
830 for (int i = 0; i < 4; i++) {
831 String keyA = "a" + i;
832 String keyD = "d" + i;
833 String valueA = "a" + (i + t);
834 String valueD = "d" + (i + t);
836 IoTString iKeyA = new IoTString(keyA);
837 IoTString iKeyD = new IoTString(keyD);
838 IoTString iValueA = new IoTString(valueA);
839 IoTString iValueD = new IoTString(valueD);
842 t1.startTransaction();
843 t1.addKV(iKeyA, iValueA);
844 t1.commitTransaction();
845 System.out.println("Server Success");
847 } catch (Exception e) {
848 System.out.println("Server Fail");
852 t2.startTransaction();
853 t2.addKV(iKeyD, iValueD);
854 t2.commitTransaction();
855 System.out.println("Server Success");
857 } catch (Exception e) {
858 System.out.println("Server Fail");
864 System.out.println("Updating Clients...");
865 System.out.println("Updating Clients...");
866 System.out.println("Updating Clients...");
867 System.out.println("Updating Clients...");
868 System.out.println("Updating Clients...");
869 System.out.println("Updating Clients...");
870 System.out.println("Updating Clients...");
871 System.out.println("Updating Clients...");
872 System.out.println("Updating Clients...");
873 System.out.println("Updating Clients...");
874 System.out.println("Updating Clients...");
875 System.out.println("Updating Clients...");
876 System.out.println("Updating Clients...");
877 System.out.println("Updating Clients...");
878 System.out.println("Updating Clients...");
879 System.out.println("Updating Clients...");
880 System.out.println("Updating Clients...");
881 System.out.println("Updating Clients...");
882 System.out.println("Updating Clients...");
883 System.out.println("Updating Clients...");
884 System.out.println("Updating Clients...");
885 System.out.println("Updating Clients...");
886 System.out.println("Updating Clients...");
887 System.out.println("Updating Clients...");
888 System.out.println("Updating Clients...");
892 } catch (Exception e) {
896 System.out.println("Updating Clients... T1 first");
901 } catch (Exception e) {
903 System.out.println("Fail");
907 System.out.println("Updating Clients... T2 first");
912 } catch (Exception e) {
913 System.out.println("Fail");
917 System.out.println("Updating Clients... T1 second");
922 } catch (Exception e) {
923 System.out.println("Fail");
927 System.out.println("Updating Clients... T2 second");
932 } catch (Exception e) {
933 System.out.println("Fail");
937 System.out.println("Checking Key-Values...");
938 for (int i = 0; i < 4; i++) {
940 String keyA = "a" + i;
941 String keyB = "b" + i;
942 String keyC = "c" + i;
943 String keyD = "d" + i;
944 String valueA = "a" + (i + NUMBER_OF_TESTS - 1);
945 String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
946 String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
947 String valueD = "d" + (i + NUMBER_OF_TESTS - 1);
949 IoTString iKeyA = new IoTString(keyA);
950 IoTString iKeyB = new IoTString(keyB);
951 IoTString iKeyC = new IoTString(keyC);
952 IoTString iKeyD = new IoTString(keyD);
953 IoTString iValueA = new IoTString(valueA);
954 IoTString iValueB = new IoTString(valueB);
955 IoTString iValueC = new IoTString(valueC);
956 IoTString iValueD = new IoTString(valueD);
959 IoTString testValA1 = t1.getCommitted(iKeyA);
960 IoTString testValB1 = t1.getCommitted(iKeyB);
961 IoTString testValC1 = t1.getCommitted(iKeyC);
962 IoTString testValD1 = t1.getCommitted(iKeyD);
964 IoTString testValA2 = t2.getCommitted(iKeyA);
965 IoTString testValB2 = t2.getCommitted(iKeyB);
966 IoTString testValC2 = t2.getCommitted(iKeyC);
967 IoTString testValD2 = t2.getCommitted(iKeyD);
969 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
970 System.out.println("Key-Value t1 incorrect: " + keyA + " " + testValA1 + " " + iValueA);
974 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
975 System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1 + " " + iValueB);
979 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
980 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1 + " " + iValueC);
984 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
985 System.out.println("Key-Value t1 incorrect: " + keyD + " " + testValD1 + " " + iValueD);
989 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
990 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2 + " " + iValueA);
994 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
995 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2 + " " + iValueB);
999 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1000 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2 + " " + iValueC);
1004 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
1005 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2 + " " + iValueD);
1011 System.out.println("Found Errors...");
1013 System.out.println("No Errors Found...");
1017 static void test8() {
1018 boolean foundError = false;
1021 // Setup the 2 clients
1022 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
1027 } catch (Exception e) {}
1030 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
1035 } catch (Exception e) {}
1039 System.out.println("Setting up keys");
1040 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1041 System.out.println(i);
1047 IoTString ia = new IoTString(a);
1048 IoTString ib = new IoTString(b);
1049 IoTString ic = new IoTString(c);
1050 IoTString id = new IoTString(d);
1054 t1.createNewKey(ia, 321);
1056 } catch (Exception e) {}
1061 t1.createNewKey(ib, 351);
1063 } catch (Exception e) {}
1068 t2.createNewKey(ic, 321);
1070 } catch (Exception e) {}
1075 t2.createNewKey(id, 351);
1077 } catch (Exception e) {}
1081 // Do Updates for the keys
1082 System.out.println("Setting Key-Values...");
1083 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1084 System.out.println(i);
1085 String keyA = "a" + i;
1086 String keyB = "b" + i;
1087 String keyC = "c" + i;
1088 String keyD = "d" + i;
1089 String valueA = "a" + i;
1090 String valueB = "b" + i;
1091 String valueC = "c" + i;
1092 String valueD = "d" + i;
1094 IoTString iKeyA = new IoTString(keyA);
1095 IoTString iKeyB = new IoTString(keyB);
1096 IoTString iKeyC = new IoTString(keyC);
1097 IoTString iKeyD = new IoTString(keyD);
1098 IoTString iValueA = new IoTString(valueA);
1099 IoTString iValueB = new IoTString(valueB);
1100 IoTString iValueC = new IoTString(valueC);
1101 IoTString iValueD = new IoTString(valueD);
1104 String keyAPrev = "a" + (i - 1);
1105 String keyBPrev = "b" + (i - 1);
1106 String keyCPrev = "c" + (i - 1);
1107 String keyDPrev = "d" + (i - 1);
1108 String valueAPrev = "a" + (i - 1);
1109 String valueBPrev = "b" + (i - 1);
1110 String valueCPrev = "c" + (i - 1);
1111 String valueDPrev = "d" + (i - 1);
1113 IoTString iKeyAPrev = new IoTString(keyAPrev);
1114 IoTString iKeyBPrev = new IoTString(keyBPrev);
1115 IoTString iKeyCPrev = new IoTString(keyCPrev);
1116 IoTString iKeyDPrev = new IoTString(keyDPrev);
1117 IoTString iValueAPrev = new IoTString(valueAPrev);
1118 IoTString iValueBPrev = new IoTString(valueBPrev);
1119 IoTString iValueCPrev = new IoTString(valueCPrev);
1120 IoTString iValueDPrev = new IoTString(valueDPrev);
1123 t1.startTransaction();
1125 IoTString tmp = t1.getSpeculative(iKeyAPrev);
1126 if ((tmp == null) || !tmp.equals(iValueAPrev)) {
1127 System.out.println("Key a Error: " + i);
1131 t1.addKV(iKeyA, iValueA);
1132 t1.commitTransaction();
1133 } catch (Exception e) {
1134 System.out.println("Connection Failure!");
1138 t1.startTransaction();
1140 IoTString tmp = t1.getSpeculative(iKeyBPrev);
1141 if ((tmp == null) || !tmp.equals(iValueBPrev)) {
1142 System.out.println("Key b Error: " + i);
1146 t1.addKV(iKeyB, iValueB);
1147 t1.commitTransaction();
1148 } catch (Exception e) {
1149 System.out.println("Connection Failure!");
1153 t2.startTransaction();
1155 IoTString tmp = t2.getSpeculative(iKeyCPrev);
1156 if ((tmp == null) || !tmp.equals(iValueCPrev)) {
1157 System.out.println("Key c Error: " + i);
1161 t2.addKV(iKeyC, iValueC);
1162 t2.commitTransaction();
1163 } catch (Exception e) {
1164 System.out.println("Connection Failure!");
1168 t2.startTransaction();
1170 IoTString tmp = t2.getSpeculative(iKeyDPrev);
1171 if ((tmp == null) || !tmp.equals(iValueDPrev)) {
1172 System.out.println("Key d Error: " + i);
1176 t2.addKV(iKeyD, iValueD);
1177 t2.commitTransaction();
1178 } catch (Exception e) {
1179 System.out.println("Connection Failure!");
1187 } catch (Exception e) {
1196 } catch (Exception e) {
1205 } catch (Exception e) {
1214 } catch (Exception e) {
1220 System.out.println("Checking Key-Values...");
1221 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1223 String keyA = "a" + i;
1224 String keyB = "b" + i;
1225 String keyC = "c" + i;
1226 String keyD = "d" + i;
1227 String valueA = "a" + i;
1228 String valueB = "b" + i;
1229 String valueC = "c" + i;
1230 String valueD = "d" + i;
1232 IoTString iKeyA = new IoTString(keyA);
1233 IoTString iKeyB = new IoTString(keyB);
1234 IoTString iKeyC = new IoTString(keyC);
1235 IoTString iKeyD = new IoTString(keyD);
1236 IoTString iValueA = new IoTString(valueA);
1237 IoTString iValueB = new IoTString(valueB);
1238 IoTString iValueC = new IoTString(valueC);
1239 IoTString iValueD = new IoTString(valueD);
1242 IoTString testValA1 = t1.getCommitted(iKeyA);
1243 IoTString testValB1 = t1.getCommitted(iKeyB);
1244 IoTString testValC1 = t1.getCommitted(iKeyC);
1245 IoTString testValD1 = t1.getCommitted(iKeyD);
1247 IoTString testValA2 = t2.getCommitted(iKeyA);
1248 IoTString testValB2 = t2.getCommitted(iKeyB);
1249 IoTString testValC2 = t2.getCommitted(iKeyC);
1250 IoTString testValD2 = t2.getCommitted(iKeyD);
1252 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
1253 System.out.println("Key-Value t1 incorrect: " + keyA);
1257 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1258 System.out.println("Key-Value t1 incorrect: " + keyB);
1262 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
1263 System.out.println("Key-Value t1 incorrect: " + keyC);
1267 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
1268 System.out.println("Key-Value t1 incorrect: " + keyD);
1273 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
1274 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
1278 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
1279 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
1283 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1284 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1288 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
1289 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
1295 System.out.println("Found Errors...");
1297 System.out.println("No Errors Found...");
1301 static void test7() throws ServerException {
1305 boolean foundError = false;
1307 // Setup the 2 clients
1308 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
1310 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
1313 startTime = System.currentTimeMillis();
1315 System.out.println("Setting up keys");
1316 for (int i = 0; i < 4; i++) {
1321 IoTString ia = new IoTString(a);
1322 IoTString ib = new IoTString(b);
1323 IoTString ic = new IoTString(c);
1324 IoTString id = new IoTString(d);
1325 t1.createNewKey(ia, 321);
1326 t1.createNewKey(ib, 351);
1327 t2.createNewKey(ic, 321);
1328 t2.createNewKey(id, 351);
1330 endTime = System.currentTimeMillis();
1331 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1332 System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (4)) );
1333 System.out.println();
1335 // Do Updates for the keys
1336 System.out.println("Setting Key-Values...");
1338 startTime = System.currentTimeMillis();
1339 System.out.println("Setting b...");
1340 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
1341 for (int i = 0; i < 4; i++) {
1342 String keyB = "b" + i;
1343 String valueB = "b" + (i + t);
1345 IoTString iKeyB = new IoTString(keyB);
1346 IoTString iValueB = new IoTString(valueB);
1348 t1.startTransaction();
1349 t1.getSpeculativeAtomic(iKeyB);
1350 t1.addKV(iKeyB, iValueB);
1351 t1.commitTransaction();
1354 endTime = System.currentTimeMillis();
1355 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1356 System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (4 * NUMBER_OF_TESTS)) );
1357 System.out.println();
1361 System.out.println("Checking b");
1362 for (int i = 0; i < 4; i++) {
1364 String keyB = "b" + i;
1365 String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
1366 IoTString iKeyB = new IoTString(keyB);
1367 IoTString iValueB = new IoTString(valueB);
1369 IoTString testValB1 = t1.getSpeculative(iKeyB);
1370 IoTString testValB2 = t2.getSpeculative(iKeyB);
1372 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1373 System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1);
1377 if ((testValB2 != null)) {
1378 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
1383 startTime = System.currentTimeMillis();
1384 System.out.println("Setting c...");
1385 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
1386 for (int i = 0; i < 4; i++) {
1387 String keyC = "c" + i;
1388 String valueC = "c" + (i + t);
1390 IoTString iKeyC = new IoTString(keyC);
1391 IoTString iValueC = new IoTString(valueC);
1393 t2.startTransaction();
1394 t2.getSpeculativeAtomic(iKeyC);
1395 t2.addKV(iKeyC, iValueC);
1396 t2.commitTransaction();
1399 endTime = System.currentTimeMillis();
1400 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1401 System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (4 * NUMBER_OF_TESTS)) );
1402 System.out.println();
1405 System.out.println("Checking c");
1406 for (int i = 0; i < 4; i++) {
1407 String keyC = "c" + i;
1408 String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
1409 IoTString iKeyC = new IoTString(keyC);
1410 IoTString iValueC = new IoTString(valueC);
1412 IoTString testValC1 = t1.getSpeculative(iKeyC);
1413 IoTString testValC2 = t2.getSpeculative(iKeyC);
1415 if ((testValC1 != null)) {
1416 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
1420 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1421 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1426 System.out.println("Setting a and b...");
1427 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
1428 for (int i = 0; i < 4; i++) {
1429 String keyA = "a" + i;
1430 String keyD = "d" + i;
1431 String valueA = "a" + (i + t);
1432 String valueD = "d" + (i + t);
1434 IoTString iKeyA = new IoTString(keyA);
1435 IoTString iKeyD = new IoTString(keyD);
1436 IoTString iValueA = new IoTString(valueA);
1437 IoTString iValueD = new IoTString(valueD);
1439 t1.startTransaction();
1440 t1.addKV(iKeyA, iValueA);
1441 t1.commitTransaction();
1443 t2.startTransaction();
1444 t2.addKV(iKeyD, iValueD);
1445 t2.commitTransaction();
1449 System.out.println("Updating Clients...");
1455 System.out.println("Checking Key-Values...");
1456 for (int i = 0; i < 4; i++) {
1458 String keyA = "a" + i;
1459 String keyB = "b" + i;
1460 String keyC = "c" + i;
1461 String keyD = "d" + i;
1462 String valueA = "a" + (i + NUMBER_OF_TESTS - 1);
1463 String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
1464 String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
1465 String valueD = "d" + (i + NUMBER_OF_TESTS - 1);
1467 IoTString iKeyA = new IoTString(keyA);
1468 IoTString iKeyB = new IoTString(keyB);
1469 IoTString iKeyC = new IoTString(keyC);
1470 IoTString iKeyD = new IoTString(keyD);
1471 IoTString iValueA = new IoTString(valueA);
1472 IoTString iValueB = new IoTString(valueB);
1473 IoTString iValueC = new IoTString(valueC);
1474 IoTString iValueD = new IoTString(valueD);
1477 IoTString testValA1 = t1.getCommitted(iKeyA);
1478 IoTString testValB1 = t1.getCommitted(iKeyB);
1479 IoTString testValC1 = t1.getCommitted(iKeyC);
1480 IoTString testValD1 = t1.getCommitted(iKeyD);
1482 IoTString testValA2 = t2.getCommitted(iKeyA);
1483 IoTString testValB2 = t2.getCommitted(iKeyB);
1484 IoTString testValC2 = t2.getCommitted(iKeyC);
1485 IoTString testValD2 = t2.getCommitted(iKeyD);
1487 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
1488 System.out.println("Key-Value t1 incorrect: " + keyA + " " + testValA1);
1492 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1493 System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1);
1497 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
1498 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
1502 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
1503 System.out.println("Key-Value t1 incorrect: " + keyD + " " + testValD1);
1507 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
1508 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
1512 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
1513 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
1517 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1518 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1522 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
1523 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
1529 System.out.println("Found Errors...");
1531 System.out.println("No Errors Found...");
1535 static void test6() throws ServerException {
1539 // Setup the 2 clients
1540 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
1542 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
1547 System.out.println("Setting up keys");
1548 startTime = System.currentTimeMillis();
1549 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1554 IoTString ia = new IoTString(a);
1555 IoTString ib = new IoTString(b);
1556 IoTString ic = new IoTString(c);
1557 IoTString id = new IoTString(d);
1558 t1.createNewKey(ia, 321);
1559 t1.createNewKey(ib, 351);
1560 t2.createNewKey(ic, 321);
1561 t2.createNewKey(id, 351);
1563 endTime = System.currentTimeMillis();
1567 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1568 System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
1569 System.out.println();
1572 // Do Updates for the keys
1573 System.out.println("Setting Key-Values...");
1574 startTime = System.currentTimeMillis();
1575 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1576 String keyA = "a" + i;
1577 String keyB = "b" + i;
1578 String keyC = "c" + i;
1579 String keyD = "d" + i;
1580 String valueA = "a" + i;
1581 String valueB = "b" + i;
1582 String valueC = "c" + i;
1583 String valueD = "d" + i;
1585 IoTString iKeyA = new IoTString(keyA);
1586 IoTString iKeyB = new IoTString(keyB);
1587 IoTString iKeyC = new IoTString(keyC);
1588 IoTString iKeyD = new IoTString(keyD);
1589 IoTString iValueA = new IoTString(valueA);
1590 IoTString iValueB = new IoTString(valueB);
1591 IoTString iValueC = new IoTString(valueC);
1592 IoTString iValueD = new IoTString(valueD);
1594 t1.startTransaction();
1595 t1.getCommittedAtomic(iKeyA);
1596 t1.addKV(iKeyA, iValueA);
1597 t1.commitTransaction();
1599 t1.startTransaction();
1600 t1.getCommittedAtomic(iKeyB);
1601 t1.addKV(iKeyB, iValueB);
1602 t1.commitTransaction();
1604 t2.startTransaction();
1605 t2.getCommittedAtomic(iKeyC);
1606 t2.addKV(iKeyC, iValueC);
1607 t2.commitTransaction();
1609 t2.startTransaction();
1610 t2.getCommittedAtomic(iKeyD);
1611 t2.addKV(iKeyD, iValueD);
1612 t2.commitTransaction();
1614 endTime = System.currentTimeMillis();
1616 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1617 System.out.println("Time Taken Per Update: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
1618 System.out.println();
1621 System.out.println("Updating Clients...");
1627 boolean foundError = false;
1629 System.out.println("Checking Key-Values...");
1630 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1632 String keyA = "a" + i;
1633 String keyB = "b" + i;
1634 String keyC = "c" + i;
1635 String keyD = "d" + i;
1636 String valueA = "a" + i;
1637 String valueB = "b" + i;
1638 String valueC = "c" + i;
1639 String valueD = "d" + i;
1641 IoTString iKeyA = new IoTString(keyA);
1642 IoTString iKeyB = new IoTString(keyB);
1643 IoTString iKeyC = new IoTString(keyC);
1644 IoTString iKeyD = new IoTString(keyD);
1645 IoTString iValueA = new IoTString(valueA);
1646 IoTString iValueB = new IoTString(valueB);
1647 IoTString iValueC = new IoTString(valueC);
1648 IoTString iValueD = new IoTString(valueD);
1651 IoTString testValA1 = t1.getCommitted(iKeyA);
1652 IoTString testValB1 = t1.getCommitted(iKeyB);
1653 IoTString testValC1 = t1.getCommitted(iKeyC);
1654 IoTString testValD1 = t1.getCommitted(iKeyD);
1656 IoTString testValA2 = t2.getCommitted(iKeyA);
1657 IoTString testValB2 = t2.getCommitted(iKeyB);
1658 IoTString testValC2 = t2.getCommitted(iKeyC);
1659 IoTString testValD2 = t2.getCommitted(iKeyD);
1661 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
1662 System.out.println("Key-Value t1 incorrect: " + keyA);
1666 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1667 System.out.println("Key-Value t1 incorrect: " + keyB);
1671 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
1672 System.out.println("Key-Value t1 incorrect: " + keyC);
1676 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
1677 System.out.println("Key-Value t1 incorrect: " + keyD);
1682 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
1683 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
1687 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
1688 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
1692 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1693 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1697 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
1698 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
1704 System.out.println("Found Errors...");
1706 System.out.println("No Errors Found...");
1709 // System.out.println();
1710 // System.out.println();
1711 // System.out.println();
1713 // System.out.println();
1714 // System.out.println();
1715 // System.out.println();
1719 static void test5() throws ServerException {
1723 boolean foundError = false;
1725 // Setup the 2 clients
1726 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
1728 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
1733 System.out.println("Setting up keys");
1734 for (int i = 0; i < 4; i++) {
1739 IoTString ia = new IoTString(a);
1740 IoTString ib = new IoTString(b);
1741 IoTString ic = new IoTString(c);
1742 IoTString id = new IoTString(d);
1743 t1.createNewKey(ia, 321);
1744 t1.createNewKey(ib, 351);
1745 t2.createNewKey(ic, 321);
1746 t2.createNewKey(id, 351);
1748 endTime = System.currentTimeMillis();
1752 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1753 System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (4)) );
1754 System.out.println();
1757 // Do Updates for the keys
1758 System.out.println("Setting Key-Values...");
1760 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
1761 for (int i = 0; i < 4; i++) {
1762 String keyB = "b" + i;
1763 String valueB = "b" + (i + t);
1765 IoTString iKeyB = new IoTString(keyB);
1766 IoTString iValueB = new IoTString(valueB);
1768 t1.startTransaction();
1769 t1.addKV(iKeyB, iValueB);
1770 t1.commitTransaction();
1774 for (int i = 0; i < 4; i++) {
1776 String keyB = "b" + i;
1777 String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
1778 IoTString iKeyB = new IoTString(keyB);
1779 IoTString iValueB = new IoTString(valueB);
1781 IoTString testValB1 = t1.getSpeculative(iKeyB);
1782 IoTString testValB2 = t2.getSpeculative(iKeyB);
1784 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1785 System.out.println("Key-Value t1 incorrect: " + keyB);
1789 if ((testValB2 != null)) {
1790 System.out.println("Key-Value t2 incorrect: " + keyB);
1795 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
1796 for (int i = 0; i < 4; i++) {
1797 String keyC = "c" + i;
1798 String valueC = "c" + (i + t);
1800 IoTString iKeyC = new IoTString(keyC);
1801 IoTString iValueC = new IoTString(valueC);
1803 t2.startTransaction();
1804 t2.addKV(iKeyC, iValueC);
1805 t2.commitTransaction();
1809 for (int i = 0; i < 4; i++) {
1810 String keyC = "c" + i;
1811 String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
1812 IoTString iKeyC = new IoTString(keyC);
1813 IoTString iValueC = new IoTString(valueC);
1815 IoTString testValC1 = t1.getSpeculative(iKeyC);
1816 IoTString testValC2 = t2.getSpeculative(iKeyC);
1818 if ((testValC1 != null)) {
1819 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
1823 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1824 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1829 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
1830 for (int i = 0; i < 4; i++) {
1831 String keyA = "a" + i;
1832 String keyD = "d" + i;
1833 String valueA = "a" + (i + t);
1834 String valueD = "d" + (i + t);
1836 IoTString iKeyA = new IoTString(keyA);
1837 IoTString iKeyD = new IoTString(keyD);
1838 IoTString iValueA = new IoTString(valueA);
1839 IoTString iValueD = new IoTString(valueD);
1841 t1.startTransaction();
1842 t1.addKV(iKeyA, iValueA);
1843 t1.commitTransaction();
1845 t2.startTransaction();
1846 t2.addKV(iKeyD, iValueD);
1847 t2.commitTransaction();
1851 System.out.println("Updating Clients...");
1858 System.out.println("Checking Key-Values...");
1859 for (int i = 0; i < 4; i++) {
1861 String keyA = "a" + i;
1862 String keyB = "b" + i;
1863 String keyC = "c" + i;
1864 String keyD = "d" + i;
1865 String valueA = "a" + (i + NUMBER_OF_TESTS - 1);
1866 String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
1867 String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
1868 String valueD = "d" + (i + NUMBER_OF_TESTS - 1);
1870 IoTString iKeyA = new IoTString(keyA);
1871 IoTString iKeyB = new IoTString(keyB);
1872 IoTString iKeyC = new IoTString(keyC);
1873 IoTString iKeyD = new IoTString(keyD);
1874 IoTString iValueA = new IoTString(valueA);
1875 IoTString iValueB = new IoTString(valueB);
1876 IoTString iValueC = new IoTString(valueC);
1877 IoTString iValueD = new IoTString(valueD);
1880 IoTString testValA1 = t1.getCommitted(iKeyA);
1881 IoTString testValB1 = t1.getCommitted(iKeyB);
1882 IoTString testValC1 = t1.getCommitted(iKeyC);
1883 IoTString testValD1 = t1.getCommitted(iKeyD);
1885 IoTString testValA2 = t2.getCommitted(iKeyA);
1886 IoTString testValB2 = t2.getCommitted(iKeyB);
1887 IoTString testValC2 = t2.getCommitted(iKeyC);
1888 IoTString testValD2 = t2.getCommitted(iKeyD);
1890 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
1891 System.out.println("Key-Value t1 incorrect: " + keyA + " " + testValA1);
1895 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1896 System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1);
1900 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
1901 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
1905 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
1906 System.out.println("Key-Value t1 incorrect: " + keyD + " " + testValD1);
1911 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
1912 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
1916 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
1917 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
1921 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1922 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1926 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
1927 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
1933 System.out.println("Found Errors...");
1935 System.out.println("No Errors Found...");
1939 static void test4() throws ServerException {
1944 // Setup the 2 clients
1945 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
1947 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
1952 System.out.println("Setting up keys");
1953 startTime = System.currentTimeMillis();
1954 for (int i = 0; i < 4; i++) {
1959 IoTString ia = new IoTString(a);
1960 IoTString ib = new IoTString(b);
1961 IoTString ic = new IoTString(c);
1962 IoTString id = new IoTString(d);
1963 t1.createNewKey(ia, 321);
1964 t1.createNewKey(ib, 351);
1965 t2.createNewKey(ic, 321);
1966 t2.createNewKey(id, 351);
1968 endTime = System.currentTimeMillis();
1972 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1973 System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
1974 System.out.println();
1977 // Do Updates for the keys
1978 System.out.println("Setting Key-Values...");
1979 startTime = System.currentTimeMillis();
1980 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
1981 for (int i = 0; i < 4; i++) {
1982 String keyA = "a" + i;
1983 String keyB = "b" + i;
1984 String keyC = "c" + i;
1985 String keyD = "d" + i;
1986 String valueA = "a" + i;
1987 String valueB = "b" + i;
1988 String valueC = "c" + i;
1989 String valueD = "d" + i;
1991 IoTString iKeyA = new IoTString(keyA);
1992 IoTString iKeyB = new IoTString(keyB);
1993 IoTString iKeyC = new IoTString(keyC);
1994 IoTString iKeyD = new IoTString(keyD);
1995 IoTString iValueA = new IoTString(valueA);
1996 IoTString iValueB = new IoTString(valueB);
1997 IoTString iValueC = new IoTString(valueC);
1998 IoTString iValueD = new IoTString(valueD);
2000 t1.startTransaction();
2001 t1.addKV(iKeyA, iValueA);
2002 t1.commitTransaction();
2004 t1.startTransaction();
2005 t1.addKV(iKeyB, iValueB);
2006 t1.commitTransaction();
2008 t2.startTransaction();
2009 t2.addKV(iKeyC, iValueC);
2010 t2.commitTransaction();
2012 t2.startTransaction();
2013 t2.addKV(iKeyD, iValueD);
2014 t2.commitTransaction();
2017 endTime = System.currentTimeMillis();
2019 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
2020 System.out.println("Time Taken Per Update: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 16)) );
2021 System.out.println();
2024 System.out.println("Updating Clients...");
2030 boolean foundError = false;
2032 System.out.println("Checking Key-Values...");
2033 for (int i = 0; i < 4; i++) {
2035 String keyA = "a" + i;
2036 String keyB = "b" + i;
2037 String keyC = "c" + i;
2038 String keyD = "d" + i;
2039 String valueA = "a" + i;
2040 String valueB = "b" + i;
2041 String valueC = "c" + i;
2042 String valueD = "d" + i;
2044 IoTString iKeyA = new IoTString(keyA);
2045 IoTString iKeyB = new IoTString(keyB);
2046 IoTString iKeyC = new IoTString(keyC);
2047 IoTString iKeyD = new IoTString(keyD);
2048 IoTString iValueA = new IoTString(valueA);
2049 IoTString iValueB = new IoTString(valueB);
2050 IoTString iValueC = new IoTString(valueC);
2051 IoTString iValueD = new IoTString(valueD);
2054 IoTString testValA1 = t1.getCommitted(iKeyA);
2055 IoTString testValB1 = t1.getCommitted(iKeyB);
2056 IoTString testValC1 = t1.getCommitted(iKeyC);
2057 IoTString testValD1 = t1.getCommitted(iKeyD);
2059 IoTString testValA2 = t2.getCommitted(iKeyA);
2060 IoTString testValB2 = t2.getCommitted(iKeyB);
2061 IoTString testValC2 = t2.getCommitted(iKeyC);
2062 IoTString testValD2 = t2.getCommitted(iKeyD);
2064 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
2065 System.out.println("Key-Value t1 incorrect: " + keyA);
2069 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
2070 System.out.println("Key-Value t1 incorrect: " + keyB);
2074 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
2075 System.out.println("Key-Value t1 incorrect: " + keyC);
2079 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
2080 System.out.println("Key-Value t1 incorrect: " + keyD);
2085 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
2086 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
2090 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
2091 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
2095 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
2096 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
2100 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
2101 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
2107 System.out.println("Found Errors...");
2109 System.out.println("No Errors Found...");
2113 static void test3() throws ServerException {
2117 boolean foundError = false;
2119 // Setup the 2 clients
2120 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
2122 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
2127 System.out.println("Setting up keys");
2128 startTime = System.currentTimeMillis();
2129 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
2134 IoTString ia = new IoTString(a);
2135 IoTString ib = new IoTString(b);
2136 IoTString ic = new IoTString(c);
2137 IoTString id = new IoTString(d);
2138 t1.createNewKey(ia, 321);
2139 t1.createNewKey(ib, 351);
2140 t2.createNewKey(ic, 321);
2141 t2.createNewKey(id, 351);
2143 endTime = System.currentTimeMillis();
2147 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
2148 System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
2149 System.out.println();
2152 // Do Updates for the keys
2153 System.out.println("Setting Key-Values...");
2154 startTime = System.currentTimeMillis();
2155 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
2156 String keyB = "b" + i;
2157 String valueB = "b" + i;
2159 IoTString iKeyB = new IoTString(keyB);
2160 IoTString iValueB = new IoTString(valueB);
2162 t1.startTransaction();
2163 t1.addKV(iKeyB, iValueB);
2164 t1.commitTransaction();
2167 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
2168 String keyC = "c" + i;
2169 String valueC = "c" + i;
2171 IoTString iKeyC = new IoTString(keyC);
2172 IoTString iValueC = new IoTString(valueC);
2174 t2.startTransaction();
2175 t2.addKV(iKeyC, iValueC);
2176 t2.commitTransaction();
2179 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
2180 String keyA = "a" + i;
2181 String keyD = "d" + i;
2182 String valueA = "a" + i;
2183 String valueD = "d" + i;
2185 IoTString iKeyA = new IoTString(keyA);
2186 IoTString iKeyD = new IoTString(keyD);
2187 IoTString iValueA = new IoTString(valueA);
2188 IoTString iValueD = new IoTString(valueD);
2190 t1.startTransaction();
2191 t1.addKV(iKeyA, iValueA);
2192 t1.commitTransaction();
2194 t2.startTransaction();
2195 t2.addKV(iKeyD, iValueD);
2196 t2.commitTransaction();
2198 endTime = System.currentTimeMillis();
2200 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
2201 System.out.println("Time Taken Per Update: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
2202 System.out.println();
2205 System.out.println("Updating Clients...");
2212 System.out.println("Checking Key-Values...");
2213 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
2215 String keyA = "a" + i;
2216 String keyB = "b" + i;
2217 String keyC = "c" + i;
2218 String keyD = "d" + i;
2219 String valueA = "a" + i;
2220 String valueB = "b" + i;
2221 String valueC = "c" + i;
2222 String valueD = "d" + i;
2224 IoTString iKeyA = new IoTString(keyA);
2225 IoTString iKeyB = new IoTString(keyB);
2226 IoTString iKeyC = new IoTString(keyC);
2227 IoTString iKeyD = new IoTString(keyD);
2228 IoTString iValueA = new IoTString(valueA);
2229 IoTString iValueB = new IoTString(valueB);
2230 IoTString iValueC = new IoTString(valueC);
2231 IoTString iValueD = new IoTString(valueD);
2234 IoTString testValA1 = t1.getCommitted(iKeyA);
2235 IoTString testValB1 = t1.getCommitted(iKeyB);
2236 IoTString testValC1 = t1.getCommitted(iKeyC);
2237 IoTString testValD1 = t1.getCommitted(iKeyD);
2239 IoTString testValA2 = t2.getCommitted(iKeyA);
2240 IoTString testValB2 = t2.getCommitted(iKeyB);
2241 IoTString testValC2 = t2.getCommitted(iKeyC);
2242 IoTString testValD2 = t2.getCommitted(iKeyD);
2244 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
2245 System.out.println("Key-Value t1 incorrect: " + keyA);
2249 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
2250 System.out.println("Key-Value t1 incorrect: " + keyB);
2254 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
2255 System.out.println("Key-Value t1 incorrect: " + keyC);
2259 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
2260 System.out.println("Key-Value t1 incorrect: " + keyD);
2265 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
2266 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
2270 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
2271 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
2275 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
2276 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
2280 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
2281 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
2287 System.out.println("Found Errors...");
2289 System.out.println("No Errors Found...");
2293 static void test2() throws ServerException {
2298 // Setup the 2 clients
2299 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
2301 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
2305 System.out.println("Setting up keys");
2306 startTime = System.currentTimeMillis();
2307 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
2312 IoTString ia = new IoTString(a);
2313 IoTString ib = new IoTString(b);
2314 IoTString ic = new IoTString(c);
2315 IoTString id = new IoTString(d);
2316 t1.createNewKey(ia, 321);
2317 t1.createNewKey(ib, 351);
2318 t2.createNewKey(ic, 321);
2319 t2.createNewKey(id, 351);
2321 endTime = System.currentTimeMillis();
2325 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
2326 System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
2327 System.out.println();
2330 // Do Updates for the keys
2331 System.out.println("Setting Key-Values...");
2332 startTime = System.currentTimeMillis();
2333 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
2334 String keyA = "a" + i;
2335 String keyB = "b" + i;
2336 String keyC = "c" + i;
2337 String keyD = "d" + i;
2338 String valueA = "a" + i;
2339 String valueB = "b" + i;
2340 String valueC = "c" + i;
2341 String valueD = "d" + i;
2343 IoTString iKeyA = new IoTString(keyA);
2344 IoTString iKeyB = new IoTString(keyB);
2345 IoTString iKeyC = new IoTString(keyC);
2346 IoTString iKeyD = new IoTString(keyD);
2347 IoTString iValueA = new IoTString(valueA);
2348 IoTString iValueB = new IoTString(valueB);
2349 IoTString iValueC = new IoTString(valueC);
2350 IoTString iValueD = new IoTString(valueD);
2352 t1.startTransaction();
2353 t1.addKV(iKeyA, iValueA);
2354 t1.commitTransaction();
2356 t1.startTransaction();
2357 t1.addKV(iKeyB, iValueB);
2358 t1.commitTransaction();
2360 t2.startTransaction();
2361 t2.addKV(iKeyC, iValueC);
2362 t2.commitTransaction();
2364 t2.startTransaction();
2365 t2.addKV(iKeyD, iValueD);
2366 t2.commitTransaction();
2368 endTime = System.currentTimeMillis();
2370 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
2371 System.out.println("Time Taken Per Update: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
2372 System.out.println();
2375 System.out.println("Updating Clients...");
2381 boolean foundError = false;
2383 System.out.println("Checking Key-Values...");
2384 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
2386 String keyA = "a" + i;
2387 String keyB = "b" + i;
2388 String keyC = "c" + i;
2389 String keyD = "d" + i;
2390 String valueA = "a" + i;
2391 String valueB = "b" + i;
2392 String valueC = "c" + i;
2393 String valueD = "d" + i;
2395 IoTString iKeyA = new IoTString(keyA);
2396 IoTString iKeyB = new IoTString(keyB);
2397 IoTString iKeyC = new IoTString(keyC);
2398 IoTString iKeyD = new IoTString(keyD);
2399 IoTString iValueA = new IoTString(valueA);
2400 IoTString iValueB = new IoTString(valueB);
2401 IoTString iValueC = new IoTString(valueC);
2402 IoTString iValueD = new IoTString(valueD);
2405 IoTString testValA1 = t1.getCommitted(iKeyA);
2406 IoTString testValB1 = t1.getCommitted(iKeyB);
2407 IoTString testValC1 = t1.getCommitted(iKeyC);
2408 IoTString testValD1 = t1.getCommitted(iKeyD);
2410 IoTString testValA2 = t2.getCommitted(iKeyA);
2411 IoTString testValB2 = t2.getCommitted(iKeyB);
2412 IoTString testValC2 = t2.getCommitted(iKeyC);
2413 IoTString testValD2 = t2.getCommitted(iKeyD);
2415 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
2416 System.out.println("Key-Value t1 incorrect: " + keyA);
2420 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
2421 System.out.println("Key-Value t1 incorrect: " + keyB);
2425 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
2426 System.out.println("Key-Value t1 incorrect: " + keyC);
2430 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
2431 System.out.println("Key-Value t1 incorrect: " + keyD);
2436 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
2437 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
2441 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
2442 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
2446 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
2447 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
2451 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
2452 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
2458 System.out.println("Found Errors...");
2460 System.out.println("No Errors Found...");