4 import java.util.ArrayList;
14 public static final int NUMBER_OF_TESTS = 100;
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")) {
36 boolean foundError = false;
37 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
39 // Setup the 2 clients
40 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, 6000);
42 System.out.println("Init Table t1s");
46 System.out.println("-==-=-=-=-=-=-=-==-=-");
49 } catch (Exception e) {}
53 System.out.println("Update Table t2");
54 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, 6001);
55 while (t2.update() == false) {}
57 t1.addLocalCommunication(351, "127.0.0.1", 6001);
58 t2.addLocalCommunication(321, "127.0.0.1", 6000);
61 System.out.println("Setting up keys");
62 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
63 System.out.println(i);
69 IoTString ia = new IoTString(a);
70 IoTString ib = new IoTString(b);
71 IoTString ic = new IoTString(c);
72 IoTString id = new IoTString(d);
76 t1.createNewKey(ia, 321);
78 } catch (Exception e) { }
83 t1.createNewKey(ib, 351);
85 } catch (Exception e) { }
90 t2.createNewKey(ic, 321);
92 } catch (Exception e) { }
97 t2.createNewKey(id, 351);
99 } catch (Exception e) { }
103 // Do Updates for the keys
104 System.out.println("Setting Key-Values...");
105 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
106 System.out.println(i);
107 String keyA = "a" + i;
108 String keyB = "b" + i;
109 String keyC = "c" + i;
110 String keyD = "d" + i;
111 String valueA = "a" + i;
112 String valueB = "b" + i;
113 String valueC = "c" + i;
114 String valueD = "d" + i;
116 IoTString iKeyA = new IoTString(keyA);
117 IoTString iKeyB = new IoTString(keyB);
118 IoTString iKeyC = new IoTString(keyC);
119 IoTString iKeyD = new IoTString(keyD);
120 IoTString iValueA = new IoTString(valueA);
121 IoTString iValueB = new IoTString(valueB);
122 IoTString iValueC = new IoTString(valueC);
123 IoTString iValueD = new IoTString(valueD);
126 String keyAPrev = "a" + (i - 1);
127 String keyBPrev = "b" + (i - 1);
128 String keyCPrev = "c" + (i - 1);
129 String keyDPrev = "d" + (i - 1);
130 String valueAPrev = "a" + (i - 1);
131 String valueBPrev = "b" + (i - 1);
132 String valueCPrev = "c" + (i - 1);
133 String valueDPrev = "d" + (i - 1);
135 IoTString iKeyAPrev = new IoTString(keyAPrev);
136 IoTString iKeyBPrev = new IoTString(keyBPrev);
137 IoTString iKeyCPrev = new IoTString(keyCPrev);
138 IoTString iKeyDPrev = new IoTString(keyDPrev);
139 IoTString iValueAPrev = new IoTString(valueAPrev);
140 IoTString iValueBPrev = new IoTString(valueBPrev);
141 IoTString iValueCPrev = new IoTString(valueCPrev);
142 IoTString iValueDPrev = new IoTString(valueDPrev);
144 t1.startTransaction();
145 t1.addKV(iKeyA, iValueA);
146 transStatusList.add(t1.commitTransaction());
148 t1.startTransaction();
149 t1.addKV(iKeyB, iValueB);
150 transStatusList.add(t1.commitTransaction());
152 t2.startTransaction();
153 t2.addKV(iKeyC, iValueC);
154 transStatusList.add(t2.commitTransaction());
156 t2.startTransaction();
157 t2.addKV(iKeyD, iValueD);
158 transStatusList.add(t2.commitTransaction());
161 System.out.println("Updating...");
162 while (t1.update() == false) {}
163 while (t2.update() == false) {}
164 while (t1.update() == false) {}
166 System.out.println("Checking Key-Values...");
167 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
169 String keyA = "a" + i;
170 String keyB = "b" + i;
171 String keyC = "c" + i;
172 String keyD = "d" + i;
173 String valueA = "a" + i;
174 String valueB = "b" + i;
175 String valueC = "c" + i;
176 String valueD = "d" + i;
178 IoTString iKeyA = new IoTString(keyA);
179 IoTString iKeyB = new IoTString(keyB);
180 IoTString iKeyC = new IoTString(keyC);
181 IoTString iKeyD = new IoTString(keyD);
182 IoTString iValueA = new IoTString(valueA);
183 IoTString iValueB = new IoTString(valueB);
184 IoTString iValueC = new IoTString(valueC);
185 IoTString iValueD = new IoTString(valueD);
188 IoTString testValA1 = t1.getCommitted(iKeyA);
189 IoTString testValB1 = t1.getCommitted(iKeyB);
190 IoTString testValC1 = t1.getCommitted(iKeyC);
191 IoTString testValD1 = t1.getCommitted(iKeyD);
193 IoTString testValA2 = t2.getCommitted(iKeyA);
194 IoTString testValB2 = t2.getCommitted(iKeyB);
195 IoTString testValC2 = t2.getCommitted(iKeyC);
196 IoTString testValD2 = t2.getCommitted(iKeyD);
198 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
199 System.out.println("Key-Value t1 incorrect: " + keyA + " " + testValA1);
203 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
204 System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1);
208 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
209 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
213 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
214 System.out.println("Key-Value t1 incorrect: " + keyD + " " + testValD1);
219 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
220 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
224 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
225 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
229 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
230 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
234 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
235 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
240 for (TransactionStatus status : transStatusList) {
241 if (status.getStatus() != TransactionStatus.StatusCommitted) {
247 System.out.println("Found Errors...");
249 System.out.println("No Errors Found...");
256 static void test7() throws ServerException {
258 boolean foundError = false;
259 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
261 // Setup the 2 clients
262 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, -1);
264 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, -1);
268 System.out.println("Setting up keys");
269 for (int i = 0; i < 4; i++) {
274 IoTString ia = new IoTString(a);
275 IoTString ib = new IoTString(b);
276 IoTString ic = new IoTString(c);
277 IoTString id = new IoTString(d);
278 t1.createNewKey(ia, 321);
279 t1.createNewKey(ib, 351);
280 t2.createNewKey(ic, 321);
281 t2.createNewKey(id, 351);
284 // Do Updates for the keys
285 System.out.println("Setting Key-Values...");
287 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
288 for (int i = 0; i < 4; i++) {
289 String keyB = "b" + i;
290 String valueB = "b" + (i + t);
292 IoTString iKeyB = new IoTString(keyB);
293 IoTString iValueB = new IoTString(valueB);
295 t1.startTransaction();
296 t1.getSpeculativeAtomic(iKeyB);
297 t1.addKV(iKeyB, iValueB);
298 transStatusList.add(t1.commitTransaction());
302 for (int i = 0; i < 4; i++) {
304 String keyB = "b" + i;
305 String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
306 IoTString iKeyB = new IoTString(keyB);
307 IoTString iValueB = new IoTString(valueB);
309 IoTString testValB1 = t1.getSpeculative(iKeyB);
310 IoTString testValB2 = t2.getSpeculative(iKeyB);
312 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
313 System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1);
317 if ((testValB2 != null)) {
318 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
323 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
324 for (int i = 0; i < 4; i++) {
325 String keyC = "c" + i;
326 String valueC = "c" + (i + t);
328 IoTString iKeyC = new IoTString(keyC);
329 IoTString iValueC = new IoTString(valueC);
331 t2.startTransaction();
332 t2.getSpeculativeAtomic(iKeyC);
333 t2.addKV(iKeyC, iValueC);
334 transStatusList.add(t2.commitTransaction());
338 for (int i = 0; i < 4; i++) {
339 String keyC = "c" + i;
340 String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
341 IoTString iKeyC = new IoTString(keyC);
342 IoTString iValueC = new IoTString(valueC);
344 IoTString testValC1 = t1.getSpeculative(iKeyC);
345 IoTString testValC2 = t2.getSpeculative(iKeyC);
347 if ((testValC1 != null)) {
348 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
352 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
353 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
358 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
359 for (int i = 0; i < 4; i++) {
360 String keyA = "a" + i;
361 String keyD = "d" + i;
362 String valueA = "a" + (i + t);
363 String valueD = "d" + (i + t);
365 IoTString iKeyA = new IoTString(keyA);
366 IoTString iKeyD = new IoTString(keyD);
367 IoTString iValueA = new IoTString(valueA);
368 IoTString iValueD = new IoTString(valueD);
370 t1.startTransaction();
371 t1.addKV(iKeyA, iValueA);
372 transStatusList.add(t1.commitTransaction());
374 t2.startTransaction();
375 t2.addKV(iKeyD, iValueD);
376 transStatusList.add(t2.commitTransaction());
380 System.out.println("Updating Clients...");
386 System.out.println("Checking Key-Values...");
387 for (int i = 0; i < 4; i++) {
389 String keyA = "a" + i;
390 String keyB = "b" + i;
391 String keyC = "c" + i;
392 String keyD = "d" + i;
393 String valueA = "a" + (i + NUMBER_OF_TESTS - 1);
394 String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
395 String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
396 String valueD = "d" + (i + NUMBER_OF_TESTS - 1);
398 IoTString iKeyA = new IoTString(keyA);
399 IoTString iKeyB = new IoTString(keyB);
400 IoTString iKeyC = new IoTString(keyC);
401 IoTString iKeyD = new IoTString(keyD);
402 IoTString iValueA = new IoTString(valueA);
403 IoTString iValueB = new IoTString(valueB);
404 IoTString iValueC = new IoTString(valueC);
405 IoTString iValueD = new IoTString(valueD);
408 IoTString testValA1 = t1.getCommitted(iKeyA);
409 IoTString testValB1 = t1.getCommitted(iKeyB);
410 IoTString testValC1 = t1.getCommitted(iKeyC);
411 IoTString testValD1 = t1.getCommitted(iKeyD);
413 IoTString testValA2 = t2.getCommitted(iKeyA);
414 IoTString testValB2 = t2.getCommitted(iKeyB);
415 IoTString testValC2 = t2.getCommitted(iKeyC);
416 IoTString testValD2 = t2.getCommitted(iKeyD);
418 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
419 System.out.println("Key-Value t1 incorrect: " + keyA + " " + testValA1);
423 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
424 System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1);
428 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
429 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
433 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
434 System.out.println("Key-Value t1 incorrect: " + keyD + " " + testValD1);
438 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
439 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
443 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
444 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
448 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
449 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
453 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
454 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
459 for (TransactionStatus status : transStatusList) {
460 if (status.getStatus() != TransactionStatus.StatusCommitted) {
466 System.out.println("Found Errors...");
468 System.out.println("No Errors Found...");
472 static void test6() throws ServerException {
474 boolean foundError = false;
475 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
477 // Setup the 2 clients
478 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, -1);
480 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, -1);
484 System.out.println("Setting up keys");
485 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
490 IoTString ia = new IoTString(a);
491 IoTString ib = new IoTString(b);
492 IoTString ic = new IoTString(c);
493 IoTString id = new IoTString(d);
494 t1.createNewKey(ia, 321);
495 t1.createNewKey(ib, 351);
496 t2.createNewKey(ic, 321);
497 t2.createNewKey(id, 351);
500 // Do Updates for the keys
501 System.out.println("Setting Key-Values...");
502 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
503 String keyA = "a" + i;
504 String keyB = "b" + i;
505 String keyC = "c" + i;
506 String keyD = "d" + i;
507 String valueA = "a" + i;
508 String valueB = "b" + i;
509 String valueC = "c" + i;
510 String valueD = "d" + i;
512 IoTString iKeyA = new IoTString(keyA);
513 IoTString iKeyB = new IoTString(keyB);
514 IoTString iKeyC = new IoTString(keyC);
515 IoTString iKeyD = new IoTString(keyD);
516 IoTString iValueA = new IoTString(valueA);
517 IoTString iValueB = new IoTString(valueB);
518 IoTString iValueC = new IoTString(valueC);
519 IoTString iValueD = new IoTString(valueD);
521 t1.startTransaction();
522 t1.getCommittedAtomic(iKeyA);
523 t1.addKV(iKeyA, iValueA);
524 transStatusList.add(t1.commitTransaction());
526 t1.startTransaction();
527 t1.getCommittedAtomic(iKeyB);
528 t1.addKV(iKeyB, iValueB);
529 transStatusList.add(t1.commitTransaction());
531 t2.startTransaction();
532 t2.getCommittedAtomic(iKeyC);
533 t2.addKV(iKeyC, iValueC);
534 transStatusList.add(t2.commitTransaction());
536 t2.startTransaction();
537 t2.getCommittedAtomic(iKeyD);
538 t2.addKV(iKeyD, iValueD);
539 transStatusList.add(t2.commitTransaction());
542 System.out.println("Updating Clients...");
546 System.out.println("Checking Key-Values...");
547 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
549 String keyA = "a" + i;
550 String keyB = "b" + i;
551 String keyC = "c" + i;
552 String keyD = "d" + i;
553 String valueA = "a" + i;
554 String valueB = "b" + i;
555 String valueC = "c" + i;
556 String valueD = "d" + i;
558 IoTString iKeyA = new IoTString(keyA);
559 IoTString iKeyB = new IoTString(keyB);
560 IoTString iKeyC = new IoTString(keyC);
561 IoTString iKeyD = new IoTString(keyD);
562 IoTString iValueA = new IoTString(valueA);
563 IoTString iValueB = new IoTString(valueB);
564 IoTString iValueC = new IoTString(valueC);
565 IoTString iValueD = new IoTString(valueD);
568 IoTString testValA1 = t1.getCommitted(iKeyA);
569 IoTString testValB1 = t1.getCommitted(iKeyB);
570 IoTString testValC1 = t1.getCommitted(iKeyC);
571 IoTString testValD1 = t1.getCommitted(iKeyD);
573 IoTString testValA2 = t2.getCommitted(iKeyA);
574 IoTString testValB2 = t2.getCommitted(iKeyB);
575 IoTString testValC2 = t2.getCommitted(iKeyC);
576 IoTString testValD2 = t2.getCommitted(iKeyD);
578 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
579 System.out.println("Key-Value t1 incorrect: " + keyA);
583 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
584 System.out.println("Key-Value t1 incorrect: " + keyB);
588 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
589 System.out.println("Key-Value t1 incorrect: " + keyC);
593 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
594 System.out.println("Key-Value t1 incorrect: " + keyD);
599 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
600 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
604 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
605 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
609 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
610 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
614 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
615 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
620 for (TransactionStatus status : transStatusList) {
621 if (status.getStatus() != TransactionStatus.StatusCommitted) {
627 System.out.println("Found Errors...");
629 System.out.println("No Errors Found...");
633 static void test5() throws ServerException {
635 boolean foundError = false;
636 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
638 // Setup the 2 clients
639 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, -1);
641 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, -1);
646 System.out.println("Setting up keys");
647 for (int i = 0; i < 4; i++) {
652 IoTString ia = new IoTString(a);
653 IoTString ib = new IoTString(b);
654 IoTString ic = new IoTString(c);
655 IoTString id = new IoTString(d);
656 t1.createNewKey(ia, 321);
657 t1.createNewKey(ib, 351);
658 t2.createNewKey(ic, 321);
659 t2.createNewKey(id, 351);
662 // Do Updates for the keys
663 System.out.println("Setting Key-Values...");
665 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
666 for (int i = 0; i < 4; i++) {
667 String keyB = "b" + i;
668 String valueB = "b" + (i + t);
670 IoTString iKeyB = new IoTString(keyB);
671 IoTString iValueB = new IoTString(valueB);
673 t1.startTransaction();
674 t1.addKV(iKeyB, iValueB);
675 transStatusList.add(t1.commitTransaction());
679 for (int i = 0; i < 4; i++) {
681 String keyB = "b" + i;
682 String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
683 IoTString iKeyB = new IoTString(keyB);
684 IoTString iValueB = new IoTString(valueB);
686 IoTString testValB1 = t1.getSpeculative(iKeyB);
687 IoTString testValB2 = t2.getSpeculative(iKeyB);
689 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
690 System.out.println("Key-Value t1 incorrect: " + keyB);
694 if ((testValB2 != null)) {
695 System.out.println("Key-Value t2 incorrect: " + keyB);
700 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
701 for (int i = 0; i < 4; i++) {
702 String keyC = "c" + i;
703 String valueC = "c" + (i + t);
705 IoTString iKeyC = new IoTString(keyC);
706 IoTString iValueC = new IoTString(valueC);
708 t2.startTransaction();
709 t2.addKV(iKeyC, iValueC);
710 transStatusList.add(t2.commitTransaction());
714 for (int i = 0; i < 4; i++) {
715 String keyC = "c" + i;
716 String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
717 IoTString iKeyC = new IoTString(keyC);
718 IoTString iValueC = new IoTString(valueC);
720 IoTString testValC1 = t1.getSpeculative(iKeyC);
721 IoTString testValC2 = t2.getSpeculative(iKeyC);
723 if ((testValC1 != null)) {
724 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
728 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
729 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
734 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
735 for (int i = 0; i < 4; i++) {
736 String keyA = "a" + i;
737 String keyD = "d" + i;
738 String valueA = "a" + (i + t);
739 String valueD = "d" + (i + t);
741 IoTString iKeyA = new IoTString(keyA);
742 IoTString iKeyD = new IoTString(keyD);
743 IoTString iValueA = new IoTString(valueA);
744 IoTString iValueD = new IoTString(valueD);
746 t1.startTransaction();
747 t1.addKV(iKeyA, iValueA);
748 transStatusList.add(t1.commitTransaction());
750 t2.startTransaction();
751 t2.addKV(iKeyD, iValueD);
752 transStatusList.add(t2.commitTransaction());
756 System.out.println("Updating Clients...");
761 System.out.println("Checking Key-Values...");
762 for (int i = 0; i < 4; i++) {
764 String keyA = "a" + i;
765 String keyB = "b" + i;
766 String keyC = "c" + i;
767 String keyD = "d" + i;
768 String valueA = "a" + (i + NUMBER_OF_TESTS - 1);
769 String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
770 String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
771 String valueD = "d" + (i + NUMBER_OF_TESTS - 1);
773 IoTString iKeyA = new IoTString(keyA);
774 IoTString iKeyB = new IoTString(keyB);
775 IoTString iKeyC = new IoTString(keyC);
776 IoTString iKeyD = new IoTString(keyD);
777 IoTString iValueA = new IoTString(valueA);
778 IoTString iValueB = new IoTString(valueB);
779 IoTString iValueC = new IoTString(valueC);
780 IoTString iValueD = new IoTString(valueD);
783 IoTString testValA1 = t1.getCommitted(iKeyA);
784 IoTString testValB1 = t1.getCommitted(iKeyB);
785 IoTString testValC1 = t1.getCommitted(iKeyC);
786 IoTString testValD1 = t1.getCommitted(iKeyD);
788 IoTString testValA2 = t2.getCommitted(iKeyA);
789 IoTString testValB2 = t2.getCommitted(iKeyB);
790 IoTString testValC2 = t2.getCommitted(iKeyC);
791 IoTString testValD2 = t2.getCommitted(iKeyD);
793 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
794 System.out.println("Key-Value t1 incorrect: " + keyA + " " + testValA1);
798 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
799 System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1);
803 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
804 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
808 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
809 System.out.println("Key-Value t1 incorrect: " + keyD + " " + testValD1);
814 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
815 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
819 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
820 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
824 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
825 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
829 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
830 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
835 for (TransactionStatus status : transStatusList) {
836 if (status.getStatus() != TransactionStatus.StatusCommitted) {
842 System.out.println("Found Errors...");
844 System.out.println("No Errors Found...");
848 static void test4() throws ServerException {
850 boolean foundError = false;
853 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
855 // Setup the 2 clients
856 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, -1);
858 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, -1);
862 System.out.println("Setting up keys");
863 startTime = System.currentTimeMillis();
864 for (int i = 0; i < 4; i++) {
869 IoTString ia = new IoTString(a);
870 IoTString ib = new IoTString(b);
871 IoTString ic = new IoTString(c);
872 IoTString id = new IoTString(d);
873 t1.createNewKey(ia, 321);
874 t1.createNewKey(ib, 351);
875 t2.createNewKey(ic, 321);
876 t2.createNewKey(id, 351);
878 endTime = System.currentTimeMillis();
879 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
880 System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
881 System.out.println();
884 // Do Updates for the keys
885 System.out.println("Setting Key-Values...");
886 startTime = System.currentTimeMillis();
887 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
888 for (int i = 0; i < 4; i++) {
889 String keyA = "a" + i;
890 String keyB = "b" + i;
891 String keyC = "c" + i;
892 String keyD = "d" + i;
893 String valueA = "a" + i;
894 String valueB = "b" + i;
895 String valueC = "c" + i;
896 String valueD = "d" + i;
898 IoTString iKeyA = new IoTString(keyA);
899 IoTString iKeyB = new IoTString(keyB);
900 IoTString iKeyC = new IoTString(keyC);
901 IoTString iKeyD = new IoTString(keyD);
902 IoTString iValueA = new IoTString(valueA);
903 IoTString iValueB = new IoTString(valueB);
904 IoTString iValueC = new IoTString(valueC);
905 IoTString iValueD = new IoTString(valueD);
907 t1.startTransaction();
908 t1.addKV(iKeyA, iValueA);
909 transStatusList.add(t1.commitTransaction());
911 t1.startTransaction();
912 t1.addKV(iKeyB, iValueB);
913 transStatusList.add(t1.commitTransaction());
915 t2.startTransaction();
916 t2.addKV(iKeyC, iValueC);
917 transStatusList.add(t2.commitTransaction());
919 t2.startTransaction();
920 t2.addKV(iKeyD, iValueD);
921 transStatusList.add(t2.commitTransaction());
924 endTime = System.currentTimeMillis();
925 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
926 System.out.println("Time Taken Per Update: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 16)) );
927 System.out.println();
930 System.out.println("Updating Clients...");
935 System.out.println("Checking Key-Values...");
936 for (int i = 0; i < 4; i++) {
938 String keyA = "a" + i;
939 String keyB = "b" + i;
940 String keyC = "c" + i;
941 String keyD = "d" + i;
942 String valueA = "a" + i;
943 String valueB = "b" + i;
944 String valueC = "c" + i;
945 String valueD = "d" + i;
947 IoTString iKeyA = new IoTString(keyA);
948 IoTString iKeyB = new IoTString(keyB);
949 IoTString iKeyC = new IoTString(keyC);
950 IoTString iKeyD = new IoTString(keyD);
951 IoTString iValueA = new IoTString(valueA);
952 IoTString iValueB = new IoTString(valueB);
953 IoTString iValueC = new IoTString(valueC);
954 IoTString iValueD = new IoTString(valueD);
957 IoTString testValA1 = t1.getCommitted(iKeyA);
958 IoTString testValB1 = t1.getCommitted(iKeyB);
959 IoTString testValC1 = t1.getCommitted(iKeyC);
960 IoTString testValD1 = t1.getCommitted(iKeyD);
962 IoTString testValA2 = t2.getCommitted(iKeyA);
963 IoTString testValB2 = t2.getCommitted(iKeyB);
964 IoTString testValC2 = t2.getCommitted(iKeyC);
965 IoTString testValD2 = t2.getCommitted(iKeyD);
967 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
968 System.out.println("Key-Value t1 incorrect: " + keyA);
972 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
973 System.out.println("Key-Value t1 incorrect: " + keyB);
977 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
978 System.out.println("Key-Value t1 incorrect: " + keyC);
982 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
983 System.out.println("Key-Value t1 incorrect: " + keyD);
988 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
989 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
993 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
994 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
998 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
999 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1003 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
1004 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
1009 for (TransactionStatus status : transStatusList) {
1010 if (status.getStatus() != TransactionStatus.StatusCommitted) {
1016 System.out.println("Found Errors...");
1018 System.out.println("No Errors Found...");
1022 static void test3() throws ServerException {
1026 boolean foundError = false;
1028 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
1030 // Setup the 2 clients
1031 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, -1);
1033 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, -1);
1038 System.out.println("Setting up keys");
1039 startTime = System.currentTimeMillis();
1040 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1045 IoTString ia = new IoTString(a);
1046 IoTString ib = new IoTString(b);
1047 IoTString ic = new IoTString(c);
1048 IoTString id = new IoTString(d);
1049 t1.createNewKey(ia, 321);
1050 t1.createNewKey(ib, 351);
1051 t2.createNewKey(ic, 321);
1052 t2.createNewKey(id, 351);
1054 endTime = System.currentTimeMillis();
1055 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1056 System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
1057 System.out.println();
1060 // Do Updates for the keys
1061 System.out.println("Setting Key-Values...");
1062 startTime = System.currentTimeMillis();
1064 System.out.println("B...");
1065 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1066 String keyB = "b" + i;
1067 String valueB = "b" + i;
1069 IoTString iKeyB = new IoTString(keyB);
1070 IoTString iValueB = new IoTString(valueB);
1072 t1.startTransaction();
1073 t1.addKV(iKeyB, iValueB);
1074 transStatusList.add(t1.commitTransaction());
1077 System.out.println("C...");
1078 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1079 String keyC = "c" + i;
1080 String valueC = "c" + i;
1082 IoTString iKeyC = new IoTString(keyC);
1083 IoTString iValueC = new IoTString(valueC);
1085 t2.startTransaction();
1086 t2.addKV(iKeyC, iValueC);
1087 transStatusList.add(t2.commitTransaction());
1090 System.out.println("A, D...");
1091 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1092 String keyA = "a" + i;
1093 String keyD = "d" + i;
1094 String valueA = "a" + i;
1095 String valueD = "d" + i;
1097 IoTString iKeyA = new IoTString(keyA);
1098 IoTString iKeyD = new IoTString(keyD);
1099 IoTString iValueA = new IoTString(valueA);
1100 IoTString iValueD = new IoTString(valueD);
1102 t1.startTransaction();
1103 t1.addKV(iKeyA, iValueA);
1104 transStatusList.add(t1.commitTransaction());
1106 t2.startTransaction();
1107 t2.addKV(iKeyD, iValueD);
1108 transStatusList.add(t2.commitTransaction());
1110 endTime = System.currentTimeMillis();
1111 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1112 System.out.println("Time Taken Per Update: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
1113 System.out.println();
1116 System.out.println("Updating Clients...");
1121 System.out.println("Checking Key-Values...");
1122 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1124 String keyA = "a" + i;
1125 String keyB = "b" + i;
1126 String keyC = "c" + i;
1127 String keyD = "d" + i;
1128 String valueA = "a" + i;
1129 String valueB = "b" + i;
1130 String valueC = "c" + i;
1131 String valueD = "d" + i;
1133 IoTString iKeyA = new IoTString(keyA);
1134 IoTString iKeyB = new IoTString(keyB);
1135 IoTString iKeyC = new IoTString(keyC);
1136 IoTString iKeyD = new IoTString(keyD);
1137 IoTString iValueA = new IoTString(valueA);
1138 IoTString iValueB = new IoTString(valueB);
1139 IoTString iValueC = new IoTString(valueC);
1140 IoTString iValueD = new IoTString(valueD);
1143 IoTString testValA1 = t1.getCommitted(iKeyA);
1144 IoTString testValB1 = t1.getCommitted(iKeyB);
1145 IoTString testValC1 = t1.getCommitted(iKeyC);
1146 IoTString testValD1 = t1.getCommitted(iKeyD);
1148 IoTString testValA2 = t2.getCommitted(iKeyA);
1149 IoTString testValB2 = t2.getCommitted(iKeyB);
1150 IoTString testValC2 = t2.getCommitted(iKeyC);
1151 IoTString testValD2 = t2.getCommitted(iKeyD);
1153 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
1154 System.out.println("Key-Value t1 incorrect: " + keyA);
1158 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1159 System.out.println("Key-Value t1 incorrect: " + keyB);
1163 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
1164 System.out.println("Key-Value t1 incorrect: " + keyC);
1168 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
1169 System.out.println("Key-Value t1 incorrect: " + keyD);
1174 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
1175 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
1179 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
1180 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
1184 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1185 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1189 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
1190 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
1195 for (TransactionStatus status : transStatusList) {
1196 if (status.getStatus() != TransactionStatus.StatusCommitted) {
1202 System.out.println("Found Errors...");
1204 System.out.println("No Errors Found...");
1208 static void test2() throws ServerException {
1210 boolean foundError = false;
1213 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
1215 // Setup the 2 clients
1216 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, -1);
1218 System.out.println("T1 Ready");
1220 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, -1);
1222 System.out.println("T2 Ready");
1225 System.out.println("Setting up keys");
1226 startTime = System.currentTimeMillis();
1227 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1228 System.out.println(i);
1233 IoTString ia = new IoTString(a);
1234 IoTString ib = new IoTString(b);
1235 IoTString ic = new IoTString(c);
1236 IoTString id = new IoTString(d);
1237 t1.createNewKey(ia, 321);
1238 t1.createNewKey(ib, 351);
1239 t2.createNewKey(ic, 321);
1240 t2.createNewKey(id, 351);
1242 endTime = System.currentTimeMillis();
1243 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1244 System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
1245 System.out.println();
1247 // Do Updates for the keys
1248 System.out.println("Setting Key-Values...");
1249 startTime = System.currentTimeMillis();
1250 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1251 System.out.println(i);
1252 String keyA = "a" + i;
1253 String keyB = "b" + i;
1254 String keyC = "c" + i;
1255 String keyD = "d" + i;
1256 String valueA = "a" + i;
1257 String valueB = "b" + i;
1258 String valueC = "c" + i;
1259 String valueD = "d" + i;
1261 IoTString iKeyA = new IoTString(keyA);
1262 IoTString iKeyB = new IoTString(keyB);
1263 IoTString iKeyC = new IoTString(keyC);
1264 IoTString iKeyD = new IoTString(keyD);
1265 IoTString iValueA = new IoTString(valueA);
1266 IoTString iValueB = new IoTString(valueB);
1267 IoTString iValueC = new IoTString(valueC);
1268 IoTString iValueD = new IoTString(valueD);
1271 System.out.println("===============================================================================");
1272 System.out.println("AAAAAAAA");
1273 System.out.println("===============================================================================");
1274 t1.startTransaction();
1275 t1.addKV(iKeyA, iValueA);
1276 transStatusList.add(t1.commitTransaction());
1277 System.out.println();
1280 System.out.println("===============================================================================");
1281 System.out.println("BBBBBBB");
1282 System.out.println("===============================================================================");
1283 t1.startTransaction();
1284 t1.addKV(iKeyB, iValueB);
1285 transStatusList.add(t1.commitTransaction());
1286 System.out.println();
1289 System.out.println("===============================================================================");
1290 System.out.println("CCCCCCC");
1291 System.out.println("===============================================================================");
1292 t2.startTransaction();
1293 t2.addKV(iKeyC, iValueC);
1294 transStatusList.add(t2.commitTransaction());
1295 System.out.println();
1298 System.out.println("===============================================================================");
1299 System.out.println("DDDDDDDDDD");
1300 System.out.println("===============================================================================");
1301 t2.startTransaction();
1302 t2.addKV(iKeyD, iValueD);
1303 transStatusList.add(t2.commitTransaction());
1304 System.out.println();
1307 endTime = System.currentTimeMillis();
1308 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1309 System.out.println("Time Taken Per Update: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
1310 System.out.println();
1313 System.out.println("Updating Clients...");
1318 System.out.println("Checking Key-Values...");
1319 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1321 String keyA = "a" + i;
1322 String keyB = "b" + i;
1323 String keyC = "c" + i;
1324 String keyD = "d" + i;
1325 String valueA = "a" + i;
1326 String valueB = "b" + i;
1327 String valueC = "c" + i;
1328 String valueD = "d" + i;
1330 IoTString iKeyA = new IoTString(keyA);
1331 IoTString iKeyB = new IoTString(keyB);
1332 IoTString iKeyC = new IoTString(keyC);
1333 IoTString iKeyD = new IoTString(keyD);
1334 IoTString iValueA = new IoTString(valueA);
1335 IoTString iValueB = new IoTString(valueB);
1336 IoTString iValueC = new IoTString(valueC);
1337 IoTString iValueD = new IoTString(valueD);
1340 IoTString testValA1 = t1.getCommitted(iKeyA);
1341 IoTString testValB1 = t1.getCommitted(iKeyB);
1342 IoTString testValC1 = t1.getCommitted(iKeyC);
1343 IoTString testValD1 = t1.getCommitted(iKeyD);
1345 IoTString testValA2 = t2.getCommitted(iKeyA);
1346 IoTString testValB2 = t2.getCommitted(iKeyB);
1347 IoTString testValC2 = t2.getCommitted(iKeyC);
1348 IoTString testValD2 = t2.getCommitted(iKeyD);
1350 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
1351 System.out.println("Key-Value t1 incorrect: " + keyA);
1355 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1356 System.out.println("Key-Value t1 incorrect: " + keyB);
1360 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
1361 System.out.println("Key-Value t1 incorrect: " + keyC);
1365 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
1366 System.out.println("Key-Value t1 incorrect: " + keyD);
1371 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
1372 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
1376 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
1377 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
1381 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1382 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1386 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
1387 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
1392 for (TransactionStatus status : transStatusList) {
1393 if (status.getStatus() != TransactionStatus.StatusCommitted) {
1395 System.out.println(status.getStatus());
1400 System.out.println("Found Errors...");
1402 System.out.println("No Errors Found...");
1405 System.out.println();
1406 System.out.println();
1409 System.out.println();
1410 System.out.println();