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) {}
776 while (t2.update() == false) {}
778 System.out.println("Checking Key-Values...");
779 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
781 String keyA = "a" + i;
782 String keyB = "b" + i;
783 String keyC = "c" + i;
784 String keyD = "d" + i;
785 String valueA = "a" + i;
786 String valueB = "b" + i;
787 String valueC = "c" + i;
788 String valueD = "d" + i;
790 IoTString iKeyA = new IoTString(keyA);
791 IoTString iKeyB = new IoTString(keyB);
792 IoTString iKeyC = new IoTString(keyC);
793 IoTString iKeyD = new IoTString(keyD);
794 IoTString iValueA = new IoTString(valueA);
795 IoTString iValueB = new IoTString(valueB);
796 IoTString iValueC = new IoTString(valueC);
797 IoTString iValueD = new IoTString(valueD);
800 IoTString testValA1 = t1.getCommitted(iKeyA);
801 IoTString testValB1 = t1.getCommitted(iKeyB);
802 IoTString testValC1 = t1.getCommitted(iKeyC);
803 IoTString testValD1 = t1.getCommitted(iKeyD);
805 IoTString testValA2 = t2.getCommitted(iKeyA);
806 IoTString testValB2 = t2.getCommitted(iKeyB);
807 IoTString testValC2 = t2.getCommitted(iKeyC);
808 IoTString testValD2 = t2.getCommitted(iKeyD);
810 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
811 System.out.println("Key-Value t1 incorrect: " + keyA + " " + testValA1);
815 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
816 System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1);
820 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
821 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
825 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
826 System.out.println("Key-Value t1 incorrect: " + keyD + " " + testValD1);
831 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
832 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
836 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
837 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
841 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
842 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
846 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
847 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
852 for (TransactionStatus status : transStatusList) {
853 if (status.getStatus() != TransactionStatus.StatusCommitted) {
859 System.out.println("Found Errors...");
861 System.out.println("No Errors Found...");
868 static void test7() throws ServerException {
870 boolean foundError = false;
871 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
873 // Setup the 2 clients
874 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, -1);
876 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, -1);
880 System.out.println("Setting up keys");
881 for (int i = 0; i < 4; i++) {
886 IoTString ia = new IoTString(a);
887 IoTString ib = new IoTString(b);
888 IoTString ic = new IoTString(c);
889 IoTString id = new IoTString(d);
890 t1.createNewKey(ia, 321);
891 t1.createNewKey(ib, 351);
892 t2.createNewKey(ic, 321);
893 t2.createNewKey(id, 351);
896 // Do Updates for the keys
897 System.out.println("Setting Key-Values...");
899 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
900 for (int i = 0; i < 4; i++) {
901 String keyB = "b" + i;
902 String valueB = "b" + (i + t);
904 IoTString iKeyB = new IoTString(keyB);
905 IoTString iValueB = new IoTString(valueB);
907 t1.startTransaction();
908 t1.getSpeculativeAtomic(iKeyB);
909 t1.addKV(iKeyB, iValueB);
910 transStatusList.add(t1.commitTransaction());
914 for (int i = 0; i < 4; i++) {
916 String keyB = "b" + i;
917 String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
918 IoTString iKeyB = new IoTString(keyB);
919 IoTString iValueB = new IoTString(valueB);
921 IoTString testValB1 = t1.getSpeculative(iKeyB);
922 IoTString testValB2 = t2.getSpeculative(iKeyB);
924 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
925 System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1);
929 if ((testValB2 != null)) {
930 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
935 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
936 for (int i = 0; i < 4; i++) {
937 String keyC = "c" + i;
938 String valueC = "c" + (i + t);
940 IoTString iKeyC = new IoTString(keyC);
941 IoTString iValueC = new IoTString(valueC);
943 t2.startTransaction();
944 t2.getSpeculativeAtomic(iKeyC);
945 t2.addKV(iKeyC, iValueC);
946 transStatusList.add(t2.commitTransaction());
950 for (int i = 0; i < 4; i++) {
951 String keyC = "c" + i;
952 String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
953 IoTString iKeyC = new IoTString(keyC);
954 IoTString iValueC = new IoTString(valueC);
956 IoTString testValC1 = t1.getSpeculative(iKeyC);
957 IoTString testValC2 = t2.getSpeculative(iKeyC);
959 if ((testValC1 != null)) {
960 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
964 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
965 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
970 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
971 for (int i = 0; i < 4; i++) {
972 String keyA = "a" + i;
973 String keyD = "d" + i;
974 String valueA = "a" + (i + t);
975 String valueD = "d" + (i + t);
977 IoTString iKeyA = new IoTString(keyA);
978 IoTString iKeyD = new IoTString(keyD);
979 IoTString iValueA = new IoTString(valueA);
980 IoTString iValueD = new IoTString(valueD);
982 t1.startTransaction();
983 t1.addKV(iKeyA, iValueA);
984 transStatusList.add(t1.commitTransaction());
986 t2.startTransaction();
987 t2.addKV(iKeyD, iValueD);
988 transStatusList.add(t2.commitTransaction());
992 System.out.println("Updating Clients...");
998 System.out.println("Checking Key-Values...");
999 for (int i = 0; i < 4; i++) {
1001 String keyA = "a" + i;
1002 String keyB = "b" + i;
1003 String keyC = "c" + i;
1004 String keyD = "d" + i;
1005 String valueA = "a" + (i + NUMBER_OF_TESTS - 1);
1006 String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
1007 String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
1008 String valueD = "d" + (i + NUMBER_OF_TESTS - 1);
1010 IoTString iKeyA = new IoTString(keyA);
1011 IoTString iKeyB = new IoTString(keyB);
1012 IoTString iKeyC = new IoTString(keyC);
1013 IoTString iKeyD = new IoTString(keyD);
1014 IoTString iValueA = new IoTString(valueA);
1015 IoTString iValueB = new IoTString(valueB);
1016 IoTString iValueC = new IoTString(valueC);
1017 IoTString iValueD = new IoTString(valueD);
1020 IoTString testValA1 = t1.getCommitted(iKeyA);
1021 IoTString testValB1 = t1.getCommitted(iKeyB);
1022 IoTString testValC1 = t1.getCommitted(iKeyC);
1023 IoTString testValD1 = t1.getCommitted(iKeyD);
1025 IoTString testValA2 = t2.getCommitted(iKeyA);
1026 IoTString testValB2 = t2.getCommitted(iKeyB);
1027 IoTString testValC2 = t2.getCommitted(iKeyC);
1028 IoTString testValD2 = t2.getCommitted(iKeyD);
1030 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
1031 System.out.println("Key-Value t1 incorrect: " + keyA + " " + testValA1);
1035 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1036 System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1);
1040 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
1041 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
1045 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
1046 System.out.println("Key-Value t1 incorrect: " + keyD + " " + testValD1);
1050 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
1051 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
1055 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
1056 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
1060 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1061 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1065 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
1066 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
1071 for (TransactionStatus status : transStatusList) {
1072 if (status.getStatus() != TransactionStatus.StatusCommitted) {
1078 System.out.println("Found Errors...");
1080 System.out.println("No Errors Found...");
1084 static void test6() throws ServerException {
1086 boolean foundError = false;
1087 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
1089 // Setup the 2 clients
1090 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, -1);
1092 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, -1);
1096 System.out.println("Setting up keys");
1097 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1102 IoTString ia = new IoTString(a);
1103 IoTString ib = new IoTString(b);
1104 IoTString ic = new IoTString(c);
1105 IoTString id = new IoTString(d);
1106 t1.createNewKey(ia, 321);
1107 t1.createNewKey(ib, 351);
1108 t2.createNewKey(ic, 321);
1109 t2.createNewKey(id, 351);
1112 // Do Updates for the keys
1113 System.out.println("Setting Key-Values...");
1114 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1115 String keyA = "a" + i;
1116 String keyB = "b" + i;
1117 String keyC = "c" + i;
1118 String keyD = "d" + i;
1119 String valueA = "a" + i;
1120 String valueB = "b" + i;
1121 String valueC = "c" + i;
1122 String valueD = "d" + i;
1124 IoTString iKeyA = new IoTString(keyA);
1125 IoTString iKeyB = new IoTString(keyB);
1126 IoTString iKeyC = new IoTString(keyC);
1127 IoTString iKeyD = new IoTString(keyD);
1128 IoTString iValueA = new IoTString(valueA);
1129 IoTString iValueB = new IoTString(valueB);
1130 IoTString iValueC = new IoTString(valueC);
1131 IoTString iValueD = new IoTString(valueD);
1133 t1.startTransaction();
1134 t1.getCommittedAtomic(iKeyA);
1135 t1.addKV(iKeyA, iValueA);
1136 transStatusList.add(t1.commitTransaction());
1138 t1.startTransaction();
1139 t1.getCommittedAtomic(iKeyB);
1140 t1.addKV(iKeyB, iValueB);
1141 transStatusList.add(t1.commitTransaction());
1143 t2.startTransaction();
1144 t2.getCommittedAtomic(iKeyC);
1145 t2.addKV(iKeyC, iValueC);
1146 transStatusList.add(t2.commitTransaction());
1148 t2.startTransaction();
1149 t2.getCommittedAtomic(iKeyD);
1150 t2.addKV(iKeyD, iValueD);
1151 transStatusList.add(t2.commitTransaction());
1154 System.out.println("Updating Clients...");
1158 System.out.println("Checking Key-Values...");
1159 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1161 String keyA = "a" + i;
1162 String keyB = "b" + i;
1163 String keyC = "c" + i;
1164 String keyD = "d" + i;
1165 String valueA = "a" + i;
1166 String valueB = "b" + i;
1167 String valueC = "c" + i;
1168 String valueD = "d" + i;
1170 IoTString iKeyA = new IoTString(keyA);
1171 IoTString iKeyB = new IoTString(keyB);
1172 IoTString iKeyC = new IoTString(keyC);
1173 IoTString iKeyD = new IoTString(keyD);
1174 IoTString iValueA = new IoTString(valueA);
1175 IoTString iValueB = new IoTString(valueB);
1176 IoTString iValueC = new IoTString(valueC);
1177 IoTString iValueD = new IoTString(valueD);
1180 IoTString testValA1 = t1.getCommitted(iKeyA);
1181 IoTString testValB1 = t1.getCommitted(iKeyB);
1182 IoTString testValC1 = t1.getCommitted(iKeyC);
1183 IoTString testValD1 = t1.getCommitted(iKeyD);
1185 IoTString testValA2 = t2.getCommitted(iKeyA);
1186 IoTString testValB2 = t2.getCommitted(iKeyB);
1187 IoTString testValC2 = t2.getCommitted(iKeyC);
1188 IoTString testValD2 = t2.getCommitted(iKeyD);
1190 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
1191 System.out.println("Key-Value t1 incorrect: " + keyA);
1195 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1196 System.out.println("Key-Value t1 incorrect: " + keyB);
1200 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
1201 System.out.println("Key-Value t1 incorrect: " + keyC);
1205 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
1206 System.out.println("Key-Value t1 incorrect: " + keyD);
1211 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
1212 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
1216 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
1217 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
1221 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1222 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1226 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
1227 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
1232 for (TransactionStatus status : transStatusList) {
1233 if (status.getStatus() != TransactionStatus.StatusCommitted) {
1239 System.out.println("Found Errors...");
1241 System.out.println("No Errors Found...");
1245 static void test5() throws ServerException {
1247 boolean foundError = false;
1248 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
1250 // Setup the 2 clients
1251 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, -1);
1253 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, -1);
1258 System.out.println("Setting up keys");
1259 for (int i = 0; i < 4; i++) {
1264 IoTString ia = new IoTString(a);
1265 IoTString ib = new IoTString(b);
1266 IoTString ic = new IoTString(c);
1267 IoTString id = new IoTString(d);
1268 t1.createNewKey(ia, 321);
1269 t1.createNewKey(ib, 351);
1270 t2.createNewKey(ic, 321);
1271 t2.createNewKey(id, 351);
1274 // Do Updates for the keys
1275 System.out.println("Setting Key-Values...");
1277 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
1278 for (int i = 0; i < 4; i++) {
1279 String keyB = "b" + i;
1280 String valueB = "b" + (i + t);
1282 IoTString iKeyB = new IoTString(keyB);
1283 IoTString iValueB = new IoTString(valueB);
1285 t1.startTransaction();
1286 t1.addKV(iKeyB, iValueB);
1287 transStatusList.add(t1.commitTransaction());
1291 for (int i = 0; i < 4; i++) {
1293 String keyB = "b" + i;
1294 String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
1295 IoTString iKeyB = new IoTString(keyB);
1296 IoTString iValueB = new IoTString(valueB);
1298 IoTString testValB1 = t1.getSpeculative(iKeyB);
1299 IoTString testValB2 = t2.getSpeculative(iKeyB);
1301 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1302 System.out.println("Key-Value t1 incorrect: " + keyB);
1306 if ((testValB2 != null)) {
1307 System.out.println("Key-Value t2 incorrect: " + keyB);
1312 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
1313 for (int i = 0; i < 4; i++) {
1314 String keyC = "c" + i;
1315 String valueC = "c" + (i + t);
1317 IoTString iKeyC = new IoTString(keyC);
1318 IoTString iValueC = new IoTString(valueC);
1320 t2.startTransaction();
1321 t2.addKV(iKeyC, iValueC);
1322 transStatusList.add(t2.commitTransaction());
1326 for (int i = 0; i < 4; i++) {
1327 String keyC = "c" + i;
1328 String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
1329 IoTString iKeyC = new IoTString(keyC);
1330 IoTString iValueC = new IoTString(valueC);
1332 IoTString testValC1 = t1.getSpeculative(iKeyC);
1333 IoTString testValC2 = t2.getSpeculative(iKeyC);
1335 if ((testValC1 != null)) {
1336 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
1340 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1341 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1346 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
1347 for (int i = 0; i < 4; i++) {
1348 String keyA = "a" + i;
1349 String keyD = "d" + i;
1350 String valueA = "a" + (i + t);
1351 String valueD = "d" + (i + t);
1353 IoTString iKeyA = new IoTString(keyA);
1354 IoTString iKeyD = new IoTString(keyD);
1355 IoTString iValueA = new IoTString(valueA);
1356 IoTString iValueD = new IoTString(valueD);
1358 t1.startTransaction();
1359 t1.addKV(iKeyA, iValueA);
1360 transStatusList.add(t1.commitTransaction());
1362 t2.startTransaction();
1363 t2.addKV(iKeyD, iValueD);
1364 transStatusList.add(t2.commitTransaction());
1368 System.out.println("Updating Clients...");
1373 System.out.println("Checking Key-Values...");
1374 for (int i = 0; i < 4; i++) {
1376 String keyA = "a" + i;
1377 String keyB = "b" + i;
1378 String keyC = "c" + i;
1379 String keyD = "d" + i;
1380 String valueA = "a" + (i + NUMBER_OF_TESTS - 1);
1381 String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
1382 String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
1383 String valueD = "d" + (i + NUMBER_OF_TESTS - 1);
1385 IoTString iKeyA = new IoTString(keyA);
1386 IoTString iKeyB = new IoTString(keyB);
1387 IoTString iKeyC = new IoTString(keyC);
1388 IoTString iKeyD = new IoTString(keyD);
1389 IoTString iValueA = new IoTString(valueA);
1390 IoTString iValueB = new IoTString(valueB);
1391 IoTString iValueC = new IoTString(valueC);
1392 IoTString iValueD = new IoTString(valueD);
1395 IoTString testValA1 = t1.getCommitted(iKeyA);
1396 IoTString testValB1 = t1.getCommitted(iKeyB);
1397 IoTString testValC1 = t1.getCommitted(iKeyC);
1398 IoTString testValD1 = t1.getCommitted(iKeyD);
1400 IoTString testValA2 = t2.getCommitted(iKeyA);
1401 IoTString testValB2 = t2.getCommitted(iKeyB);
1402 IoTString testValC2 = t2.getCommitted(iKeyC);
1403 IoTString testValD2 = t2.getCommitted(iKeyD);
1405 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
1406 System.out.println("Key-Value t1 incorrect: " + keyA + " " + testValA1);
1410 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1411 System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1);
1415 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
1416 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
1420 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
1421 System.out.println("Key-Value t1 incorrect: " + keyD + " " + testValD1);
1426 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
1427 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
1431 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
1432 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
1436 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1437 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1441 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
1442 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
1447 for (TransactionStatus status : transStatusList) {
1448 if (status.getStatus() != TransactionStatus.StatusCommitted) {
1454 System.out.println("Found Errors...");
1456 System.out.println("No Errors Found...");
1460 static void test4() throws ServerException {
1462 boolean foundError = false;
1465 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
1467 // Setup the 2 clients
1468 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, -1);
1470 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, -1);
1474 System.out.println("Setting up keys");
1475 startTime = System.currentTimeMillis();
1476 for (int i = 0; i < 4; i++) {
1481 IoTString ia = new IoTString(a);
1482 IoTString ib = new IoTString(b);
1483 IoTString ic = new IoTString(c);
1484 IoTString id = new IoTString(d);
1485 t1.createNewKey(ia, 321);
1486 t1.createNewKey(ib, 351);
1487 t2.createNewKey(ic, 321);
1488 t2.createNewKey(id, 351);
1490 endTime = System.currentTimeMillis();
1491 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1492 System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
1493 System.out.println();
1496 // Do Updates for the keys
1497 System.out.println("Setting Key-Values...");
1498 startTime = System.currentTimeMillis();
1499 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
1500 for (int i = 0; i < 4; i++) {
1501 String keyA = "a" + i;
1502 String keyB = "b" + i;
1503 String keyC = "c" + i;
1504 String keyD = "d" + i;
1505 String valueA = "a" + i;
1506 String valueB = "b" + i;
1507 String valueC = "c" + i;
1508 String valueD = "d" + i;
1510 IoTString iKeyA = new IoTString(keyA);
1511 IoTString iKeyB = new IoTString(keyB);
1512 IoTString iKeyC = new IoTString(keyC);
1513 IoTString iKeyD = new IoTString(keyD);
1514 IoTString iValueA = new IoTString(valueA);
1515 IoTString iValueB = new IoTString(valueB);
1516 IoTString iValueC = new IoTString(valueC);
1517 IoTString iValueD = new IoTString(valueD);
1519 t1.startTransaction();
1520 t1.addKV(iKeyA, iValueA);
1521 transStatusList.add(t1.commitTransaction());
1523 t1.startTransaction();
1524 t1.addKV(iKeyB, iValueB);
1525 transStatusList.add(t1.commitTransaction());
1527 t2.startTransaction();
1528 t2.addKV(iKeyC, iValueC);
1529 transStatusList.add(t2.commitTransaction());
1531 t2.startTransaction();
1532 t2.addKV(iKeyD, iValueD);
1533 transStatusList.add(t2.commitTransaction());
1536 endTime = System.currentTimeMillis();
1537 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1538 System.out.println("Time Taken Per Update: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 16)) );
1539 System.out.println();
1542 System.out.println("Updating Clients...");
1547 System.out.println("Checking Key-Values...");
1548 for (int i = 0; i < 4; i++) {
1550 String keyA = "a" + i;
1551 String keyB = "b" + i;
1552 String keyC = "c" + i;
1553 String keyD = "d" + i;
1554 String valueA = "a" + i;
1555 String valueB = "b" + i;
1556 String valueC = "c" + i;
1557 String valueD = "d" + i;
1559 IoTString iKeyA = new IoTString(keyA);
1560 IoTString iKeyB = new IoTString(keyB);
1561 IoTString iKeyC = new IoTString(keyC);
1562 IoTString iKeyD = new IoTString(keyD);
1563 IoTString iValueA = new IoTString(valueA);
1564 IoTString iValueB = new IoTString(valueB);
1565 IoTString iValueC = new IoTString(valueC);
1566 IoTString iValueD = new IoTString(valueD);
1569 IoTString testValA1 = t1.getCommitted(iKeyA);
1570 IoTString testValB1 = t1.getCommitted(iKeyB);
1571 IoTString testValC1 = t1.getCommitted(iKeyC);
1572 IoTString testValD1 = t1.getCommitted(iKeyD);
1574 IoTString testValA2 = t2.getCommitted(iKeyA);
1575 IoTString testValB2 = t2.getCommitted(iKeyB);
1576 IoTString testValC2 = t2.getCommitted(iKeyC);
1577 IoTString testValD2 = t2.getCommitted(iKeyD);
1579 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
1580 System.out.println("Key-Value t1 incorrect: " + keyA);
1584 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1585 System.out.println("Key-Value t1 incorrect: " + keyB);
1589 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
1590 System.out.println("Key-Value t1 incorrect: " + keyC);
1594 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
1595 System.out.println("Key-Value t1 incorrect: " + keyD);
1600 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
1601 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
1605 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
1606 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
1610 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1611 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1615 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
1616 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
1621 for (TransactionStatus status : transStatusList) {
1622 if (status.getStatus() != TransactionStatus.StatusCommitted) {
1628 System.out.println("Found Errors...");
1630 System.out.println("No Errors Found...");
1634 static void test3() throws ServerException {
1638 boolean foundError = false;
1640 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
1642 // Setup the 2 clients
1643 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, -1);
1645 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, -1);
1650 System.out.println("Setting up keys");
1651 startTime = System.currentTimeMillis();
1652 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1657 IoTString ia = new IoTString(a);
1658 IoTString ib = new IoTString(b);
1659 IoTString ic = new IoTString(c);
1660 IoTString id = new IoTString(d);
1661 t1.createNewKey(ia, 321);
1662 t1.createNewKey(ib, 351);
1663 t2.createNewKey(ic, 321);
1664 t2.createNewKey(id, 351);
1666 endTime = System.currentTimeMillis();
1667 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1668 System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
1669 System.out.println();
1672 // Do Updates for the keys
1673 System.out.println("Setting Key-Values...");
1674 startTime = System.currentTimeMillis();
1676 System.out.println("B...");
1677 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1678 String keyB = "b" + i;
1679 String valueB = "b" + i;
1681 IoTString iKeyB = new IoTString(keyB);
1682 IoTString iValueB = new IoTString(valueB);
1684 t1.startTransaction();
1685 t1.addKV(iKeyB, iValueB);
1686 transStatusList.add(t1.commitTransaction());
1689 System.out.println("C...");
1690 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1691 String keyC = "c" + i;
1692 String valueC = "c" + i;
1694 IoTString iKeyC = new IoTString(keyC);
1695 IoTString iValueC = new IoTString(valueC);
1697 t2.startTransaction();
1698 t2.addKV(iKeyC, iValueC);
1699 transStatusList.add(t2.commitTransaction());
1702 System.out.println("A, D...");
1703 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1704 String keyA = "a" + i;
1705 String keyD = "d" + i;
1706 String valueA = "a" + i;
1707 String valueD = "d" + i;
1709 IoTString iKeyA = new IoTString(keyA);
1710 IoTString iKeyD = new IoTString(keyD);
1711 IoTString iValueA = new IoTString(valueA);
1712 IoTString iValueD = new IoTString(valueD);
1714 t1.startTransaction();
1715 t1.addKV(iKeyA, iValueA);
1716 transStatusList.add(t1.commitTransaction());
1718 t2.startTransaction();
1719 t2.addKV(iKeyD, iValueD);
1720 transStatusList.add(t2.commitTransaction());
1722 endTime = System.currentTimeMillis();
1723 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1724 System.out.println("Time Taken Per Update: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
1725 System.out.println();
1728 System.out.println("Updating Clients...");
1733 System.out.println("Checking Key-Values...");
1734 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1736 String keyA = "a" + i;
1737 String keyB = "b" + i;
1738 String keyC = "c" + i;
1739 String keyD = "d" + i;
1740 String valueA = "a" + i;
1741 String valueB = "b" + i;
1742 String valueC = "c" + i;
1743 String valueD = "d" + i;
1745 IoTString iKeyA = new IoTString(keyA);
1746 IoTString iKeyB = new IoTString(keyB);
1747 IoTString iKeyC = new IoTString(keyC);
1748 IoTString iKeyD = new IoTString(keyD);
1749 IoTString iValueA = new IoTString(valueA);
1750 IoTString iValueB = new IoTString(valueB);
1751 IoTString iValueC = new IoTString(valueC);
1752 IoTString iValueD = new IoTString(valueD);
1755 IoTString testValA1 = t1.getCommitted(iKeyA);
1756 IoTString testValB1 = t1.getCommitted(iKeyB);
1757 IoTString testValC1 = t1.getCommitted(iKeyC);
1758 IoTString testValD1 = t1.getCommitted(iKeyD);
1760 IoTString testValA2 = t2.getCommitted(iKeyA);
1761 IoTString testValB2 = t2.getCommitted(iKeyB);
1762 IoTString testValC2 = t2.getCommitted(iKeyC);
1763 IoTString testValD2 = t2.getCommitted(iKeyD);
1765 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
1766 System.out.println("Key-Value t1 incorrect: " + keyA);
1770 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1771 System.out.println("Key-Value t1 incorrect: " + keyB);
1775 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
1776 System.out.println("Key-Value t1 incorrect: " + keyC);
1780 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
1781 System.out.println("Key-Value t1 incorrect: " + keyD);
1786 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
1787 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
1791 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
1792 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
1796 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1797 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1801 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
1802 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
1807 for (TransactionStatus status : transStatusList) {
1808 if (status.getStatus() != TransactionStatus.StatusCommitted) {
1814 System.out.println("Found Errors...");
1816 System.out.println("No Errors Found...");
1820 static void test2() throws ServerException {
1822 boolean foundError = false;
1825 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
1827 // Setup the 2 clients
1828 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, -1);
1830 System.out.println("T1 Ready");
1832 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, -1);
1834 System.out.println("T2 Ready");
1837 System.out.println("Setting up keys");
1838 startTime = System.currentTimeMillis();
1839 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1840 System.out.println(i);
1845 IoTString ia = new IoTString(a);
1846 IoTString ib = new IoTString(b);
1847 IoTString ic = new IoTString(c);
1848 IoTString id = new IoTString(d);
1849 t1.createNewKey(ia, 321);
1850 t1.createNewKey(ib, 351);
1851 t2.createNewKey(ic, 321);
1852 t2.createNewKey(id, 351);
1854 endTime = System.currentTimeMillis();
1855 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1856 System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
1857 System.out.println();
1859 // Do Updates for the keys
1860 System.out.println("Setting Key-Values...");
1861 startTime = System.currentTimeMillis();
1862 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1863 System.out.println(i);
1864 String keyA = "a" + i;
1865 String keyB = "b" + i;
1866 String keyC = "c" + i;
1867 String keyD = "d" + i;
1868 String valueA = "a" + i;
1869 String valueB = "b" + i;
1870 String valueC = "c" + i;
1871 String valueD = "d" + i;
1873 IoTString iKeyA = new IoTString(keyA);
1874 IoTString iKeyB = new IoTString(keyB);
1875 IoTString iKeyC = new IoTString(keyC);
1876 IoTString iKeyD = new IoTString(keyD);
1877 IoTString iValueA = new IoTString(valueA);
1878 IoTString iValueB = new IoTString(valueB);
1879 IoTString iValueC = new IoTString(valueC);
1880 IoTString iValueD = new IoTString(valueD);
1883 System.out.println("===============================================================================");
1884 System.out.println("AAAAAAAA");
1885 System.out.println("===============================================================================");
1886 t1.startTransaction();
1887 t1.addKV(iKeyA, iValueA);
1888 transStatusList.add(t1.commitTransaction());
1889 System.out.println();
1892 System.out.println("===============================================================================");
1893 System.out.println("BBBBBBB");
1894 System.out.println("===============================================================================");
1895 t1.startTransaction();
1896 t1.addKV(iKeyB, iValueB);
1897 transStatusList.add(t1.commitTransaction());
1898 System.out.println();
1901 System.out.println("===============================================================================");
1902 System.out.println("CCCCCCC");
1903 System.out.println("===============================================================================");
1904 t2.startTransaction();
1905 t2.addKV(iKeyC, iValueC);
1906 transStatusList.add(t2.commitTransaction());
1907 System.out.println();
1910 System.out.println("===============================================================================");
1911 System.out.println("DDDDDDDDDD");
1912 System.out.println("===============================================================================");
1913 t2.startTransaction();
1914 t2.addKV(iKeyD, iValueD);
1915 transStatusList.add(t2.commitTransaction());
1916 System.out.println();
1919 endTime = System.currentTimeMillis();
1920 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1921 System.out.println("Time Taken Per Update: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
1922 System.out.println();
1925 System.out.println("Updating Clients...");
1930 System.out.println("Checking Key-Values...");
1931 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1933 String keyA = "a" + i;
1934 String keyB = "b" + i;
1935 String keyC = "c" + i;
1936 String keyD = "d" + i;
1937 String valueA = "a" + i;
1938 String valueB = "b" + i;
1939 String valueC = "c" + i;
1940 String valueD = "d" + i;
1942 IoTString iKeyA = new IoTString(keyA);
1943 IoTString iKeyB = new IoTString(keyB);
1944 IoTString iKeyC = new IoTString(keyC);
1945 IoTString iKeyD = new IoTString(keyD);
1946 IoTString iValueA = new IoTString(valueA);
1947 IoTString iValueB = new IoTString(valueB);
1948 IoTString iValueC = new IoTString(valueC);
1949 IoTString iValueD = new IoTString(valueD);
1952 IoTString testValA1 = t1.getCommitted(iKeyA);
1953 IoTString testValB1 = t1.getCommitted(iKeyB);
1954 IoTString testValC1 = t1.getCommitted(iKeyC);
1955 IoTString testValD1 = t1.getCommitted(iKeyD);
1957 IoTString testValA2 = t2.getCommitted(iKeyA);
1958 IoTString testValB2 = t2.getCommitted(iKeyB);
1959 IoTString testValC2 = t2.getCommitted(iKeyC);
1960 IoTString testValD2 = t2.getCommitted(iKeyD);
1962 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
1963 System.out.println("Key-Value t1 incorrect: " + keyA);
1967 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1968 System.out.println("Key-Value t1 incorrect: " + keyB);
1972 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
1973 System.out.println("Key-Value t1 incorrect: " + keyC);
1977 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
1978 System.out.println("Key-Value t1 incorrect: " + keyD);
1983 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
1984 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
1988 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
1989 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
1993 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1994 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1998 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
1999 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
2004 for (TransactionStatus status : transStatusList) {
2005 if (status.getStatus() != TransactionStatus.StatusCommitted) {
2007 System.out.println(status.getStatus());
2012 System.out.println("Found Errors...");
2014 System.out.println("No Errors Found...");
2017 System.out.println();
2018 System.out.println();
2021 System.out.println();
2022 System.out.println();