4 import java.util.ArrayList;
14 public static final int NUMBER_OF_TESTS = 15;
16 public static void main(String[] args) throws ServerException {
17 if (args[0].equals("2")) {
19 } else if (args[0].equals("3")) {
21 } else if (args[0].equals("4")) {
23 } else if (args[0].equals("5")) {
25 } else if (args[0].equals("6")) {
27 } else if (args[0].equals("7")) {
29 } else if (args[0].equals("8")) {
31 } else if (args[0].equals("9")) {
33 } else if (args[0].equals("10")) {
35 } else if (args[0].equals("11")) {
41 static void test11() {
43 boolean foundError = false;
44 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
46 // Setup the 2 clients
47 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, 6000);
49 System.out.println("Init Table t1s");
55 } catch (Exception e) { }
59 System.out.println("Update Table t2");
60 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, 6001);
61 while (t2.update() == false) {}
64 System.out.println("Setting up keys");
65 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
66 System.out.println(i);
72 IoTString ia = new IoTString(a);
73 IoTString ib = new IoTString(b);
74 IoTString ic = new IoTString(c);
75 IoTString id = new IoTString(d);
79 t1.createNewKey(ia, 321);
81 } catch (Exception e) { }
86 t1.createNewKey(ib, 351);
88 } catch (Exception e) { }
93 t2.createNewKey(ic, 321);
95 } catch (Exception e) { }
100 t2.createNewKey(id, 351);
102 } catch (Exception e) { }
106 // Do Updates for the keys
107 System.out.println("Setting Key-Values...");
108 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
109 System.out.println(i);
110 String keyA = "a" + i;
111 String keyB = "b" + i;
112 String keyC = "c" + i;
113 String keyD = "d" + i;
114 String valueA = "a" + i;
115 String valueB = "b" + i;
116 String valueC = "c" + i;
117 String valueD = "d" + i;
119 IoTString iKeyA = new IoTString(keyA);
120 IoTString iKeyB = new IoTString(keyB);
121 IoTString iKeyC = new IoTString(keyC);
122 IoTString iKeyD = new IoTString(keyD);
123 IoTString iValueA = new IoTString(valueA);
124 IoTString iValueB = new IoTString(valueB);
125 IoTString iValueC = new IoTString(valueC);
126 IoTString iValueD = new IoTString(valueD);
129 String keyAPrev = "a" + (i - 1);
130 String keyBPrev = "b" + (i - 1);
131 String keyCPrev = "c" + (i - 1);
132 String keyDPrev = "d" + (i - 1);
133 String valueAPrev = "a" + (i - 1);
134 String valueBPrev = "b" + (i - 1);
135 String valueCPrev = "c" + (i - 1);
136 String valueDPrev = "d" + (i - 1);
138 IoTString iKeyAPrev = new IoTString(keyAPrev);
139 IoTString iKeyBPrev = new IoTString(keyBPrev);
140 IoTString iKeyCPrev = new IoTString(keyCPrev);
141 IoTString iKeyDPrev = new IoTString(keyDPrev);
142 IoTString iValueAPrev = new IoTString(valueAPrev);
143 IoTString iValueBPrev = new IoTString(valueBPrev);
144 IoTString iValueCPrev = new IoTString(valueCPrev);
145 IoTString iValueDPrev = new IoTString(valueDPrev);
148 System.out.println("t1 A");
149 t1.startTransaction();
150 t1.addKV(iKeyA, iValueA);
151 transStatusList.add(t1.commitTransaction());
153 System.out.println("t1 B");
154 t1.startTransaction();
155 t1.addKV(iKeyB, iValueB);
156 transStatusList.add(t1.commitTransaction());
158 System.out.println("t2 C");
159 t2.startTransaction();
160 t2.addKV(iKeyC, iValueC);
161 transStatusList.add(t2.commitTransaction());
163 System.out.println("t2 D");
164 t2.startTransaction();
165 t2.addKV(iKeyD, iValueD);
166 transStatusList.add(t2.commitTransaction());
169 System.out.println("Updating...");
170 while (t1.update() == false) {}
171 while (t2.update() == false) {}
172 while (t1.update() == false) {}
173 while (t2.update() == false) {}
175 System.out.println("Checking Key-Values...");
176 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
178 String keyA = "a" + i;
179 String keyB = "b" + i;
180 String keyC = "c" + i;
181 String keyD = "d" + i;
182 String valueA = "a" + i;
183 String valueB = "b" + i;
184 String valueC = "c" + i;
185 String valueD = "d" + i;
187 IoTString iKeyA = new IoTString(keyA);
188 IoTString iKeyB = new IoTString(keyB);
189 IoTString iKeyC = new IoTString(keyC);
190 IoTString iKeyD = new IoTString(keyD);
191 IoTString iValueA = new IoTString(valueA);
192 IoTString iValueB = new IoTString(valueB);
193 IoTString iValueC = new IoTString(valueC);
194 IoTString iValueD = new IoTString(valueD);
197 IoTString testValA1 = t1.getCommitted(iKeyA);
198 IoTString testValB1 = t1.getCommitted(iKeyB);
199 IoTString testValC1 = t1.getCommitted(iKeyC);
200 IoTString testValD1 = t1.getCommitted(iKeyD);
202 IoTString testValA2 = t2.getCommitted(iKeyA);
203 IoTString testValB2 = t2.getCommitted(iKeyB);
204 IoTString testValC2 = t2.getCommitted(iKeyC);
205 IoTString testValD2 = t2.getCommitted(iKeyD);
207 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
208 System.out.println("Key-Value t1 incorrect: " + keyA + " " + testValA1);
212 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
213 System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1);
217 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
218 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
222 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
223 System.out.println("Key-Value t1 incorrect: " + keyD + " " + testValD1);
228 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
229 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
233 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
234 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
238 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
239 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
243 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
244 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
249 for (TransactionStatus status : transStatusList) {
250 if (status.getStatus() != TransactionStatus.StatusCommitted) {
256 System.out.println("Found Errors...");
258 System.out.println("No Errors Found...");
265 static void test10() {
267 boolean foundError = false;
268 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
270 // Setup the 2 clients
271 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, 6000);
272 System.out.println("Init Table t1s");
277 } catch (Exception e) { }
279 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, 6001);
280 while (t2.update() == false) {}
282 t1.addLocalCommunication(351, "127.0.0.1", 6001);
283 t2.addLocalCommunication(321, "127.0.0.1", 6000);
287 System.out.println("Setting up keys");
288 for (int i = 0; i < 4; i++) {
293 IoTString ia = new IoTString(a);
294 IoTString ib = new IoTString(b);
295 IoTString ic = new IoTString(c);
296 IoTString id = new IoTString(d);
299 t1.createNewKey(ia, 321);
301 } catch (Exception e) { }
306 t1.createNewKey(ib, 351);
308 } catch (Exception e) { }
313 t2.createNewKey(ic, 321);
315 } catch (Exception e) { }
320 t2.createNewKey(id, 351);
322 } catch (Exception e) { }
327 // Do Updates for the keys
328 System.out.println("B========================");
329 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
330 for (int i = 0; i < 4; i++) {
332 System.out.println(i);
334 String keyB = "b" + i;
335 String valueB = "b" + (i + t);
337 IoTString iKeyB = new IoTString(keyB);
338 IoTString iValueB = new IoTString(valueB);
340 t1.startTransaction();
341 System.out.println(t1.getSpeculativeAtomic(iKeyB));
342 t1.addKV(iKeyB, iValueB);
343 transStatusList.add(t1.commitTransaction());
346 System.out.println();
349 System.out.println("C========================");
350 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
351 for (int i = 0; i < 4; i++) {
352 System.out.println(i);
354 String keyC = "c" + i;
355 String valueC = "c" + (i + t);
357 IoTString iKeyC = new IoTString(keyC);
358 IoTString iValueC = new IoTString(valueC);
360 t2.startTransaction();
361 System.out.println(t2.getSpeculativeAtomic(iKeyC));
362 t2.addKV(iKeyC, iValueC);
363 transStatusList.add(t2.commitTransaction());
366 System.out.println();
369 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
370 for (int i = 0; i < 4; i++) {
371 String keyA = "a" + i;
372 String keyD = "d" + i;
373 String valueA = "a" + (i + t);
374 String valueD = "d" + (i + t);
376 IoTString iKeyA = new IoTString(keyA);
377 IoTString iKeyD = new IoTString(keyD);
378 IoTString iValueA = new IoTString(valueA);
379 IoTString iValueD = new IoTString(valueD);
382 t1.startTransaction();
383 t1.addKV(iKeyA, iValueA);
384 transStatusList.add(t1.commitTransaction());
387 t2.startTransaction();
388 t2.addKV(iKeyD, iValueD);
389 transStatusList.add(t2.commitTransaction());
390 System.out.println();
393 System.out.println();
395 System.out.println("Updating...");
396 System.out.println("t1 -=-=-=-=-=-=-=-");
397 while (t1.update() == false) {}
398 System.out.println("t2 -=-=-=-=-=-=-=-");
399 while (t2.update() == false) {}
400 System.out.println("t1 -=-=-=-=-=-=-=-");
401 while (t1.update() == false) {}
402 System.out.println("t2 -=-=-=-=-=-=-=-");
403 while (t2.update() == false) {}
406 System.out.println("Checking Key-Values...");
407 for (int i = 0; i < 4; i++) {
409 String keyA = "a" + i;
410 String keyB = "b" + i;
411 String keyC = "c" + i;
412 String keyD = "d" + i;
413 String valueA = "a" + (i + NUMBER_OF_TESTS - 1);
414 String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
415 String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
416 String valueD = "d" + (i + NUMBER_OF_TESTS - 1);
418 IoTString iKeyA = new IoTString(keyA);
419 IoTString iKeyB = new IoTString(keyB);
420 IoTString iKeyC = new IoTString(keyC);
421 IoTString iKeyD = new IoTString(keyD);
422 IoTString iValueA = new IoTString(valueA);
423 IoTString iValueB = new IoTString(valueB);
424 IoTString iValueC = new IoTString(valueC);
425 IoTString iValueD = new IoTString(valueD);
428 IoTString testValA1 = t1.getCommitted(iKeyA);
429 IoTString testValB1 = t1.getCommitted(iKeyB);
430 IoTString testValC1 = t1.getCommitted(iKeyC);
431 IoTString testValD1 = t1.getCommitted(iKeyD);
433 IoTString testValA2 = t2.getCommitted(iKeyA);
434 IoTString testValB2 = t2.getCommitted(iKeyB);
435 IoTString testValC2 = t2.getCommitted(iKeyC);
436 IoTString testValD2 = t2.getCommitted(iKeyD);
438 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
439 System.out.println("Key-Value t1 incorrect: " + keyA + " " + testValA1);
443 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
444 System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1);
448 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
449 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
453 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
454 System.out.println("Key-Value t1 incorrect: " + keyD + " " + testValD1);
458 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
459 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
463 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
464 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
468 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
469 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
473 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
474 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
480 for (TransactionStatus status : transStatusList) {
481 if (status.getStatus() != TransactionStatus.StatusCommitted) {
483 System.out.println(counter + " Status: " + status.getStatus());
489 System.out.println("Found Errors...");
491 System.out.println("No Errors Found...");
498 static void test9() {
500 boolean foundError = false;
501 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
503 // Setup the 2 clients
504 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, 6000);
506 System.out.println("Init Table t1s");
511 } catch (Exception e) { }
515 System.out.println("Update Table t2");
516 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, 6001);
517 while (t2.update() == false) {}
519 t1.addLocalCommunication(351, "127.0.0.1", 6001);
520 t2.addLocalCommunication(321, "127.0.0.1", 6000);
523 System.out.println("Setting up keys");
524 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
525 System.out.println(i);
531 IoTString ia = new IoTString(a);
532 IoTString ib = new IoTString(b);
533 IoTString ic = new IoTString(c);
534 IoTString id = new IoTString(d);
538 t1.createNewKey(ia, 321);
540 } catch (Exception e) { }
545 t1.createNewKey(ib, 351);
547 } catch (Exception e) { }
552 t2.createNewKey(ic, 321);
554 } catch (Exception e) { }
559 t2.createNewKey(id, 351);
561 } catch (Exception e) { }
565 System.out.println("A, D...");
566 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
567 String keyA = "a" + i;
568 String keyD = "d" + i;
569 String valueA = "a" + i;
570 String valueD = "d" + i;
572 IoTString iKeyA = new IoTString(keyA);
573 IoTString iKeyD = new IoTString(keyD);
574 IoTString iValueA = new IoTString(valueA);
575 IoTString iValueD = new IoTString(valueD);
577 t1.startTransaction();
578 t1.addKV(iKeyA, iValueA);
579 transStatusList.add(t1.commitTransaction());
581 t2.startTransaction();
582 t2.addKV(iKeyD, iValueD);
583 transStatusList.add(t2.commitTransaction());
586 while (t1.updateFromLocal(351) == false) {}
587 while (t2.updateFromLocal(321) == false) {}
590 System.out.println("Updating...");
591 System.out.println("Checking Key-Values...");
593 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
595 String keyA = "a" + i;
596 String keyD = "d" + i;
597 String valueA = "a" + i;
598 String valueD = "d" + i;
601 IoTString iKeyA = new IoTString(keyA);
602 IoTString iKeyD = new IoTString(keyD);
603 IoTString iValueA = new IoTString(valueA);
604 IoTString iValueD = new IoTString(valueD);
607 IoTString testValA1 = t1.getCommitted(iKeyA);
608 IoTString testValD1 = t1.getCommitted(iKeyD);
609 IoTString testValA2 = t2.getCommitted(iKeyA);
610 IoTString testValD2 = t2.getCommitted(iKeyD);
613 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
614 System.out.println("Key-Value t1 incorrect: " + keyA + " " + testValA1);
618 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
619 System.out.println("Key-Value t1 incorrect: " + keyD + " " + testValD1);
624 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
625 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
629 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
630 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
635 for (TransactionStatus status : transStatusList) {
636 if (status.getStatus() != TransactionStatus.StatusCommitted) {
642 System.out.println("Found Errors...");
644 System.out.println("No Errors Found...");
651 static void test8() {
653 boolean foundError = false;
654 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
656 // Setup the 2 clients
657 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, 6000);
659 System.out.println("Init Table t1s");
665 } catch (Exception e) { }
669 System.out.println("Update Table t2");
670 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, 6001);
671 while (t2.update() == false) {}
673 t1.addLocalCommunication(351, "127.0.0.1", 6001);
674 t2.addLocalCommunication(321, "127.0.0.1", 6000);
677 System.out.println("Setting up keys");
678 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
679 System.out.println(i);
685 IoTString ia = new IoTString(a);
686 IoTString ib = new IoTString(b);
687 IoTString ic = new IoTString(c);
688 IoTString id = new IoTString(d);
692 t1.createNewKey(ia, 321);
694 } catch (Exception e) { }
699 t1.createNewKey(ib, 351);
701 } catch (Exception e) { }
706 t2.createNewKey(ic, 321);
708 } catch (Exception e) { }
713 t2.createNewKey(id, 351);
715 } catch (Exception e) { }
719 // Do Updates for the keys
720 System.out.println("Setting Key-Values...");
721 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
722 System.out.println(i);
723 String keyA = "a" + i;
724 String keyB = "b" + i;
725 String keyC = "c" + i;
726 String keyD = "d" + i;
727 String valueA = "a" + i;
728 String valueB = "b" + i;
729 String valueC = "c" + i;
730 String valueD = "d" + i;
732 IoTString iKeyA = new IoTString(keyA);
733 IoTString iKeyB = new IoTString(keyB);
734 IoTString iKeyC = new IoTString(keyC);
735 IoTString iKeyD = new IoTString(keyD);
736 IoTString iValueA = new IoTString(valueA);
737 IoTString iValueB = new IoTString(valueB);
738 IoTString iValueC = new IoTString(valueC);
739 IoTString iValueD = new IoTString(valueD);
742 String keyAPrev = "a" + (i - 1);
743 String keyBPrev = "b" + (i - 1);
744 String keyCPrev = "c" + (i - 1);
745 String keyDPrev = "d" + (i - 1);
746 String valueAPrev = "a" + (i - 1);
747 String valueBPrev = "b" + (i - 1);
748 String valueCPrev = "c" + (i - 1);
749 String valueDPrev = "d" + (i - 1);
751 IoTString iKeyAPrev = new IoTString(keyAPrev);
752 IoTString iKeyBPrev = new IoTString(keyBPrev);
753 IoTString iKeyCPrev = new IoTString(keyCPrev);
754 IoTString iKeyDPrev = new IoTString(keyDPrev);
755 IoTString iValueAPrev = new IoTString(valueAPrev);
756 IoTString iValueBPrev = new IoTString(valueBPrev);
757 IoTString iValueCPrev = new IoTString(valueCPrev);
758 IoTString iValueDPrev = new IoTString(valueDPrev);
760 t1.startTransaction();
761 t1.addKV(iKeyA, iValueA);
762 transStatusList.add(t1.commitTransaction());
764 t1.startTransaction();
765 t1.addKV(iKeyB, iValueB);
766 transStatusList.add(t1.commitTransaction());
768 t2.startTransaction();
769 t2.addKV(iKeyC, iValueC);
770 transStatusList.add(t2.commitTransaction());
772 t2.startTransaction();
773 t2.addKV(iKeyD, iValueD);
774 transStatusList.add(t2.commitTransaction());
777 System.out.println("Updating...");
778 while (t1.update() == false) {}
779 while (t2.update() == false) {}
780 while (t1.update() == false) {}
781 while (t2.update() == false) {}
783 System.out.println("Checking Key-Values...");
784 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
786 String keyA = "a" + i;
787 String keyB = "b" + i;
788 String keyC = "c" + i;
789 String keyD = "d" + i;
790 String valueA = "a" + i;
791 String valueB = "b" + i;
792 String valueC = "c" + i;
793 String valueD = "d" + i;
795 IoTString iKeyA = new IoTString(keyA);
796 IoTString iKeyB = new IoTString(keyB);
797 IoTString iKeyC = new IoTString(keyC);
798 IoTString iKeyD = new IoTString(keyD);
799 IoTString iValueA = new IoTString(valueA);
800 IoTString iValueB = new IoTString(valueB);
801 IoTString iValueC = new IoTString(valueC);
802 IoTString iValueD = new IoTString(valueD);
805 IoTString testValA1 = t1.getCommitted(iKeyA);
806 IoTString testValB1 = t1.getCommitted(iKeyB);
807 IoTString testValC1 = t1.getCommitted(iKeyC);
808 IoTString testValD1 = t1.getCommitted(iKeyD);
810 IoTString testValA2 = t2.getCommitted(iKeyA);
811 IoTString testValB2 = t2.getCommitted(iKeyB);
812 IoTString testValC2 = t2.getCommitted(iKeyC);
813 IoTString testValD2 = t2.getCommitted(iKeyD);
815 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
816 System.out.println("Key-Value t1 incorrect: " + keyA + " " + testValA1);
820 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
821 System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1);
825 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
826 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
830 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
831 System.out.println("Key-Value t1 incorrect: " + keyD + " " + testValD1);
836 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
837 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
841 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
842 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
846 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
847 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
851 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
852 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
858 for (TransactionStatus status : transStatusList) {
859 if (status.getStatus() != TransactionStatus.StatusCommitted) {
861 System.out.println("Status: " + status.getStatus() + " " + status.getTransactionSequenceNumber());
868 System.out.println("Found Errors...");
870 System.out.println("No Errors Found...");
876 System.out.println();
877 System.out.println();
880 System.out.println();
881 System.out.println();
885 static void test7() throws ServerException {
887 boolean foundError = false;
888 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
890 // Setup the 2 clients
891 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, -1);
893 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, -1);
897 System.out.println("Setting up keys");
898 for (int i = 0; i < 4; i++) {
903 IoTString ia = new IoTString(a);
904 IoTString ib = new IoTString(b);
905 IoTString ic = new IoTString(c);
906 IoTString id = new IoTString(d);
907 t1.createNewKey(ia, 321);
908 t1.createNewKey(ib, 351);
909 t2.createNewKey(ic, 321);
910 t2.createNewKey(id, 351);
913 // Do Updates for the keys
914 System.out.println("Setting Key-Values...");
916 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
917 for (int i = 0; i < 4; i++) {
918 String keyB = "b" + i;
919 String valueB = "b" + (i + t);
921 IoTString iKeyB = new IoTString(keyB);
922 IoTString iValueB = new IoTString(valueB);
924 t1.startTransaction();
925 t1.getSpeculativeAtomic(iKeyB);
926 t1.addKV(iKeyB, iValueB);
927 transStatusList.add(t1.commitTransaction());
931 for (int i = 0; i < 4; i++) {
933 String keyB = "b" + i;
934 String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
935 IoTString iKeyB = new IoTString(keyB);
936 IoTString iValueB = new IoTString(valueB);
938 IoTString testValB1 = t1.getSpeculative(iKeyB);
939 IoTString testValB2 = t2.getSpeculative(iKeyB);
941 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
942 System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1);
946 if ((testValB2 != null)) {
947 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
952 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
953 for (int i = 0; i < 4; i++) {
954 String keyC = "c" + i;
955 String valueC = "c" + (i + t);
957 IoTString iKeyC = new IoTString(keyC);
958 IoTString iValueC = new IoTString(valueC);
960 t2.startTransaction();
961 t2.getSpeculativeAtomic(iKeyC);
962 t2.addKV(iKeyC, iValueC);
963 transStatusList.add(t2.commitTransaction());
967 for (int i = 0; i < 4; i++) {
968 String keyC = "c" + i;
969 String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
970 IoTString iKeyC = new IoTString(keyC);
971 IoTString iValueC = new IoTString(valueC);
973 IoTString testValC1 = t1.getSpeculative(iKeyC);
974 IoTString testValC2 = t2.getSpeculative(iKeyC);
976 if ((testValC1 != null)) {
977 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
981 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
982 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
987 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
988 for (int i = 0; i < 4; i++) {
989 String keyA = "a" + i;
990 String keyD = "d" + i;
991 String valueA = "a" + (i + t);
992 String valueD = "d" + (i + t);
994 IoTString iKeyA = new IoTString(keyA);
995 IoTString iKeyD = new IoTString(keyD);
996 IoTString iValueA = new IoTString(valueA);
997 IoTString iValueD = new IoTString(valueD);
999 t1.startTransaction();
1000 t1.addKV(iKeyA, iValueA);
1001 transStatusList.add(t1.commitTransaction());
1003 t2.startTransaction();
1004 t2.addKV(iKeyD, iValueD);
1005 transStatusList.add(t2.commitTransaction());
1009 System.out.println("Updating Clients...");
1015 System.out.println("Checking Key-Values...");
1016 for (int i = 0; i < 4; i++) {
1018 String keyA = "a" + i;
1019 String keyB = "b" + i;
1020 String keyC = "c" + i;
1021 String keyD = "d" + i;
1022 String valueA = "a" + (i + NUMBER_OF_TESTS - 1);
1023 String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
1024 String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
1025 String valueD = "d" + (i + NUMBER_OF_TESTS - 1);
1027 IoTString iKeyA = new IoTString(keyA);
1028 IoTString iKeyB = new IoTString(keyB);
1029 IoTString iKeyC = new IoTString(keyC);
1030 IoTString iKeyD = new IoTString(keyD);
1031 IoTString iValueA = new IoTString(valueA);
1032 IoTString iValueB = new IoTString(valueB);
1033 IoTString iValueC = new IoTString(valueC);
1034 IoTString iValueD = new IoTString(valueD);
1037 IoTString testValA1 = t1.getCommitted(iKeyA);
1038 IoTString testValB1 = t1.getCommitted(iKeyB);
1039 IoTString testValC1 = t1.getCommitted(iKeyC);
1040 IoTString testValD1 = t1.getCommitted(iKeyD);
1042 IoTString testValA2 = t2.getCommitted(iKeyA);
1043 IoTString testValB2 = t2.getCommitted(iKeyB);
1044 IoTString testValC2 = t2.getCommitted(iKeyC);
1045 IoTString testValD2 = t2.getCommitted(iKeyD);
1047 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
1048 System.out.println("Key-Value t1 incorrect: " + keyA + " " + testValA1);
1052 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1053 System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1);
1057 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
1058 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
1062 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
1063 System.out.println("Key-Value t1 incorrect: " + keyD + " " + testValD1);
1067 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
1068 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
1072 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
1073 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
1077 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1078 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1082 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
1083 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
1088 for (TransactionStatus status : transStatusList) {
1089 if (status.getStatus() != TransactionStatus.StatusCommitted) {
1095 System.out.println("Found Errors...");
1097 System.out.println("No Errors Found...");
1101 static void test6() throws ServerException {
1103 boolean foundError = false;
1104 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
1106 // Setup the 2 clients
1107 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, -1);
1109 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, -1);
1113 System.out.println("Setting up keys");
1114 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1119 IoTString ia = new IoTString(a);
1120 IoTString ib = new IoTString(b);
1121 IoTString ic = new IoTString(c);
1122 IoTString id = new IoTString(d);
1123 t1.createNewKey(ia, 321);
1124 t1.createNewKey(ib, 351);
1125 t2.createNewKey(ic, 321);
1126 t2.createNewKey(id, 351);
1129 // Do Updates for the keys
1130 System.out.println("Setting Key-Values...");
1131 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1132 String keyA = "a" + i;
1133 String keyB = "b" + i;
1134 String keyC = "c" + i;
1135 String keyD = "d" + i;
1136 String valueA = "a" + i;
1137 String valueB = "b" + i;
1138 String valueC = "c" + i;
1139 String valueD = "d" + i;
1141 IoTString iKeyA = new IoTString(keyA);
1142 IoTString iKeyB = new IoTString(keyB);
1143 IoTString iKeyC = new IoTString(keyC);
1144 IoTString iKeyD = new IoTString(keyD);
1145 IoTString iValueA = new IoTString(valueA);
1146 IoTString iValueB = new IoTString(valueB);
1147 IoTString iValueC = new IoTString(valueC);
1148 IoTString iValueD = new IoTString(valueD);
1150 t1.startTransaction();
1151 t1.getCommittedAtomic(iKeyA);
1152 t1.addKV(iKeyA, iValueA);
1153 transStatusList.add(t1.commitTransaction());
1155 t1.startTransaction();
1156 t1.getCommittedAtomic(iKeyB);
1157 t1.addKV(iKeyB, iValueB);
1158 transStatusList.add(t1.commitTransaction());
1160 t2.startTransaction();
1161 t2.getCommittedAtomic(iKeyC);
1162 t2.addKV(iKeyC, iValueC);
1163 transStatusList.add(t2.commitTransaction());
1165 t2.startTransaction();
1166 t2.getCommittedAtomic(iKeyD);
1167 t2.addKV(iKeyD, iValueD);
1168 transStatusList.add(t2.commitTransaction());
1171 System.out.println("Updating Clients...");
1175 System.out.println("Checking Key-Values...");
1176 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1178 String keyA = "a" + i;
1179 String keyB = "b" + i;
1180 String keyC = "c" + i;
1181 String keyD = "d" + i;
1182 String valueA = "a" + i;
1183 String valueB = "b" + i;
1184 String valueC = "c" + i;
1185 String valueD = "d" + i;
1187 IoTString iKeyA = new IoTString(keyA);
1188 IoTString iKeyB = new IoTString(keyB);
1189 IoTString iKeyC = new IoTString(keyC);
1190 IoTString iKeyD = new IoTString(keyD);
1191 IoTString iValueA = new IoTString(valueA);
1192 IoTString iValueB = new IoTString(valueB);
1193 IoTString iValueC = new IoTString(valueC);
1194 IoTString iValueD = new IoTString(valueD);
1197 IoTString testValA1 = t1.getCommitted(iKeyA);
1198 IoTString testValB1 = t1.getCommitted(iKeyB);
1199 IoTString testValC1 = t1.getCommitted(iKeyC);
1200 IoTString testValD1 = t1.getCommitted(iKeyD);
1202 IoTString testValA2 = t2.getCommitted(iKeyA);
1203 IoTString testValB2 = t2.getCommitted(iKeyB);
1204 IoTString testValC2 = t2.getCommitted(iKeyC);
1205 IoTString testValD2 = t2.getCommitted(iKeyD);
1207 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
1208 System.out.println("Key-Value t1 incorrect: " + keyA);
1212 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1213 System.out.println("Key-Value t1 incorrect: " + keyB);
1217 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
1218 System.out.println("Key-Value t1 incorrect: " + keyC);
1222 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
1223 System.out.println("Key-Value t1 incorrect: " + keyD);
1228 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
1229 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
1233 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
1234 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
1238 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1239 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1243 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
1244 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
1249 for (TransactionStatus status : transStatusList) {
1250 if (status.getStatus() != TransactionStatus.StatusCommitted) {
1256 System.out.println("Found Errors...");
1258 System.out.println("No Errors Found...");
1262 static void test5() throws ServerException {
1264 boolean foundError = false;
1265 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
1267 // Setup the 2 clients
1268 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, -1);
1270 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, -1);
1275 System.out.println("Setting up keys");
1276 for (int i = 0; i < 4; i++) {
1281 IoTString ia = new IoTString(a);
1282 IoTString ib = new IoTString(b);
1283 IoTString ic = new IoTString(c);
1284 IoTString id = new IoTString(d);
1285 t1.createNewKey(ia, 321);
1286 t1.createNewKey(ib, 351);
1287 t2.createNewKey(ic, 321);
1288 t2.createNewKey(id, 351);
1291 // Do Updates for the keys
1292 System.out.println("Setting Key-Values...");
1294 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
1295 for (int i = 0; i < 4; i++) {
1296 String keyB = "b" + i;
1297 String valueB = "b" + (i + t);
1299 IoTString iKeyB = new IoTString(keyB);
1300 IoTString iValueB = new IoTString(valueB);
1302 t1.startTransaction();
1303 t1.addKV(iKeyB, iValueB);
1304 transStatusList.add(t1.commitTransaction());
1308 for (int i = 0; i < 4; i++) {
1310 String keyB = "b" + i;
1311 String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
1312 IoTString iKeyB = new IoTString(keyB);
1313 IoTString iValueB = new IoTString(valueB);
1315 IoTString testValB1 = t1.getSpeculative(iKeyB);
1316 IoTString testValB2 = t2.getSpeculative(iKeyB);
1318 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1319 System.out.println("Key-Value t1 incorrect: " + keyB);
1323 if ((testValB2 != null)) {
1324 System.out.println("Key-Value t2 incorrect: " + keyB);
1329 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
1330 for (int i = 0; i < 4; i++) {
1331 String keyC = "c" + i;
1332 String valueC = "c" + (i + t);
1334 IoTString iKeyC = new IoTString(keyC);
1335 IoTString iValueC = new IoTString(valueC);
1337 t2.startTransaction();
1338 t2.addKV(iKeyC, iValueC);
1339 transStatusList.add(t2.commitTransaction());
1343 for (int i = 0; i < 4; i++) {
1344 String keyC = "c" + i;
1345 String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
1346 IoTString iKeyC = new IoTString(keyC);
1347 IoTString iValueC = new IoTString(valueC);
1349 IoTString testValC1 = t1.getSpeculative(iKeyC);
1350 IoTString testValC2 = t2.getSpeculative(iKeyC);
1352 if ((testValC1 != null)) {
1353 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
1357 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1358 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1363 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
1364 for (int i = 0; i < 4; i++) {
1365 String keyA = "a" + i;
1366 String keyD = "d" + i;
1367 String valueA = "a" + (i + t);
1368 String valueD = "d" + (i + t);
1370 IoTString iKeyA = new IoTString(keyA);
1371 IoTString iKeyD = new IoTString(keyD);
1372 IoTString iValueA = new IoTString(valueA);
1373 IoTString iValueD = new IoTString(valueD);
1375 t1.startTransaction();
1376 t1.addKV(iKeyA, iValueA);
1377 transStatusList.add(t1.commitTransaction());
1379 t2.startTransaction();
1380 t2.addKV(iKeyD, iValueD);
1381 transStatusList.add(t2.commitTransaction());
1385 System.out.println("Updating Clients...");
1390 System.out.println("Checking Key-Values...");
1391 for (int i = 0; i < 4; i++) {
1393 String keyA = "a" + i;
1394 String keyB = "b" + i;
1395 String keyC = "c" + i;
1396 String keyD = "d" + i;
1397 String valueA = "a" + (i + NUMBER_OF_TESTS - 1);
1398 String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
1399 String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
1400 String valueD = "d" + (i + NUMBER_OF_TESTS - 1);
1402 IoTString iKeyA = new IoTString(keyA);
1403 IoTString iKeyB = new IoTString(keyB);
1404 IoTString iKeyC = new IoTString(keyC);
1405 IoTString iKeyD = new IoTString(keyD);
1406 IoTString iValueA = new IoTString(valueA);
1407 IoTString iValueB = new IoTString(valueB);
1408 IoTString iValueC = new IoTString(valueC);
1409 IoTString iValueD = new IoTString(valueD);
1412 IoTString testValA1 = t1.getCommitted(iKeyA);
1413 IoTString testValB1 = t1.getCommitted(iKeyB);
1414 IoTString testValC1 = t1.getCommitted(iKeyC);
1415 IoTString testValD1 = t1.getCommitted(iKeyD);
1417 IoTString testValA2 = t2.getCommitted(iKeyA);
1418 IoTString testValB2 = t2.getCommitted(iKeyB);
1419 IoTString testValC2 = t2.getCommitted(iKeyC);
1420 IoTString testValD2 = t2.getCommitted(iKeyD);
1422 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
1423 System.out.println("Key-Value t1 incorrect: " + keyA + " " + testValA1);
1427 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1428 System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1);
1432 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
1433 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
1437 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
1438 System.out.println("Key-Value t1 incorrect: " + keyD + " " + testValD1);
1443 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
1444 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
1448 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
1449 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
1453 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1454 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1458 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
1459 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
1464 for (TransactionStatus status : transStatusList) {
1465 if (status.getStatus() != TransactionStatus.StatusCommitted) {
1471 System.out.println("Found Errors...");
1473 System.out.println("No Errors Found...");
1477 static void test4() throws ServerException {
1479 boolean foundError = false;
1482 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
1484 // Setup the 2 clients
1485 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, -1);
1487 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, -1);
1491 System.out.println("Setting up keys");
1492 startTime = System.currentTimeMillis();
1493 for (int i = 0; i < 4; i++) {
1498 IoTString ia = new IoTString(a);
1499 IoTString ib = new IoTString(b);
1500 IoTString ic = new IoTString(c);
1501 IoTString id = new IoTString(d);
1502 t1.createNewKey(ia, 321);
1503 t1.createNewKey(ib, 351);
1504 t2.createNewKey(ic, 321);
1505 t2.createNewKey(id, 351);
1507 endTime = System.currentTimeMillis();
1508 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1509 System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
1510 System.out.println();
1513 // Do Updates for the keys
1514 System.out.println("Setting Key-Values...");
1515 startTime = System.currentTimeMillis();
1516 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
1517 for (int i = 0; i < 4; i++) {
1518 String keyA = "a" + i;
1519 String keyB = "b" + i;
1520 String keyC = "c" + i;
1521 String keyD = "d" + i;
1522 String valueA = "a" + i;
1523 String valueB = "b" + i;
1524 String valueC = "c" + i;
1525 String valueD = "d" + i;
1527 IoTString iKeyA = new IoTString(keyA);
1528 IoTString iKeyB = new IoTString(keyB);
1529 IoTString iKeyC = new IoTString(keyC);
1530 IoTString iKeyD = new IoTString(keyD);
1531 IoTString iValueA = new IoTString(valueA);
1532 IoTString iValueB = new IoTString(valueB);
1533 IoTString iValueC = new IoTString(valueC);
1534 IoTString iValueD = new IoTString(valueD);
1536 t1.startTransaction();
1537 t1.addKV(iKeyA, iValueA);
1538 transStatusList.add(t1.commitTransaction());
1540 t1.startTransaction();
1541 t1.addKV(iKeyB, iValueB);
1542 transStatusList.add(t1.commitTransaction());
1544 t2.startTransaction();
1545 t2.addKV(iKeyC, iValueC);
1546 transStatusList.add(t2.commitTransaction());
1548 t2.startTransaction();
1549 t2.addKV(iKeyD, iValueD);
1550 transStatusList.add(t2.commitTransaction());
1553 endTime = System.currentTimeMillis();
1554 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1555 System.out.println("Time Taken Per Update: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 16)) );
1556 System.out.println();
1559 System.out.println("Updating Clients...");
1564 System.out.println("Checking Key-Values...");
1565 for (int i = 0; i < 4; i++) {
1567 String keyA = "a" + i;
1568 String keyB = "b" + i;
1569 String keyC = "c" + i;
1570 String keyD = "d" + i;
1571 String valueA = "a" + i;
1572 String valueB = "b" + i;
1573 String valueC = "c" + i;
1574 String valueD = "d" + i;
1576 IoTString iKeyA = new IoTString(keyA);
1577 IoTString iKeyB = new IoTString(keyB);
1578 IoTString iKeyC = new IoTString(keyC);
1579 IoTString iKeyD = new IoTString(keyD);
1580 IoTString iValueA = new IoTString(valueA);
1581 IoTString iValueB = new IoTString(valueB);
1582 IoTString iValueC = new IoTString(valueC);
1583 IoTString iValueD = new IoTString(valueD);
1586 IoTString testValA1 = t1.getCommitted(iKeyA);
1587 IoTString testValB1 = t1.getCommitted(iKeyB);
1588 IoTString testValC1 = t1.getCommitted(iKeyC);
1589 IoTString testValD1 = t1.getCommitted(iKeyD);
1591 IoTString testValA2 = t2.getCommitted(iKeyA);
1592 IoTString testValB2 = t2.getCommitted(iKeyB);
1593 IoTString testValC2 = t2.getCommitted(iKeyC);
1594 IoTString testValD2 = t2.getCommitted(iKeyD);
1596 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
1597 System.out.println("Key-Value t1 incorrect: " + keyA);
1601 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1602 System.out.println("Key-Value t1 incorrect: " + keyB);
1606 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
1607 System.out.println("Key-Value t1 incorrect: " + keyC);
1611 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
1612 System.out.println("Key-Value t1 incorrect: " + keyD);
1617 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
1618 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
1622 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
1623 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
1627 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1628 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1632 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
1633 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
1638 for (TransactionStatus status : transStatusList) {
1639 if (status.getStatus() != TransactionStatus.StatusCommitted) {
1645 System.out.println("Found Errors...");
1647 System.out.println("No Errors Found...");
1651 static void test3() throws ServerException {
1655 boolean foundError = false;
1657 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
1659 // Setup the 2 clients
1660 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, -1);
1662 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, -1);
1667 System.out.println("Setting up keys");
1668 startTime = System.currentTimeMillis();
1669 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1674 IoTString ia = new IoTString(a);
1675 IoTString ib = new IoTString(b);
1676 IoTString ic = new IoTString(c);
1677 IoTString id = new IoTString(d);
1678 t1.createNewKey(ia, 321);
1679 t1.createNewKey(ib, 351);
1680 t2.createNewKey(ic, 321);
1681 t2.createNewKey(id, 351);
1683 endTime = System.currentTimeMillis();
1684 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1685 System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
1686 System.out.println();
1689 // Do Updates for the keys
1690 System.out.println("Setting Key-Values...");
1691 startTime = System.currentTimeMillis();
1693 System.out.println("B...");
1694 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1695 String keyB = "b" + i;
1696 String valueB = "b" + i;
1698 IoTString iKeyB = new IoTString(keyB);
1699 IoTString iValueB = new IoTString(valueB);
1701 t1.startTransaction();
1702 t1.addKV(iKeyB, iValueB);
1703 transStatusList.add(t1.commitTransaction());
1706 System.out.println("C...");
1707 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1708 String keyC = "c" + i;
1709 String valueC = "c" + i;
1711 IoTString iKeyC = new IoTString(keyC);
1712 IoTString iValueC = new IoTString(valueC);
1714 t2.startTransaction();
1715 t2.addKV(iKeyC, iValueC);
1716 transStatusList.add(t2.commitTransaction());
1719 System.out.println("A, D...");
1720 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1721 String keyA = "a" + i;
1722 String keyD = "d" + i;
1723 String valueA = "a" + i;
1724 String valueD = "d" + i;
1726 IoTString iKeyA = new IoTString(keyA);
1727 IoTString iKeyD = new IoTString(keyD);
1728 IoTString iValueA = new IoTString(valueA);
1729 IoTString iValueD = new IoTString(valueD);
1731 t1.startTransaction();
1732 t1.addKV(iKeyA, iValueA);
1733 transStatusList.add(t1.commitTransaction());
1735 t2.startTransaction();
1736 t2.addKV(iKeyD, iValueD);
1737 transStatusList.add(t2.commitTransaction());
1739 endTime = System.currentTimeMillis();
1740 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1741 System.out.println("Time Taken Per Update: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
1742 System.out.println();
1745 System.out.println("Updating Clients...");
1750 System.out.println("Checking Key-Values...");
1751 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1753 String keyA = "a" + i;
1754 String keyB = "b" + i;
1755 String keyC = "c" + i;
1756 String keyD = "d" + i;
1757 String valueA = "a" + i;
1758 String valueB = "b" + i;
1759 String valueC = "c" + i;
1760 String valueD = "d" + i;
1762 IoTString iKeyA = new IoTString(keyA);
1763 IoTString iKeyB = new IoTString(keyB);
1764 IoTString iKeyC = new IoTString(keyC);
1765 IoTString iKeyD = new IoTString(keyD);
1766 IoTString iValueA = new IoTString(valueA);
1767 IoTString iValueB = new IoTString(valueB);
1768 IoTString iValueC = new IoTString(valueC);
1769 IoTString iValueD = new IoTString(valueD);
1772 IoTString testValA1 = t1.getCommitted(iKeyA);
1773 IoTString testValB1 = t1.getCommitted(iKeyB);
1774 IoTString testValC1 = t1.getCommitted(iKeyC);
1775 IoTString testValD1 = t1.getCommitted(iKeyD);
1777 IoTString testValA2 = t2.getCommitted(iKeyA);
1778 IoTString testValB2 = t2.getCommitted(iKeyB);
1779 IoTString testValC2 = t2.getCommitted(iKeyC);
1780 IoTString testValD2 = t2.getCommitted(iKeyD);
1782 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
1783 System.out.println("Key-Value t1 incorrect: " + keyA);
1787 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1788 System.out.println("Key-Value t1 incorrect: " + keyB);
1792 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
1793 System.out.println("Key-Value t1 incorrect: " + keyC);
1797 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
1798 System.out.println("Key-Value t1 incorrect: " + keyD);
1803 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
1804 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
1808 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
1809 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
1813 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1814 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1818 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
1819 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
1824 for (TransactionStatus status : transStatusList) {
1825 if (status.getStatus() != TransactionStatus.StatusCommitted) {
1831 System.out.println("Found Errors...");
1833 System.out.println("No Errors Found...");
1837 static void test2() throws ServerException {
1839 boolean foundError = false;
1842 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
1844 // Setup the 2 clients
1845 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, -1);
1847 System.out.println("T1 Ready");
1849 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, -1);
1851 System.out.println("T2 Ready");
1854 System.out.println("Setting up keys");
1855 startTime = System.currentTimeMillis();
1856 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1857 System.out.println(i);
1862 IoTString ia = new IoTString(a);
1863 IoTString ib = new IoTString(b);
1864 IoTString ic = new IoTString(c);
1865 IoTString id = new IoTString(d);
1866 t1.createNewKey(ia, 321);
1867 t1.createNewKey(ib, 351);
1868 t2.createNewKey(ic, 321);
1869 t2.createNewKey(id, 351);
1871 endTime = System.currentTimeMillis();
1872 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1873 System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
1874 System.out.println();
1876 // Do Updates for the keys
1877 System.out.println("Setting Key-Values...");
1878 startTime = System.currentTimeMillis();
1879 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1880 System.out.println(i);
1881 String keyA = "a" + i;
1882 String keyB = "b" + i;
1883 String keyC = "c" + i;
1884 String keyD = "d" + i;
1885 String valueA = "a" + i;
1886 String valueB = "b" + i;
1887 String valueC = "c" + i;
1888 String valueD = "d" + i;
1890 IoTString iKeyA = new IoTString(keyA);
1891 IoTString iKeyB = new IoTString(keyB);
1892 IoTString iKeyC = new IoTString(keyC);
1893 IoTString iKeyD = new IoTString(keyD);
1894 IoTString iValueA = new IoTString(valueA);
1895 IoTString iValueB = new IoTString(valueB);
1896 IoTString iValueC = new IoTString(valueC);
1897 IoTString iValueD = new IoTString(valueD);
1900 t1.startTransaction();
1901 t1.addKV(iKeyA, iValueA);
1902 transStatusList.add(t1.commitTransaction());
1905 t1.startTransaction();
1906 t1.addKV(iKeyB, iValueB);
1907 transStatusList.add(t1.commitTransaction());
1909 t2.startTransaction();
1910 t2.addKV(iKeyC, iValueC);
1911 transStatusList.add(t2.commitTransaction());
1913 t2.startTransaction();
1914 t2.addKV(iKeyD, iValueD);
1915 transStatusList.add(t2.commitTransaction());
1918 endTime = System.currentTimeMillis();
1919 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1920 System.out.println("Time Taken Per Update: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
1921 System.out.println();
1924 System.out.println("Updating Clients...");
1929 System.out.println("Checking Key-Values...");
1930 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1932 String keyA = "a" + i;
1933 String keyB = "b" + i;
1934 String keyC = "c" + i;
1935 String keyD = "d" + i;
1936 String valueA = "a" + i;
1937 String valueB = "b" + i;
1938 String valueC = "c" + i;
1939 String valueD = "d" + i;
1941 IoTString iKeyA = new IoTString(keyA);
1942 IoTString iKeyB = new IoTString(keyB);
1943 IoTString iKeyC = new IoTString(keyC);
1944 IoTString iKeyD = new IoTString(keyD);
1945 IoTString iValueA = new IoTString(valueA);
1946 IoTString iValueB = new IoTString(valueB);
1947 IoTString iValueC = new IoTString(valueC);
1948 IoTString iValueD = new IoTString(valueD);
1951 IoTString testValA1 = t1.getCommitted(iKeyA);
1952 IoTString testValB1 = t1.getCommitted(iKeyB);
1953 IoTString testValC1 = t1.getCommitted(iKeyC);
1954 IoTString testValD1 = t1.getCommitted(iKeyD);
1956 IoTString testValA2 = t2.getCommitted(iKeyA);
1957 IoTString testValB2 = t2.getCommitted(iKeyB);
1958 IoTString testValC2 = t2.getCommitted(iKeyC);
1959 IoTString testValD2 = t2.getCommitted(iKeyD);
1961 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
1962 System.out.println("Key-Value t1 incorrect: " + keyA);
1966 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1967 System.out.println("Key-Value t1 incorrect: " + keyB);
1971 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
1972 System.out.println("Key-Value t1 incorrect: " + keyC);
1976 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
1977 System.out.println("Key-Value t1 incorrect: " + keyD);
1982 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
1983 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
1987 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
1988 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
1992 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1993 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1997 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
1998 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
2003 for (TransactionStatus status : transStatusList) {
2004 if (status.getStatus() != TransactionStatus.StatusCommitted) {
2006 System.out.println(status.getStatus());
2011 System.out.println("Found Errors...");
2013 System.out.println("No Errors Found...");
2016 // System.out.println();
2017 // System.out.println();
2020 // System.out.println();
2021 // System.out.println();