4 import java.util.ArrayList;
14 public static final int NUMBER_OF_TESTS = 10;
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);
147 t1.startTransaction();
148 t1.addKV(iKeyA, iValueA);
149 transStatusList.add(t1.commitTransaction());
151 t1.startTransaction();
152 t1.addKV(iKeyB, iValueB);
153 transStatusList.add(t1.commitTransaction());
155 t2.startTransaction();
156 t2.addKV(iKeyC, iValueC);
157 transStatusList.add(t2.commitTransaction());
159 t2.startTransaction();
160 t2.addKV(iKeyD, iValueD);
161 transStatusList.add(t2.commitTransaction());
164 System.out.println("Updating...");
165 while (t1.update() == false) {}
166 while (t2.update() == false) {}
167 while (t1.update() == false) {}
168 while (t2.update() == false) {}
170 System.out.println("Checking Key-Values...");
171 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
173 String keyA = "a" + i;
174 String keyB = "b" + i;
175 String keyC = "c" + i;
176 String keyD = "d" + i;
177 String valueA = "a" + i;
178 String valueB = "b" + i;
179 String valueC = "c" + i;
180 String valueD = "d" + i;
182 IoTString iKeyA = new IoTString(keyA);
183 IoTString iKeyB = new IoTString(keyB);
184 IoTString iKeyC = new IoTString(keyC);
185 IoTString iKeyD = new IoTString(keyD);
186 IoTString iValueA = new IoTString(valueA);
187 IoTString iValueB = new IoTString(valueB);
188 IoTString iValueC = new IoTString(valueC);
189 IoTString iValueD = new IoTString(valueD);
192 IoTString testValA1 = t1.getCommitted(iKeyA);
193 IoTString testValB1 = t1.getCommitted(iKeyB);
194 IoTString testValC1 = t1.getCommitted(iKeyC);
195 IoTString testValD1 = t1.getCommitted(iKeyD);
197 IoTString testValA2 = t2.getCommitted(iKeyA);
198 IoTString testValB2 = t2.getCommitted(iKeyB);
199 IoTString testValC2 = t2.getCommitted(iKeyC);
200 IoTString testValD2 = t2.getCommitted(iKeyD);
202 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
203 System.out.println("Key-Value t1 incorrect: " + keyA + " " + testValA1);
207 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
208 System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1);
212 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
213 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
217 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
218 System.out.println("Key-Value t1 incorrect: " + keyD + " " + testValD1);
223 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
224 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
228 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
229 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
233 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
234 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
238 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
239 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
244 for (TransactionStatus status : transStatusList) {
245 if (status.getStatus() != TransactionStatus.StatusCommitted) {
251 System.out.println("Found Errors...");
253 System.out.println("No Errors Found...");
260 static void test10() {
262 boolean foundError = false;
263 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
265 // Setup the 2 clients
266 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, 6000);
267 System.out.println("Init Table t1s");
272 } catch (Exception e) { }
274 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, 6001);
275 while (t2.update() == false) {}
277 t1.addLocalCommunication(351, "127.0.0.1", 6001);
278 t2.addLocalCommunication(321, "127.0.0.1", 6000);
282 System.out.println("Setting up keys");
283 for (int i = 0; i < 4; i++) {
288 IoTString ia = new IoTString(a);
289 IoTString ib = new IoTString(b);
290 IoTString ic = new IoTString(c);
291 IoTString id = new IoTString(d);
294 t1.createNewKey(ia, 321);
296 } catch (Exception e) { }
301 t1.createNewKey(ib, 351);
303 } catch (Exception e) { }
308 t2.createNewKey(ic, 321);
310 } catch (Exception e) { }
315 t2.createNewKey(id, 351);
317 } catch (Exception e) { }
322 // Do Updates for the keys
323 System.out.println("B========================");
324 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
325 for (int i = 0; i < 4; i++) {
327 System.out.println(i);
329 String keyB = "b" + i;
330 String valueB = "b" + (i + t);
332 IoTString iKeyB = new IoTString(keyB);
333 IoTString iValueB = new IoTString(valueB);
335 t1.startTransaction();
336 System.out.println(t1.getSpeculativeAtomic(iKeyB));
337 t1.addKV(iKeyB, iValueB);
338 transStatusList.add(t1.commitTransaction());
341 System.out.println();
344 System.out.println("C========================");
345 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
346 for (int i = 0; i < 4; i++) {
347 System.out.println(i);
349 String keyC = "c" + i;
350 String valueC = "c" + (i + t);
352 IoTString iKeyC = new IoTString(keyC);
353 IoTString iValueC = new IoTString(valueC);
355 t2.startTransaction();
356 System.out.println(t2.getSpeculativeAtomic(iKeyC));
357 t2.addKV(iKeyC, iValueC);
358 transStatusList.add(t2.commitTransaction());
361 System.out.println();
364 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
365 for (int i = 0; i < 4; i++) {
366 String keyA = "a" + i;
367 String keyD = "d" + i;
368 String valueA = "a" + (i + t);
369 String valueD = "d" + (i + t);
371 IoTString iKeyA = new IoTString(keyA);
372 IoTString iKeyD = new IoTString(keyD);
373 IoTString iValueA = new IoTString(valueA);
374 IoTString iValueD = new IoTString(valueD);
377 t1.startTransaction();
378 t1.addKV(iKeyA, iValueA);
379 transStatusList.add(t1.commitTransaction());
382 t2.startTransaction();
383 t2.addKV(iKeyD, iValueD);
384 transStatusList.add(t2.commitTransaction());
385 System.out.println();
388 System.out.println();
390 System.out.println("Updating...");
391 System.out.println("t1 -=-=-=-=-=-=-=-");
392 while (t1.update() == false) {}
393 System.out.println("t2 -=-=-=-=-=-=-=-");
394 while (t2.update() == false) {}
395 System.out.println("t1 -=-=-=-=-=-=-=-");
396 while (t1.update() == false) {}
397 System.out.println("t2 -=-=-=-=-=-=-=-");
398 while (t2.update() == false) {}
401 System.out.println("Checking Key-Values...");
402 for (int i = 0; i < 4; i++) {
404 String keyA = "a" + i;
405 String keyB = "b" + i;
406 String keyC = "c" + i;
407 String keyD = "d" + i;
408 String valueA = "a" + (i + NUMBER_OF_TESTS - 1);
409 String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
410 String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
411 String valueD = "d" + (i + NUMBER_OF_TESTS - 1);
413 IoTString iKeyA = new IoTString(keyA);
414 IoTString iKeyB = new IoTString(keyB);
415 IoTString iKeyC = new IoTString(keyC);
416 IoTString iKeyD = new IoTString(keyD);
417 IoTString iValueA = new IoTString(valueA);
418 IoTString iValueB = new IoTString(valueB);
419 IoTString iValueC = new IoTString(valueC);
420 IoTString iValueD = new IoTString(valueD);
423 IoTString testValA1 = t1.getCommitted(iKeyA);
424 IoTString testValB1 = t1.getCommitted(iKeyB);
425 IoTString testValC1 = t1.getCommitted(iKeyC);
426 IoTString testValD1 = t1.getCommitted(iKeyD);
428 IoTString testValA2 = t2.getCommitted(iKeyA);
429 IoTString testValB2 = t2.getCommitted(iKeyB);
430 IoTString testValC2 = t2.getCommitted(iKeyC);
431 IoTString testValD2 = t2.getCommitted(iKeyD);
433 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
434 System.out.println("Key-Value t1 incorrect: " + keyA + " " + testValA1);
438 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
439 System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1);
443 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
444 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
448 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
449 System.out.println("Key-Value t1 incorrect: " + keyD + " " + testValD1);
453 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
454 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
458 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
459 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
463 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
464 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
468 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
469 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
475 for (TransactionStatus status : transStatusList) {
476 if (status.getStatus() != TransactionStatus.StatusCommitted) {
478 System.out.println(counter + " Status: " + status.getStatus());
484 System.out.println("Found Errors...");
486 System.out.println("No Errors Found...");
493 static void test9() {
495 boolean foundError = false;
496 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
498 // Setup the 2 clients
499 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, 6000);
501 System.out.println("Init Table t1s");
506 } catch (Exception e) { }
510 System.out.println("Update Table t2");
511 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, 6001);
512 while (t2.update() == false) {}
514 t1.addLocalCommunication(351, "127.0.0.1", 6001);
515 t2.addLocalCommunication(321, "127.0.0.1", 6000);
518 System.out.println("Setting up keys");
519 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
520 System.out.println(i);
526 IoTString ia = new IoTString(a);
527 IoTString ib = new IoTString(b);
528 IoTString ic = new IoTString(c);
529 IoTString id = new IoTString(d);
533 t1.createNewKey(ia, 321);
535 } catch (Exception e) { }
540 t1.createNewKey(ib, 351);
542 } catch (Exception e) { }
547 t2.createNewKey(ic, 321);
549 } catch (Exception e) { }
554 t2.createNewKey(id, 351);
556 } catch (Exception e) { }
560 System.out.println("A, D...");
561 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
562 String keyA = "a" + i;
563 String keyD = "d" + i;
564 String valueA = "a" + i;
565 String valueD = "d" + i;
567 IoTString iKeyA = new IoTString(keyA);
568 IoTString iKeyD = new IoTString(keyD);
569 IoTString iValueA = new IoTString(valueA);
570 IoTString iValueD = new IoTString(valueD);
572 t1.startTransaction();
573 t1.addKV(iKeyA, iValueA);
574 transStatusList.add(t1.commitTransaction());
576 t2.startTransaction();
577 t2.addKV(iKeyD, iValueD);
578 transStatusList.add(t2.commitTransaction());
581 while (t1.updateFromLocal(351) == false) {}
582 while (t2.updateFromLocal(321) == false) {}
585 System.out.println("Updating...");
586 System.out.println("Checking Key-Values...");
588 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
590 String keyA = "a" + i;
591 String keyD = "d" + i;
592 String valueA = "a" + i;
593 String valueD = "d" + i;
596 IoTString iKeyA = new IoTString(keyA);
597 IoTString iKeyD = new IoTString(keyD);
598 IoTString iValueA = new IoTString(valueA);
599 IoTString iValueD = new IoTString(valueD);
602 IoTString testValA1 = t1.getCommitted(iKeyA);
603 IoTString testValD1 = t1.getCommitted(iKeyD);
604 IoTString testValA2 = t2.getCommitted(iKeyA);
605 IoTString testValD2 = t2.getCommitted(iKeyD);
608 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
609 System.out.println("Key-Value t1 incorrect: " + keyA + " " + testValA1);
613 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
614 System.out.println("Key-Value t1 incorrect: " + keyD + " " + testValD1);
619 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
620 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
624 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
625 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
630 for (TransactionStatus status : transStatusList) {
631 if (status.getStatus() != TransactionStatus.StatusCommitted) {
637 System.out.println("Found Errors...");
639 System.out.println("No Errors Found...");
646 static void test8() {
648 boolean foundError = false;
649 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
651 // Setup the 2 clients
652 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, 6000);
654 System.out.println("Init Table t1s");
660 } catch (Exception e) { }
664 System.out.println("Update Table t2");
665 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, 6001);
666 while (t2.update() == false) {}
668 t1.addLocalCommunication(351, "127.0.0.1", 6001);
669 t2.addLocalCommunication(321, "127.0.0.1", 6000);
672 System.out.println("Setting up keys");
673 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
674 System.out.println(i);
680 IoTString ia = new IoTString(a);
681 IoTString ib = new IoTString(b);
682 IoTString ic = new IoTString(c);
683 IoTString id = new IoTString(d);
687 t1.createNewKey(ia, 321);
689 } catch (Exception e) { }
694 t1.createNewKey(ib, 351);
696 } catch (Exception e) { }
701 t2.createNewKey(ic, 321);
703 } catch (Exception e) { }
708 t2.createNewKey(id, 351);
710 } catch (Exception e) { }
714 // Do Updates for the keys
715 System.out.println("Setting Key-Values...");
716 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
717 System.out.println(i);
718 String keyA = "a" + i;
719 String keyB = "b" + i;
720 String keyC = "c" + i;
721 String keyD = "d" + i;
722 String valueA = "a" + i;
723 String valueB = "b" + i;
724 String valueC = "c" + i;
725 String valueD = "d" + i;
727 IoTString iKeyA = new IoTString(keyA);
728 IoTString iKeyB = new IoTString(keyB);
729 IoTString iKeyC = new IoTString(keyC);
730 IoTString iKeyD = new IoTString(keyD);
731 IoTString iValueA = new IoTString(valueA);
732 IoTString iValueB = new IoTString(valueB);
733 IoTString iValueC = new IoTString(valueC);
734 IoTString iValueD = new IoTString(valueD);
737 String keyAPrev = "a" + (i - 1);
738 String keyBPrev = "b" + (i - 1);
739 String keyCPrev = "c" + (i - 1);
740 String keyDPrev = "d" + (i - 1);
741 String valueAPrev = "a" + (i - 1);
742 String valueBPrev = "b" + (i - 1);
743 String valueCPrev = "c" + (i - 1);
744 String valueDPrev = "d" + (i - 1);
746 IoTString iKeyAPrev = new IoTString(keyAPrev);
747 IoTString iKeyBPrev = new IoTString(keyBPrev);
748 IoTString iKeyCPrev = new IoTString(keyCPrev);
749 IoTString iKeyDPrev = new IoTString(keyDPrev);
750 IoTString iValueAPrev = new IoTString(valueAPrev);
751 IoTString iValueBPrev = new IoTString(valueBPrev);
752 IoTString iValueCPrev = new IoTString(valueCPrev);
753 IoTString iValueDPrev = new IoTString(valueDPrev);
755 t1.startTransaction();
756 t1.addKV(iKeyA, iValueA);
757 transStatusList.add(t1.commitTransaction());
759 t1.startTransaction();
760 t1.addKV(iKeyB, iValueB);
761 transStatusList.add(t1.commitTransaction());
763 t2.startTransaction();
764 t2.addKV(iKeyC, iValueC);
765 transStatusList.add(t2.commitTransaction());
767 t2.startTransaction();
768 t2.addKV(iKeyD, iValueD);
769 transStatusList.add(t2.commitTransaction());
772 System.out.println("Updating...");
773 while (t1.update() == false) {}
774 while (t2.update() == false) {}
775 while (t1.update() == false) {}
777 System.out.println("Checking Key-Values...");
778 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
780 String keyA = "a" + i;
781 String keyB = "b" + i;
782 String keyC = "c" + i;
783 String keyD = "d" + i;
784 String valueA = "a" + i;
785 String valueB = "b" + i;
786 String valueC = "c" + i;
787 String valueD = "d" + i;
789 IoTString iKeyA = new IoTString(keyA);
790 IoTString iKeyB = new IoTString(keyB);
791 IoTString iKeyC = new IoTString(keyC);
792 IoTString iKeyD = new IoTString(keyD);
793 IoTString iValueA = new IoTString(valueA);
794 IoTString iValueB = new IoTString(valueB);
795 IoTString iValueC = new IoTString(valueC);
796 IoTString iValueD = new IoTString(valueD);
799 IoTString testValA1 = t1.getCommitted(iKeyA);
800 IoTString testValB1 = t1.getCommitted(iKeyB);
801 IoTString testValC1 = t1.getCommitted(iKeyC);
802 IoTString testValD1 = t1.getCommitted(iKeyD);
804 IoTString testValA2 = t2.getCommitted(iKeyA);
805 IoTString testValB2 = t2.getCommitted(iKeyB);
806 IoTString testValC2 = t2.getCommitted(iKeyC);
807 IoTString testValD2 = t2.getCommitted(iKeyD);
809 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
810 System.out.println("Key-Value t1 incorrect: " + keyA + " " + testValA1);
814 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
815 System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1);
819 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
820 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
824 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
825 System.out.println("Key-Value t1 incorrect: " + keyD + " " + testValD1);
830 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
831 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
835 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
836 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
840 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
841 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
845 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
846 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
851 for (TransactionStatus status : transStatusList) {
852 if (status.getStatus() != TransactionStatus.StatusCommitted) {
858 System.out.println("Found Errors...");
860 System.out.println("No Errors Found...");
867 static void test7() throws ServerException {
869 boolean foundError = false;
870 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
872 // Setup the 2 clients
873 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, -1);
875 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, -1);
879 System.out.println("Setting up keys");
880 for (int i = 0; i < 4; i++) {
885 IoTString ia = new IoTString(a);
886 IoTString ib = new IoTString(b);
887 IoTString ic = new IoTString(c);
888 IoTString id = new IoTString(d);
889 t1.createNewKey(ia, 321);
890 t1.createNewKey(ib, 351);
891 t2.createNewKey(ic, 321);
892 t2.createNewKey(id, 351);
895 // Do Updates for the keys
896 System.out.println("Setting Key-Values...");
898 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
899 for (int i = 0; i < 4; i++) {
900 String keyB = "b" + i;
901 String valueB = "b" + (i + t);
903 IoTString iKeyB = new IoTString(keyB);
904 IoTString iValueB = new IoTString(valueB);
906 t1.startTransaction();
907 t1.getSpeculativeAtomic(iKeyB);
908 t1.addKV(iKeyB, iValueB);
909 transStatusList.add(t1.commitTransaction());
913 for (int i = 0; i < 4; i++) {
915 String keyB = "b" + i;
916 String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
917 IoTString iKeyB = new IoTString(keyB);
918 IoTString iValueB = new IoTString(valueB);
920 IoTString testValB1 = t1.getSpeculative(iKeyB);
921 IoTString testValB2 = t2.getSpeculative(iKeyB);
923 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
924 System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1);
928 if ((testValB2 != null)) {
929 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
934 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
935 for (int i = 0; i < 4; i++) {
936 String keyC = "c" + i;
937 String valueC = "c" + (i + t);
939 IoTString iKeyC = new IoTString(keyC);
940 IoTString iValueC = new IoTString(valueC);
942 t2.startTransaction();
943 t2.getSpeculativeAtomic(iKeyC);
944 t2.addKV(iKeyC, iValueC);
945 transStatusList.add(t2.commitTransaction());
949 for (int i = 0; i < 4; i++) {
950 String keyC = "c" + i;
951 String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
952 IoTString iKeyC = new IoTString(keyC);
953 IoTString iValueC = new IoTString(valueC);
955 IoTString testValC1 = t1.getSpeculative(iKeyC);
956 IoTString testValC2 = t2.getSpeculative(iKeyC);
958 if ((testValC1 != null)) {
959 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
963 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
964 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
969 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
970 for (int i = 0; i < 4; i++) {
971 String keyA = "a" + i;
972 String keyD = "d" + i;
973 String valueA = "a" + (i + t);
974 String valueD = "d" + (i + t);
976 IoTString iKeyA = new IoTString(keyA);
977 IoTString iKeyD = new IoTString(keyD);
978 IoTString iValueA = new IoTString(valueA);
979 IoTString iValueD = new IoTString(valueD);
981 t1.startTransaction();
982 t1.addKV(iKeyA, iValueA);
983 transStatusList.add(t1.commitTransaction());
985 t2.startTransaction();
986 t2.addKV(iKeyD, iValueD);
987 transStatusList.add(t2.commitTransaction());
991 System.out.println("Updating Clients...");
997 System.out.println("Checking Key-Values...");
998 for (int i = 0; i < 4; i++) {
1000 String keyA = "a" + i;
1001 String keyB = "b" + i;
1002 String keyC = "c" + i;
1003 String keyD = "d" + i;
1004 String valueA = "a" + (i + NUMBER_OF_TESTS - 1);
1005 String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
1006 String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
1007 String valueD = "d" + (i + NUMBER_OF_TESTS - 1);
1009 IoTString iKeyA = new IoTString(keyA);
1010 IoTString iKeyB = new IoTString(keyB);
1011 IoTString iKeyC = new IoTString(keyC);
1012 IoTString iKeyD = new IoTString(keyD);
1013 IoTString iValueA = new IoTString(valueA);
1014 IoTString iValueB = new IoTString(valueB);
1015 IoTString iValueC = new IoTString(valueC);
1016 IoTString iValueD = new IoTString(valueD);
1019 IoTString testValA1 = t1.getCommitted(iKeyA);
1020 IoTString testValB1 = t1.getCommitted(iKeyB);
1021 IoTString testValC1 = t1.getCommitted(iKeyC);
1022 IoTString testValD1 = t1.getCommitted(iKeyD);
1024 IoTString testValA2 = t2.getCommitted(iKeyA);
1025 IoTString testValB2 = t2.getCommitted(iKeyB);
1026 IoTString testValC2 = t2.getCommitted(iKeyC);
1027 IoTString testValD2 = t2.getCommitted(iKeyD);
1029 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
1030 System.out.println("Key-Value t1 incorrect: " + keyA + " " + testValA1);
1034 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1035 System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1);
1039 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
1040 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
1044 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
1045 System.out.println("Key-Value t1 incorrect: " + keyD + " " + testValD1);
1049 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
1050 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
1054 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
1055 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
1059 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1060 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1064 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
1065 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
1070 for (TransactionStatus status : transStatusList) {
1071 if (status.getStatus() != TransactionStatus.StatusCommitted) {
1077 System.out.println("Found Errors...");
1079 System.out.println("No Errors Found...");
1083 static void test6() throws ServerException {
1085 boolean foundError = false;
1086 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
1088 // Setup the 2 clients
1089 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, -1);
1091 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, -1);
1095 System.out.println("Setting up keys");
1096 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1101 IoTString ia = new IoTString(a);
1102 IoTString ib = new IoTString(b);
1103 IoTString ic = new IoTString(c);
1104 IoTString id = new IoTString(d);
1105 t1.createNewKey(ia, 321);
1106 t1.createNewKey(ib, 351);
1107 t2.createNewKey(ic, 321);
1108 t2.createNewKey(id, 351);
1111 // Do Updates for the keys
1112 System.out.println("Setting Key-Values...");
1113 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1114 String keyA = "a" + i;
1115 String keyB = "b" + i;
1116 String keyC = "c" + i;
1117 String keyD = "d" + i;
1118 String valueA = "a" + i;
1119 String valueB = "b" + i;
1120 String valueC = "c" + i;
1121 String valueD = "d" + i;
1123 IoTString iKeyA = new IoTString(keyA);
1124 IoTString iKeyB = new IoTString(keyB);
1125 IoTString iKeyC = new IoTString(keyC);
1126 IoTString iKeyD = new IoTString(keyD);
1127 IoTString iValueA = new IoTString(valueA);
1128 IoTString iValueB = new IoTString(valueB);
1129 IoTString iValueC = new IoTString(valueC);
1130 IoTString iValueD = new IoTString(valueD);
1132 t1.startTransaction();
1133 t1.getCommittedAtomic(iKeyA);
1134 t1.addKV(iKeyA, iValueA);
1135 transStatusList.add(t1.commitTransaction());
1137 t1.startTransaction();
1138 t1.getCommittedAtomic(iKeyB);
1139 t1.addKV(iKeyB, iValueB);
1140 transStatusList.add(t1.commitTransaction());
1142 t2.startTransaction();
1143 t2.getCommittedAtomic(iKeyC);
1144 t2.addKV(iKeyC, iValueC);
1145 transStatusList.add(t2.commitTransaction());
1147 t2.startTransaction();
1148 t2.getCommittedAtomic(iKeyD);
1149 t2.addKV(iKeyD, iValueD);
1150 transStatusList.add(t2.commitTransaction());
1153 System.out.println("Updating Clients...");
1157 System.out.println("Checking Key-Values...");
1158 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1160 String keyA = "a" + i;
1161 String keyB = "b" + i;
1162 String keyC = "c" + i;
1163 String keyD = "d" + i;
1164 String valueA = "a" + i;
1165 String valueB = "b" + i;
1166 String valueC = "c" + i;
1167 String valueD = "d" + i;
1169 IoTString iKeyA = new IoTString(keyA);
1170 IoTString iKeyB = new IoTString(keyB);
1171 IoTString iKeyC = new IoTString(keyC);
1172 IoTString iKeyD = new IoTString(keyD);
1173 IoTString iValueA = new IoTString(valueA);
1174 IoTString iValueB = new IoTString(valueB);
1175 IoTString iValueC = new IoTString(valueC);
1176 IoTString iValueD = new IoTString(valueD);
1179 IoTString testValA1 = t1.getCommitted(iKeyA);
1180 IoTString testValB1 = t1.getCommitted(iKeyB);
1181 IoTString testValC1 = t1.getCommitted(iKeyC);
1182 IoTString testValD1 = t1.getCommitted(iKeyD);
1184 IoTString testValA2 = t2.getCommitted(iKeyA);
1185 IoTString testValB2 = t2.getCommitted(iKeyB);
1186 IoTString testValC2 = t2.getCommitted(iKeyC);
1187 IoTString testValD2 = t2.getCommitted(iKeyD);
1189 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
1190 System.out.println("Key-Value t1 incorrect: " + keyA);
1194 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1195 System.out.println("Key-Value t1 incorrect: " + keyB);
1199 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
1200 System.out.println("Key-Value t1 incorrect: " + keyC);
1204 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
1205 System.out.println("Key-Value t1 incorrect: " + keyD);
1210 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
1211 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
1215 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
1216 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
1220 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1221 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1225 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
1226 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
1231 for (TransactionStatus status : transStatusList) {
1232 if (status.getStatus() != TransactionStatus.StatusCommitted) {
1238 System.out.println("Found Errors...");
1240 System.out.println("No Errors Found...");
1244 static void test5() throws ServerException {
1246 boolean foundError = false;
1247 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
1249 // Setup the 2 clients
1250 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, -1);
1252 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, -1);
1257 System.out.println("Setting up keys");
1258 for (int i = 0; i < 4; i++) {
1263 IoTString ia = new IoTString(a);
1264 IoTString ib = new IoTString(b);
1265 IoTString ic = new IoTString(c);
1266 IoTString id = new IoTString(d);
1267 t1.createNewKey(ia, 321);
1268 t1.createNewKey(ib, 351);
1269 t2.createNewKey(ic, 321);
1270 t2.createNewKey(id, 351);
1273 // Do Updates for the keys
1274 System.out.println("Setting Key-Values...");
1276 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
1277 for (int i = 0; i < 4; i++) {
1278 String keyB = "b" + i;
1279 String valueB = "b" + (i + t);
1281 IoTString iKeyB = new IoTString(keyB);
1282 IoTString iValueB = new IoTString(valueB);
1284 t1.startTransaction();
1285 t1.addKV(iKeyB, iValueB);
1286 transStatusList.add(t1.commitTransaction());
1290 for (int i = 0; i < 4; i++) {
1292 String keyB = "b" + i;
1293 String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
1294 IoTString iKeyB = new IoTString(keyB);
1295 IoTString iValueB = new IoTString(valueB);
1297 IoTString testValB1 = t1.getSpeculative(iKeyB);
1298 IoTString testValB2 = t2.getSpeculative(iKeyB);
1300 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1301 System.out.println("Key-Value t1 incorrect: " + keyB);
1305 if ((testValB2 != null)) {
1306 System.out.println("Key-Value t2 incorrect: " + keyB);
1311 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
1312 for (int i = 0; i < 4; i++) {
1313 String keyC = "c" + i;
1314 String valueC = "c" + (i + t);
1316 IoTString iKeyC = new IoTString(keyC);
1317 IoTString iValueC = new IoTString(valueC);
1319 t2.startTransaction();
1320 t2.addKV(iKeyC, iValueC);
1321 transStatusList.add(t2.commitTransaction());
1325 for (int i = 0; i < 4; i++) {
1326 String keyC = "c" + i;
1327 String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
1328 IoTString iKeyC = new IoTString(keyC);
1329 IoTString iValueC = new IoTString(valueC);
1331 IoTString testValC1 = t1.getSpeculative(iKeyC);
1332 IoTString testValC2 = t2.getSpeculative(iKeyC);
1334 if ((testValC1 != null)) {
1335 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
1339 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1340 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1345 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
1346 for (int i = 0; i < 4; i++) {
1347 String keyA = "a" + i;
1348 String keyD = "d" + i;
1349 String valueA = "a" + (i + t);
1350 String valueD = "d" + (i + t);
1352 IoTString iKeyA = new IoTString(keyA);
1353 IoTString iKeyD = new IoTString(keyD);
1354 IoTString iValueA = new IoTString(valueA);
1355 IoTString iValueD = new IoTString(valueD);
1357 t1.startTransaction();
1358 t1.addKV(iKeyA, iValueA);
1359 transStatusList.add(t1.commitTransaction());
1361 t2.startTransaction();
1362 t2.addKV(iKeyD, iValueD);
1363 transStatusList.add(t2.commitTransaction());
1367 System.out.println("Updating Clients...");
1372 System.out.println("Checking Key-Values...");
1373 for (int i = 0; i < 4; i++) {
1375 String keyA = "a" + i;
1376 String keyB = "b" + i;
1377 String keyC = "c" + i;
1378 String keyD = "d" + i;
1379 String valueA = "a" + (i + NUMBER_OF_TESTS - 1);
1380 String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
1381 String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
1382 String valueD = "d" + (i + NUMBER_OF_TESTS - 1);
1384 IoTString iKeyA = new IoTString(keyA);
1385 IoTString iKeyB = new IoTString(keyB);
1386 IoTString iKeyC = new IoTString(keyC);
1387 IoTString iKeyD = new IoTString(keyD);
1388 IoTString iValueA = new IoTString(valueA);
1389 IoTString iValueB = new IoTString(valueB);
1390 IoTString iValueC = new IoTString(valueC);
1391 IoTString iValueD = new IoTString(valueD);
1394 IoTString testValA1 = t1.getCommitted(iKeyA);
1395 IoTString testValB1 = t1.getCommitted(iKeyB);
1396 IoTString testValC1 = t1.getCommitted(iKeyC);
1397 IoTString testValD1 = t1.getCommitted(iKeyD);
1399 IoTString testValA2 = t2.getCommitted(iKeyA);
1400 IoTString testValB2 = t2.getCommitted(iKeyB);
1401 IoTString testValC2 = t2.getCommitted(iKeyC);
1402 IoTString testValD2 = t2.getCommitted(iKeyD);
1404 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
1405 System.out.println("Key-Value t1 incorrect: " + keyA + " " + testValA1);
1409 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1410 System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1);
1414 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
1415 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
1419 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
1420 System.out.println("Key-Value t1 incorrect: " + keyD + " " + testValD1);
1425 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
1426 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
1430 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
1431 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
1435 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1436 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1440 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
1441 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
1446 for (TransactionStatus status : transStatusList) {
1447 if (status.getStatus() != TransactionStatus.StatusCommitted) {
1453 System.out.println("Found Errors...");
1455 System.out.println("No Errors Found...");
1459 static void test4() throws ServerException {
1461 boolean foundError = false;
1464 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
1466 // Setup the 2 clients
1467 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, -1);
1469 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, -1);
1473 System.out.println("Setting up keys");
1474 startTime = System.currentTimeMillis();
1475 for (int i = 0; i < 4; i++) {
1480 IoTString ia = new IoTString(a);
1481 IoTString ib = new IoTString(b);
1482 IoTString ic = new IoTString(c);
1483 IoTString id = new IoTString(d);
1484 t1.createNewKey(ia, 321);
1485 t1.createNewKey(ib, 351);
1486 t2.createNewKey(ic, 321);
1487 t2.createNewKey(id, 351);
1489 endTime = System.currentTimeMillis();
1490 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1491 System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
1492 System.out.println();
1495 // Do Updates for the keys
1496 System.out.println("Setting Key-Values...");
1497 startTime = System.currentTimeMillis();
1498 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
1499 for (int i = 0; i < 4; i++) {
1500 String keyA = "a" + i;
1501 String keyB = "b" + i;
1502 String keyC = "c" + i;
1503 String keyD = "d" + i;
1504 String valueA = "a" + i;
1505 String valueB = "b" + i;
1506 String valueC = "c" + i;
1507 String valueD = "d" + i;
1509 IoTString iKeyA = new IoTString(keyA);
1510 IoTString iKeyB = new IoTString(keyB);
1511 IoTString iKeyC = new IoTString(keyC);
1512 IoTString iKeyD = new IoTString(keyD);
1513 IoTString iValueA = new IoTString(valueA);
1514 IoTString iValueB = new IoTString(valueB);
1515 IoTString iValueC = new IoTString(valueC);
1516 IoTString iValueD = new IoTString(valueD);
1518 t1.startTransaction();
1519 t1.addKV(iKeyA, iValueA);
1520 transStatusList.add(t1.commitTransaction());
1522 t1.startTransaction();
1523 t1.addKV(iKeyB, iValueB);
1524 transStatusList.add(t1.commitTransaction());
1526 t2.startTransaction();
1527 t2.addKV(iKeyC, iValueC);
1528 transStatusList.add(t2.commitTransaction());
1530 t2.startTransaction();
1531 t2.addKV(iKeyD, iValueD);
1532 transStatusList.add(t2.commitTransaction());
1535 endTime = System.currentTimeMillis();
1536 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1537 System.out.println("Time Taken Per Update: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 16)) );
1538 System.out.println();
1541 System.out.println("Updating Clients...");
1546 System.out.println("Checking Key-Values...");
1547 for (int i = 0; i < 4; i++) {
1549 String keyA = "a" + i;
1550 String keyB = "b" + i;
1551 String keyC = "c" + i;
1552 String keyD = "d" + i;
1553 String valueA = "a" + i;
1554 String valueB = "b" + i;
1555 String valueC = "c" + i;
1556 String valueD = "d" + i;
1558 IoTString iKeyA = new IoTString(keyA);
1559 IoTString iKeyB = new IoTString(keyB);
1560 IoTString iKeyC = new IoTString(keyC);
1561 IoTString iKeyD = new IoTString(keyD);
1562 IoTString iValueA = new IoTString(valueA);
1563 IoTString iValueB = new IoTString(valueB);
1564 IoTString iValueC = new IoTString(valueC);
1565 IoTString iValueD = new IoTString(valueD);
1568 IoTString testValA1 = t1.getCommitted(iKeyA);
1569 IoTString testValB1 = t1.getCommitted(iKeyB);
1570 IoTString testValC1 = t1.getCommitted(iKeyC);
1571 IoTString testValD1 = t1.getCommitted(iKeyD);
1573 IoTString testValA2 = t2.getCommitted(iKeyA);
1574 IoTString testValB2 = t2.getCommitted(iKeyB);
1575 IoTString testValC2 = t2.getCommitted(iKeyC);
1576 IoTString testValD2 = t2.getCommitted(iKeyD);
1578 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
1579 System.out.println("Key-Value t1 incorrect: " + keyA);
1583 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1584 System.out.println("Key-Value t1 incorrect: " + keyB);
1588 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
1589 System.out.println("Key-Value t1 incorrect: " + keyC);
1593 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
1594 System.out.println("Key-Value t1 incorrect: " + keyD);
1599 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
1600 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
1604 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
1605 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
1609 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1610 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1614 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
1615 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
1620 for (TransactionStatus status : transStatusList) {
1621 if (status.getStatus() != TransactionStatus.StatusCommitted) {
1627 System.out.println("Found Errors...");
1629 System.out.println("No Errors Found...");
1633 static void test3() throws ServerException {
1637 boolean foundError = false;
1639 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
1641 // Setup the 2 clients
1642 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, -1);
1644 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, -1);
1649 System.out.println("Setting up keys");
1650 startTime = System.currentTimeMillis();
1651 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1656 IoTString ia = new IoTString(a);
1657 IoTString ib = new IoTString(b);
1658 IoTString ic = new IoTString(c);
1659 IoTString id = new IoTString(d);
1660 t1.createNewKey(ia, 321);
1661 t1.createNewKey(ib, 351);
1662 t2.createNewKey(ic, 321);
1663 t2.createNewKey(id, 351);
1665 endTime = System.currentTimeMillis();
1666 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1667 System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
1668 System.out.println();
1671 // Do Updates for the keys
1672 System.out.println("Setting Key-Values...");
1673 startTime = System.currentTimeMillis();
1675 System.out.println("B...");
1676 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1677 String keyB = "b" + i;
1678 String valueB = "b" + i;
1680 IoTString iKeyB = new IoTString(keyB);
1681 IoTString iValueB = new IoTString(valueB);
1683 t1.startTransaction();
1684 t1.addKV(iKeyB, iValueB);
1685 transStatusList.add(t1.commitTransaction());
1688 System.out.println("C...");
1689 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1690 String keyC = "c" + i;
1691 String valueC = "c" + i;
1693 IoTString iKeyC = new IoTString(keyC);
1694 IoTString iValueC = new IoTString(valueC);
1696 t2.startTransaction();
1697 t2.addKV(iKeyC, iValueC);
1698 transStatusList.add(t2.commitTransaction());
1701 System.out.println("A, D...");
1702 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1703 String keyA = "a" + i;
1704 String keyD = "d" + i;
1705 String valueA = "a" + i;
1706 String valueD = "d" + i;
1708 IoTString iKeyA = new IoTString(keyA);
1709 IoTString iKeyD = new IoTString(keyD);
1710 IoTString iValueA = new IoTString(valueA);
1711 IoTString iValueD = new IoTString(valueD);
1713 t1.startTransaction();
1714 t1.addKV(iKeyA, iValueA);
1715 transStatusList.add(t1.commitTransaction());
1717 t2.startTransaction();
1718 t2.addKV(iKeyD, iValueD);
1719 transStatusList.add(t2.commitTransaction());
1721 endTime = System.currentTimeMillis();
1722 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1723 System.out.println("Time Taken Per Update: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
1724 System.out.println();
1727 System.out.println("Updating Clients...");
1732 System.out.println("Checking Key-Values...");
1733 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1735 String keyA = "a" + i;
1736 String keyB = "b" + i;
1737 String keyC = "c" + i;
1738 String keyD = "d" + i;
1739 String valueA = "a" + i;
1740 String valueB = "b" + i;
1741 String valueC = "c" + i;
1742 String valueD = "d" + i;
1744 IoTString iKeyA = new IoTString(keyA);
1745 IoTString iKeyB = new IoTString(keyB);
1746 IoTString iKeyC = new IoTString(keyC);
1747 IoTString iKeyD = new IoTString(keyD);
1748 IoTString iValueA = new IoTString(valueA);
1749 IoTString iValueB = new IoTString(valueB);
1750 IoTString iValueC = new IoTString(valueC);
1751 IoTString iValueD = new IoTString(valueD);
1754 IoTString testValA1 = t1.getCommitted(iKeyA);
1755 IoTString testValB1 = t1.getCommitted(iKeyB);
1756 IoTString testValC1 = t1.getCommitted(iKeyC);
1757 IoTString testValD1 = t1.getCommitted(iKeyD);
1759 IoTString testValA2 = t2.getCommitted(iKeyA);
1760 IoTString testValB2 = t2.getCommitted(iKeyB);
1761 IoTString testValC2 = t2.getCommitted(iKeyC);
1762 IoTString testValD2 = t2.getCommitted(iKeyD);
1764 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
1765 System.out.println("Key-Value t1 incorrect: " + keyA);
1769 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1770 System.out.println("Key-Value t1 incorrect: " + keyB);
1774 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
1775 System.out.println("Key-Value t1 incorrect: " + keyC);
1779 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
1780 System.out.println("Key-Value t1 incorrect: " + keyD);
1785 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
1786 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
1790 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
1791 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
1795 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1796 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1800 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
1801 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
1806 for (TransactionStatus status : transStatusList) {
1807 if (status.getStatus() != TransactionStatus.StatusCommitted) {
1813 System.out.println("Found Errors...");
1815 System.out.println("No Errors Found...");
1819 static void test2() throws ServerException {
1821 boolean foundError = false;
1824 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
1826 // Setup the 2 clients
1827 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, -1);
1829 System.out.println("T1 Ready");
1831 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, -1);
1833 System.out.println("T2 Ready");
1836 System.out.println("Setting up keys");
1837 startTime = System.currentTimeMillis();
1838 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1839 System.out.println(i);
1844 IoTString ia = new IoTString(a);
1845 IoTString ib = new IoTString(b);
1846 IoTString ic = new IoTString(c);
1847 IoTString id = new IoTString(d);
1848 t1.createNewKey(ia, 321);
1849 t1.createNewKey(ib, 351);
1850 t2.createNewKey(ic, 321);
1851 t2.createNewKey(id, 351);
1853 endTime = System.currentTimeMillis();
1854 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1855 System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
1856 System.out.println();
1858 // Do Updates for the keys
1859 System.out.println("Setting Key-Values...");
1860 startTime = System.currentTimeMillis();
1861 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1862 System.out.println(i);
1863 String keyA = "a" + i;
1864 String keyB = "b" + i;
1865 String keyC = "c" + i;
1866 String keyD = "d" + i;
1867 String valueA = "a" + i;
1868 String valueB = "b" + i;
1869 String valueC = "c" + i;
1870 String valueD = "d" + i;
1872 IoTString iKeyA = new IoTString(keyA);
1873 IoTString iKeyB = new IoTString(keyB);
1874 IoTString iKeyC = new IoTString(keyC);
1875 IoTString iKeyD = new IoTString(keyD);
1876 IoTString iValueA = new IoTString(valueA);
1877 IoTString iValueB = new IoTString(valueB);
1878 IoTString iValueC = new IoTString(valueC);
1879 IoTString iValueD = new IoTString(valueD);
1882 System.out.println("===============================================================================");
1883 System.out.println("AAAAAAAA");
1884 System.out.println("===============================================================================");
1885 t1.startTransaction();
1886 t1.addKV(iKeyA, iValueA);
1887 transStatusList.add(t1.commitTransaction());
1888 System.out.println();
1891 System.out.println("===============================================================================");
1892 System.out.println("BBBBBBB");
1893 System.out.println("===============================================================================");
1894 t1.startTransaction();
1895 t1.addKV(iKeyB, iValueB);
1896 transStatusList.add(t1.commitTransaction());
1897 System.out.println();
1900 System.out.println("===============================================================================");
1901 System.out.println("CCCCCCC");
1902 System.out.println("===============================================================================");
1903 t2.startTransaction();
1904 t2.addKV(iKeyC, iValueC);
1905 transStatusList.add(t2.commitTransaction());
1906 System.out.println();
1909 System.out.println("===============================================================================");
1910 System.out.println("DDDDDDDDDD");
1911 System.out.println("===============================================================================");
1912 t2.startTransaction();
1913 t2.addKV(iKeyD, iValueD);
1914 transStatusList.add(t2.commitTransaction());
1915 System.out.println();
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();