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")) {
31 } else if (args[0].equals("9")) {
34 // else if (args[0].equals("10")) {
40 // static void test10() throws ServerException {
42 // long startTime = 0;
44 // boolean foundError = false;
46 // // Setup the 2 clients
47 // Table t1 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
49 // Table t2 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
52 // if (t1.hasConnection()) {
53 // System.out.println("Can see server");
56 // LocalComm lc = new LocalComm(t1, t2);
57 // t1.addLocalComm(t2.getId(), lc);
58 // t2.addLocalComm(t1.getId(), lc);
61 // System.out.println("Setting up keys");
62 // startTime = System.currentTimeMillis();
63 // for (int i = 0; i < NUMBER_OF_TESTS; i++) {
64 // String a = "a" + i;
65 // String b = "b" + i;
66 // String c = "c" + i;
67 // String d = "d" + i;
68 // IoTString ia = new IoTString(a);
69 // IoTString ib = new IoTString(b);
70 // IoTString ic = new IoTString(c);
71 // IoTString id = new IoTString(d);
72 // t1.createNewKey(ia, 321);
73 // t1.createNewKey(ib, 351);
74 // t2.createNewKey(ic, 321);
75 // t2.createNewKey(id, 351);
77 // endTime = System.currentTimeMillis();
78 // System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
79 // System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
80 // System.out.println();
83 // // Do Updates for the keys
84 // System.out.println("Setting Key-Values...");
85 // startTime = System.currentTimeMillis();
86 // for (int i = 0; i < NUMBER_OF_TESTS; i++) {
87 // String keyA = "a" + i;
88 // String keyB = "b" + i;
89 // String keyC = "c" + i;
90 // String keyD = "d" + i;
91 // String valueA = "a" + i;
92 // String valueB = "b" + i;
93 // String valueC = "c" + i;
94 // String valueD = "d" + i;
96 // IoTString iKeyA = new IoTString(keyA);
97 // IoTString iKeyB = new IoTString(keyB);
98 // IoTString iKeyC = new IoTString(keyC);
99 // IoTString iKeyD = new IoTString(keyD);
100 // IoTString iValueA = new IoTString(valueA);
101 // IoTString iValueB = new IoTString(valueB);
102 // IoTString iValueC = new IoTString(valueC);
103 // IoTString iValueD = new IoTString(valueD);
106 // t1.startTransaction();
107 // t1.addKV(iKeyA, iValueA);
108 // if (t1.commitTransactionLocal()) {
114 // t1.startTransaction();
115 // t1.addKV(iKeyB, iValueB);
116 // if (t1.commitTransactionLocal()) {
122 // t2.startTransaction();
123 // t2.addKV(iKeyC, iValueC);
124 // if (t2.commitTransactionLocal()) {
130 // t2.startTransaction();
131 // t2.addKV(iKeyD, iValueD);
132 // if (t2.commitTransactionLocal()) {
137 // endTime = System.currentTimeMillis();
138 // System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
139 // System.out.println("Time Taken Per Update: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
140 // System.out.println();
143 // System.out.println("Checking Key-Values...");
144 // for (int i = 0; i < NUMBER_OF_TESTS; i++) {
146 // String keyA = "a" + i;
147 // String keyB = "b" + i;
148 // String keyC = "c" + i;
149 // String keyD = "d" + i;
150 // String valueA = "a" + i;
151 // String valueB = "b" + i;
152 // String valueC = "c" + i;
153 // String valueD = "d" + i;
155 // IoTString iKeyA = new IoTString(keyA);
156 // IoTString iKeyB = new IoTString(keyB);
157 // IoTString iKeyC = new IoTString(keyC);
158 // IoTString iKeyD = new IoTString(keyD);
159 // IoTString iValueA = new IoTString(valueA);
160 // IoTString iValueB = new IoTString(valueB);
161 // IoTString iValueC = new IoTString(valueC);
162 // IoTString iValueD = new IoTString(valueD);
165 // IoTString testValA1 = t1.getCommitted(iKeyA);
166 // IoTString testValB1 = t1.getCommitted(iKeyB);
167 // IoTString testValC1 = t1.getCommitted(iKeyC);
168 // IoTString testValD1 = t1.getCommitted(iKeyD);
170 // IoTString testValA2 = t2.getCommitted(iKeyA);
171 // IoTString testValB2 = t2.getCommitted(iKeyB);
172 // IoTString testValC2 = t2.getCommitted(iKeyC);
173 // IoTString testValD2 = t2.getCommitted(iKeyD);
175 // if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
176 // System.out.println("Key-Value t1 incorrect: " + keyA);
177 // foundError = true;
180 // if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
181 // System.out.println("Key-Value t1 incorrect: " + keyB);
182 // foundError = true;
185 // if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
186 // System.out.println("Key-Value t1 incorrect: " + keyC);
187 // foundError = true;
190 // if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
191 // System.out.println("Key-Value t1 incorrect: " + keyD);
192 // foundError = true;
196 // if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
197 // System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
198 // foundError = true;
201 // if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
202 // System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
203 // foundError = true;
206 // if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
207 // System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
208 // foundError = true;
211 // if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
212 // System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
213 // foundError = true;
218 // // System.out.println("Updating Clients...");
226 // // System.out.println("Checking Key-Values...");
227 // // for (int i = 0; i < NUMBER_OF_TESTS; i++) {
229 // // String keyA = "a" + i;
230 // // String keyB = "b" + i;
231 // // String keyC = "c" + i;
232 // // String keyD = "d" + i;
233 // // String valueA = "a" + i;
234 // // String valueB = "b" + i;
235 // // String valueC = "c" + i;
236 // // String valueD = "d" + i;
238 // // IoTString iKeyA = new IoTString(keyA);
239 // // IoTString iKeyB = new IoTString(keyB);
240 // // IoTString iKeyC = new IoTString(keyC);
241 // // IoTString iKeyD = new IoTString(keyD);
242 // // IoTString iValueA = new IoTString(valueA);
243 // // IoTString iValueB = new IoTString(valueB);
244 // // IoTString iValueC = new IoTString(valueC);
245 // // IoTString iValueD = new IoTString(valueD);
248 // // IoTString testValA1 = t1.getCommitted(iKeyA);
249 // // IoTString testValB1 = t1.getCommitted(iKeyB);
250 // // IoTString testValC1 = t1.getCommitted(iKeyC);
251 // // IoTString testValD1 = t1.getCommitted(iKeyD);
253 // // IoTString testValA2 = t2.getCommitted(iKeyA);
254 // // IoTString testValB2 = t2.getCommitted(iKeyB);
255 // // IoTString testValC2 = t2.getCommitted(iKeyC);
256 // // IoTString testValD2 = t2.getCommitted(iKeyD);
258 // // if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
259 // // System.out.println("Key-Value t1 incorrect: " + keyA);
260 // // foundError = true;
263 // // if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
264 // // System.out.println("Key-Value t1 incorrect: " + keyB);
265 // // foundError = true;
268 // // if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
269 // // System.out.println("Key-Value t1 incorrect: " + keyC);
270 // // foundError = true;
273 // // if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
274 // // System.out.println("Key-Value t1 incorrect: " + keyD);
275 // // foundError = true;
279 // // if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
280 // // System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
281 // // foundError = true;
284 // // if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
285 // // System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
286 // // foundError = true;
289 // // if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
290 // // System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
291 // // foundError = true;
294 // // if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
295 // // System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
296 // // foundError = true;
302 // System.out.println("Found Errors...");
304 // System.out.println("No Errors Found...");
308 // System.out.println();
309 // System.out.println();
310 // System.out.println();
312 // System.out.println();
313 // System.out.println();
317 static void test9() {
319 boolean foundError = false;
321 // Setup the 2 clients
322 Table t1 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
328 } catch (Exception e) {}
331 Table t2 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
337 } catch (Exception e) {}
341 System.out.println("Setting up keys");
342 for (int i = 0; i < 4; i++) {
347 IoTString ia = new IoTString(a);
348 IoTString ib = new IoTString(b);
349 IoTString ic = new IoTString(c);
350 IoTString id = new IoTString(d);
353 t1.createNewKey(ia, 321);
355 } catch (Exception e) {}
360 t1.createNewKey(ib, 351);
362 } catch (Exception e) {}
367 t2.createNewKey(ic, 321);
369 } catch (Exception e) {}
374 t2.createNewKey(id, 351);
376 } catch (Exception e) {}
380 // Do Updates for the keys
381 System.out.println("Setting Key-Values...");
383 System.out.println("Setting b...");
384 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
385 for (int i = 0; i < 4; i++) {
386 String keyB = "b" + i;
387 String valueB = "b" + (i + t);
389 IoTString iKeyB = new IoTString(keyB);
390 IoTString iValueB = new IoTString(valueB);
393 t1.startTransaction();
394 t1.getSpeculativeAtomic(iKeyB);
395 t1.addKV(iKeyB, iValueB);
396 t1.commitTransaction();
397 System.out.println("Server Success");
398 } catch (Exception e) {
399 System.out.println("Server Fail");
405 System.out.println("Checking b");
406 for (int i = 0; i < 4; i++) {
408 String keyB = "b" + i;
409 String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
410 IoTString iKeyB = new IoTString(keyB);
411 IoTString iValueB = new IoTString(valueB);
413 IoTString testValB1 = t1.getSpeculative(iKeyB);
414 IoTString testValB2 = t2.getSpeculative(iKeyB);
416 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
417 System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1);
421 if ((testValB2 != null)) {
422 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
427 System.out.println("Setting c...");
428 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
429 for (int i = 0; i < 4; i++) {
430 String keyC = "c" + i;
431 String valueC = "c" + (i + t);
433 IoTString iKeyC = new IoTString(keyC);
434 IoTString iValueC = new IoTString(valueC);
437 t2.startTransaction();
438 t2.getSpeculativeAtomic(iKeyC);
439 t2.addKV(iKeyC, iValueC);
440 t2.commitTransaction();
441 System.out.println("Server Success");
442 } catch (Exception e) {
443 System.out.println("Server Fail");
449 System.out.println("Checking c");
450 for (int i = 0; i < 4; i++) {
451 String keyC = "c" + i;
452 String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
453 IoTString iKeyC = new IoTString(keyC);
454 IoTString iValueC = new IoTString(valueC);
456 IoTString testValC1 = t1.getSpeculative(iKeyC);
457 IoTString testValC2 = t2.getSpeculative(iKeyC);
459 if ((testValC1 != null)) {
460 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
464 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
465 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
470 System.out.println("Setting a and b...");
471 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
472 for (int i = 0; i < 4; i++) {
473 String keyA = "a" + i;
474 String keyD = "d" + i;
475 String valueA = "a" + (i + t);
476 String valueD = "d" + (i + t);
478 IoTString iKeyA = new IoTString(keyA);
479 IoTString iKeyD = new IoTString(keyD);
480 IoTString iValueA = new IoTString(valueA);
481 IoTString iValueD = new IoTString(valueD);
484 t1.startTransaction();
485 t1.addKV(iKeyA, iValueA);
486 t1.commitTransaction();
487 System.out.println("Server Success");
489 } catch (Exception e) {
490 System.out.println("Server Fail");
494 t2.startTransaction();
495 t2.addKV(iKeyD, iValueD);
496 t2.commitTransaction();
497 System.out.println("Server Success");
499 } catch (Exception e) {
500 System.out.println("Server Fail");
506 System.out.println("Updating Clients...");
507 System.out.println("Updating Clients...");
508 System.out.println("Updating Clients...");
509 System.out.println("Updating Clients...");
510 System.out.println("Updating Clients...");
511 System.out.println("Updating Clients...");
512 System.out.println("Updating Clients...");
513 System.out.println("Updating Clients...");
514 System.out.println("Updating Clients...");
515 System.out.println("Updating Clients...");
516 System.out.println("Updating Clients...");
517 System.out.println("Updating Clients...");
518 System.out.println("Updating Clients...");
519 System.out.println("Updating Clients...");
520 System.out.println("Updating Clients...");
521 System.out.println("Updating Clients...");
522 System.out.println("Updating Clients...");
523 System.out.println("Updating Clients...");
524 System.out.println("Updating Clients...");
525 System.out.println("Updating Clients...");
526 System.out.println("Updating Clients...");
527 System.out.println("Updating Clients...");
528 System.out.println("Updating Clients...");
529 System.out.println("Updating Clients...");
530 System.out.println("Updating Clients...");
534 } catch (Exception e) {
538 System.out.println("Updating Clients... T1 first");
543 } catch (Exception e) {
545 System.out.println("Fail");
549 System.out.println("Updating Clients... T2 first");
554 } catch (Exception e) {
555 System.out.println("Fail");
559 System.out.println("Updating Clients... T1 second");
564 } catch (Exception e) {
565 System.out.println("Fail");
569 System.out.println("Updating Clients... T2 second");
574 } catch (Exception e) {
575 System.out.println("Fail");
579 System.out.println("Checking Key-Values...");
580 for (int i = 0; i < 4; i++) {
582 String keyA = "a" + i;
583 String keyB = "b" + i;
584 String keyC = "c" + i;
585 String keyD = "d" + i;
586 String valueA = "a" + (i + NUMBER_OF_TESTS - 1);
587 String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
588 String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
589 String valueD = "d" + (i + NUMBER_OF_TESTS - 1);
591 IoTString iKeyA = new IoTString(keyA);
592 IoTString iKeyB = new IoTString(keyB);
593 IoTString iKeyC = new IoTString(keyC);
594 IoTString iKeyD = new IoTString(keyD);
595 IoTString iValueA = new IoTString(valueA);
596 IoTString iValueB = new IoTString(valueB);
597 IoTString iValueC = new IoTString(valueC);
598 IoTString iValueD = new IoTString(valueD);
601 IoTString testValA1 = t1.getCommitted(iKeyA);
602 IoTString testValB1 = t1.getCommitted(iKeyB);
603 IoTString testValC1 = t1.getCommitted(iKeyC);
604 IoTString testValD1 = t1.getCommitted(iKeyD);
606 IoTString testValA2 = t2.getCommitted(iKeyA);
607 IoTString testValB2 = t2.getCommitted(iKeyB);
608 IoTString testValC2 = t2.getCommitted(iKeyC);
609 IoTString testValD2 = t2.getCommitted(iKeyD);
611 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
612 System.out.println("Key-Value t1 incorrect: " + keyA + " " + testValA1 + " " + iValueA);
616 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
617 System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1 + " " + iValueB);
621 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
622 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1 + " " + iValueC);
626 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
627 System.out.println("Key-Value t1 incorrect: " + keyD + " " + testValD1 + " " + iValueD);
631 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
632 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2 + " " + iValueA);
636 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
637 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2 + " " + iValueB);
641 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
642 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2 + " " + iValueC);
646 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
647 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2 + " " + iValueD);
653 System.out.println("Found Errors...");
655 System.out.println("No Errors Found...");
659 static void test8() {
660 boolean foundError = false;
663 // Setup the 2 clients
664 Table t1 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
669 } catch (Exception e) {}
672 Table t2 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
677 } catch (Exception e) {}
681 System.out.println("Setting up keys");
682 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
683 System.out.println(i);
689 IoTString ia = new IoTString(a);
690 IoTString ib = new IoTString(b);
691 IoTString ic = new IoTString(c);
692 IoTString id = new IoTString(d);
696 t1.createNewKey(ia, 321);
698 } catch (Exception e) {}
703 t1.createNewKey(ib, 351);
705 } catch (Exception e) {}
710 t2.createNewKey(ic, 321);
712 } catch (Exception e) {}
717 t2.createNewKey(id, 351);
719 } catch (Exception e) {}
723 // Do Updates for the keys
724 System.out.println("Setting Key-Values...");
725 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
726 System.out.println(i);
727 String keyA = "a" + i;
728 String keyB = "b" + i;
729 String keyC = "c" + i;
730 String keyD = "d" + i;
731 String valueA = "a" + i;
732 String valueB = "b" + i;
733 String valueC = "c" + i;
734 String valueD = "d" + i;
736 IoTString iKeyA = new IoTString(keyA);
737 IoTString iKeyB = new IoTString(keyB);
738 IoTString iKeyC = new IoTString(keyC);
739 IoTString iKeyD = new IoTString(keyD);
740 IoTString iValueA = new IoTString(valueA);
741 IoTString iValueB = new IoTString(valueB);
742 IoTString iValueC = new IoTString(valueC);
743 IoTString iValueD = new IoTString(valueD);
746 String keyAPrev = "a" + (i - 1);
747 String keyBPrev = "b" + (i - 1);
748 String keyCPrev = "c" + (i - 1);
749 String keyDPrev = "d" + (i - 1);
750 String valueAPrev = "a" + (i - 1);
751 String valueBPrev = "b" + (i - 1);
752 String valueCPrev = "c" + (i - 1);
753 String valueDPrev = "d" + (i - 1);
755 IoTString iKeyAPrev = new IoTString(keyAPrev);
756 IoTString iKeyBPrev = new IoTString(keyBPrev);
757 IoTString iKeyCPrev = new IoTString(keyCPrev);
758 IoTString iKeyDPrev = new IoTString(keyDPrev);
759 IoTString iValueAPrev = new IoTString(valueAPrev);
760 IoTString iValueBPrev = new IoTString(valueBPrev);
761 IoTString iValueCPrev = new IoTString(valueCPrev);
762 IoTString iValueDPrev = new IoTString(valueDPrev);
765 t1.startTransaction();
767 IoTString tmp = t1.getSpeculative(iKeyAPrev);
768 if ((tmp == null) || !tmp.equals(iValueAPrev)) {
769 System.out.println("Key a Error: " + i);
773 t1.addKV(iKeyA, iValueA);
774 t1.commitTransaction();
775 } catch (Exception e) {
776 System.out.println("Connection Failure!");
780 t1.startTransaction();
782 IoTString tmp = t1.getSpeculative(iKeyBPrev);
783 if ((tmp == null) || !tmp.equals(iValueBPrev)) {
784 System.out.println("Key b Error: " + i);
788 t1.addKV(iKeyB, iValueB);
789 t1.commitTransaction();
790 } catch (Exception e) {
791 System.out.println("Connection Failure!");
795 t2.startTransaction();
797 IoTString tmp = t2.getSpeculative(iKeyCPrev);
798 if ((tmp == null) || !tmp.equals(iValueCPrev)) {
799 System.out.println("Key c Error: " + i);
803 t2.addKV(iKeyC, iValueC);
804 t2.commitTransaction();
805 } catch (Exception e) {
806 System.out.println("Connection Failure!");
810 t2.startTransaction();
812 IoTString tmp = t2.getSpeculative(iKeyDPrev);
813 if ((tmp == null) || !tmp.equals(iValueDPrev)) {
814 System.out.println("Key d Error: " + i);
818 t2.addKV(iKeyD, iValueD);
819 t2.commitTransaction();
820 } catch (Exception e) {
821 System.out.println("Connection Failure!");
829 } catch (Exception e) {
838 } catch (Exception e) {
847 } catch (Exception e) {
856 } catch (Exception e) {
862 System.out.println("Checking Key-Values...");
863 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
865 String keyA = "a" + i;
866 String keyB = "b" + i;
867 String keyC = "c" + i;
868 String keyD = "d" + i;
869 String valueA = "a" + i;
870 String valueB = "b" + i;
871 String valueC = "c" + i;
872 String valueD = "d" + i;
874 IoTString iKeyA = new IoTString(keyA);
875 IoTString iKeyB = new IoTString(keyB);
876 IoTString iKeyC = new IoTString(keyC);
877 IoTString iKeyD = new IoTString(keyD);
878 IoTString iValueA = new IoTString(valueA);
879 IoTString iValueB = new IoTString(valueB);
880 IoTString iValueC = new IoTString(valueC);
881 IoTString iValueD = new IoTString(valueD);
884 IoTString testValA1 = t1.getCommitted(iKeyA);
885 IoTString testValB1 = t1.getCommitted(iKeyB);
886 IoTString testValC1 = t1.getCommitted(iKeyC);
887 IoTString testValD1 = t1.getCommitted(iKeyD);
889 IoTString testValA2 = t2.getCommitted(iKeyA);
890 IoTString testValB2 = t2.getCommitted(iKeyB);
891 IoTString testValC2 = t2.getCommitted(iKeyC);
892 IoTString testValD2 = t2.getCommitted(iKeyD);
894 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
895 System.out.println("Key-Value t1 incorrect: " + keyA);
899 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
900 System.out.println("Key-Value t1 incorrect: " + keyB);
904 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
905 System.out.println("Key-Value t1 incorrect: " + keyC);
909 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
910 System.out.println("Key-Value t1 incorrect: " + keyD);
915 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
916 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
920 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
921 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
925 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
926 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
930 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
931 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
937 System.out.println("Found Errors...");
939 System.out.println("No Errors Found...");
943 static void test7() throws ServerException {
947 boolean foundError = false;
949 // Setup the 2 clients
950 Table t1 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
952 Table t2 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
955 startTime = System.currentTimeMillis();
957 System.out.println("Setting up keys");
958 for (int i = 0; i < 4; i++) {
963 IoTString ia = new IoTString(a);
964 IoTString ib = new IoTString(b);
965 IoTString ic = new IoTString(c);
966 IoTString id = new IoTString(d);
967 t1.createNewKey(ia, 321);
968 t1.createNewKey(ib, 351);
969 t2.createNewKey(ic, 321);
970 t2.createNewKey(id, 351);
972 endTime = System.currentTimeMillis();
973 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
974 System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (4)) );
975 System.out.println();
977 // Do Updates for the keys
978 System.out.println("Setting Key-Values...");
980 startTime = System.currentTimeMillis();
981 System.out.println("Setting b...");
982 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
983 for (int i = 0; i < 4; i++) {
984 String keyB = "b" + i;
985 String valueB = "b" + (i + t);
987 IoTString iKeyB = new IoTString(keyB);
988 IoTString iValueB = new IoTString(valueB);
990 t1.startTransaction();
991 t1.getSpeculativeAtomic(iKeyB);
992 t1.addKV(iKeyB, iValueB);
993 t1.commitTransaction();
996 endTime = System.currentTimeMillis();
997 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
998 System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (4 * NUMBER_OF_TESTS)) );
999 System.out.println();
1003 System.out.println("Checking b");
1004 for (int i = 0; i < 4; i++) {
1006 String keyB = "b" + i;
1007 String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
1008 IoTString iKeyB = new IoTString(keyB);
1009 IoTString iValueB = new IoTString(valueB);
1011 IoTString testValB1 = t1.getSpeculative(iKeyB);
1012 IoTString testValB2 = t2.getSpeculative(iKeyB);
1014 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1015 System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1);
1019 if ((testValB2 != null)) {
1020 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
1025 startTime = System.currentTimeMillis();
1026 System.out.println("Setting c...");
1027 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
1028 for (int i = 0; i < 4; i++) {
1029 String keyC = "c" + i;
1030 String valueC = "c" + (i + t);
1032 IoTString iKeyC = new IoTString(keyC);
1033 IoTString iValueC = new IoTString(valueC);
1035 t2.startTransaction();
1036 t2.getSpeculativeAtomic(iKeyC);
1037 t2.addKV(iKeyC, iValueC);
1038 t2.commitTransaction();
1041 endTime = System.currentTimeMillis();
1042 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1043 System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (4 * NUMBER_OF_TESTS)) );
1044 System.out.println();
1047 System.out.println("Checking c");
1048 for (int i = 0; i < 4; i++) {
1049 String keyC = "c" + i;
1050 String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
1051 IoTString iKeyC = new IoTString(keyC);
1052 IoTString iValueC = new IoTString(valueC);
1054 IoTString testValC1 = t1.getSpeculative(iKeyC);
1055 IoTString testValC2 = t2.getSpeculative(iKeyC);
1057 if ((testValC1 != null)) {
1058 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
1062 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1063 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1068 System.out.println("Setting a and b...");
1069 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
1070 for (int i = 0; i < 4; i++) {
1071 String keyA = "a" + i;
1072 String keyD = "d" + i;
1073 String valueA = "a" + (i + t);
1074 String valueD = "d" + (i + t);
1076 IoTString iKeyA = new IoTString(keyA);
1077 IoTString iKeyD = new IoTString(keyD);
1078 IoTString iValueA = new IoTString(valueA);
1079 IoTString iValueD = new IoTString(valueD);
1081 t1.startTransaction();
1082 t1.addKV(iKeyA, iValueA);
1083 t1.commitTransaction();
1085 t2.startTransaction();
1086 t2.addKV(iKeyD, iValueD);
1087 t2.commitTransaction();
1091 System.out.println("Updating Clients...");
1097 System.out.println("Checking Key-Values...");
1098 for (int i = 0; i < 4; i++) {
1100 String keyA = "a" + i;
1101 String keyB = "b" + i;
1102 String keyC = "c" + i;
1103 String keyD = "d" + i;
1104 String valueA = "a" + (i + NUMBER_OF_TESTS - 1);
1105 String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
1106 String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
1107 String valueD = "d" + (i + NUMBER_OF_TESTS - 1);
1109 IoTString iKeyA = new IoTString(keyA);
1110 IoTString iKeyB = new IoTString(keyB);
1111 IoTString iKeyC = new IoTString(keyC);
1112 IoTString iKeyD = new IoTString(keyD);
1113 IoTString iValueA = new IoTString(valueA);
1114 IoTString iValueB = new IoTString(valueB);
1115 IoTString iValueC = new IoTString(valueC);
1116 IoTString iValueD = new IoTString(valueD);
1119 IoTString testValA1 = t1.getCommitted(iKeyA);
1120 IoTString testValB1 = t1.getCommitted(iKeyB);
1121 IoTString testValC1 = t1.getCommitted(iKeyC);
1122 IoTString testValD1 = t1.getCommitted(iKeyD);
1124 IoTString testValA2 = t2.getCommitted(iKeyA);
1125 IoTString testValB2 = t2.getCommitted(iKeyB);
1126 IoTString testValC2 = t2.getCommitted(iKeyC);
1127 IoTString testValD2 = t2.getCommitted(iKeyD);
1129 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
1130 System.out.println("Key-Value t1 incorrect: " + keyA + " " + testValA1);
1134 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1135 System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1);
1139 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
1140 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
1144 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
1145 System.out.println("Key-Value t1 incorrect: " + keyD + " " + testValD1);
1149 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
1150 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
1154 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
1155 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
1159 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1160 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1164 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
1165 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
1171 System.out.println("Found Errors...");
1173 System.out.println("No Errors Found...");
1177 static void test6() throws ServerException {
1181 // Setup the 2 clients
1182 Table t1 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
1184 Table t2 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
1189 System.out.println("Setting up keys");
1190 startTime = System.currentTimeMillis();
1191 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1196 IoTString ia = new IoTString(a);
1197 IoTString ib = new IoTString(b);
1198 IoTString ic = new IoTString(c);
1199 IoTString id = new IoTString(d);
1200 t1.createNewKey(ia, 321);
1201 t1.createNewKey(ib, 351);
1202 t2.createNewKey(ic, 321);
1203 t2.createNewKey(id, 351);
1205 endTime = System.currentTimeMillis();
1209 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1210 System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
1211 System.out.println();
1214 // Do Updates for the keys
1215 System.out.println("Setting Key-Values...");
1216 startTime = System.currentTimeMillis();
1217 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1218 String keyA = "a" + i;
1219 String keyB = "b" + i;
1220 String keyC = "c" + i;
1221 String keyD = "d" + i;
1222 String valueA = "a" + i;
1223 String valueB = "b" + i;
1224 String valueC = "c" + i;
1225 String valueD = "d" + i;
1227 IoTString iKeyA = new IoTString(keyA);
1228 IoTString iKeyB = new IoTString(keyB);
1229 IoTString iKeyC = new IoTString(keyC);
1230 IoTString iKeyD = new IoTString(keyD);
1231 IoTString iValueA = new IoTString(valueA);
1232 IoTString iValueB = new IoTString(valueB);
1233 IoTString iValueC = new IoTString(valueC);
1234 IoTString iValueD = new IoTString(valueD);
1236 t1.startTransaction();
1237 t1.getCommittedAtomic(iKeyA);
1238 t1.addKV(iKeyA, iValueA);
1239 t1.commitTransaction();
1241 t1.startTransaction();
1242 t1.getCommittedAtomic(iKeyB);
1243 t1.addKV(iKeyB, iValueB);
1244 t1.commitTransaction();
1246 t2.startTransaction();
1247 t2.getCommittedAtomic(iKeyC);
1248 t2.addKV(iKeyC, iValueC);
1249 t2.commitTransaction();
1251 t2.startTransaction();
1252 t2.getCommittedAtomic(iKeyD);
1253 t2.addKV(iKeyD, iValueD);
1254 t2.commitTransaction();
1256 endTime = System.currentTimeMillis();
1258 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1259 System.out.println("Time Taken Per Update: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
1260 System.out.println();
1263 System.out.println("Updating Clients...");
1269 boolean foundError = false;
1271 System.out.println("Checking Key-Values...");
1272 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1274 String keyA = "a" + i;
1275 String keyB = "b" + i;
1276 String keyC = "c" + i;
1277 String keyD = "d" + i;
1278 String valueA = "a" + i;
1279 String valueB = "b" + i;
1280 String valueC = "c" + i;
1281 String valueD = "d" + i;
1283 IoTString iKeyA = new IoTString(keyA);
1284 IoTString iKeyB = new IoTString(keyB);
1285 IoTString iKeyC = new IoTString(keyC);
1286 IoTString iKeyD = new IoTString(keyD);
1287 IoTString iValueA = new IoTString(valueA);
1288 IoTString iValueB = new IoTString(valueB);
1289 IoTString iValueC = new IoTString(valueC);
1290 IoTString iValueD = new IoTString(valueD);
1293 IoTString testValA1 = t1.getCommitted(iKeyA);
1294 IoTString testValB1 = t1.getCommitted(iKeyB);
1295 IoTString testValC1 = t1.getCommitted(iKeyC);
1296 IoTString testValD1 = t1.getCommitted(iKeyD);
1298 IoTString testValA2 = t2.getCommitted(iKeyA);
1299 IoTString testValB2 = t2.getCommitted(iKeyB);
1300 IoTString testValC2 = t2.getCommitted(iKeyC);
1301 IoTString testValD2 = t2.getCommitted(iKeyD);
1303 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
1304 System.out.println("Key-Value t1 incorrect: " + keyA);
1308 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1309 System.out.println("Key-Value t1 incorrect: " + keyB);
1313 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
1314 System.out.println("Key-Value t1 incorrect: " + keyC);
1318 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
1319 System.out.println("Key-Value t1 incorrect: " + keyD);
1324 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
1325 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
1329 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
1330 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
1334 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1335 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1339 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
1340 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
1346 System.out.println("Found Errors...");
1348 System.out.println("No Errors Found...");
1351 // System.out.println();
1352 // System.out.println();
1353 // System.out.println();
1355 // System.out.println();
1356 // System.out.println();
1357 // System.out.println();
1361 static void test5() throws ServerException {
1365 boolean foundError = false;
1367 // Setup the 2 clients
1368 Table t1 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
1370 Table t2 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
1375 System.out.println("Setting up keys");
1376 for (int i = 0; i < 4; i++) {
1381 IoTString ia = new IoTString(a);
1382 IoTString ib = new IoTString(b);
1383 IoTString ic = new IoTString(c);
1384 IoTString id = new IoTString(d);
1385 t1.createNewKey(ia, 321);
1386 t1.createNewKey(ib, 351);
1387 t2.createNewKey(ic, 321);
1388 t2.createNewKey(id, 351);
1390 endTime = System.currentTimeMillis();
1394 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1395 System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (4)) );
1396 System.out.println();
1399 // Do Updates for the keys
1400 System.out.println("Setting Key-Values...");
1402 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
1403 for (int i = 0; i < 4; i++) {
1404 String keyB = "b" + i;
1405 String valueB = "b" + (i + t);
1407 IoTString iKeyB = new IoTString(keyB);
1408 IoTString iValueB = new IoTString(valueB);
1410 t1.startTransaction();
1411 t1.addKV(iKeyB, iValueB);
1412 t1.commitTransaction();
1416 for (int i = 0; i < 4; i++) {
1418 String keyB = "b" + i;
1419 String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
1420 IoTString iKeyB = new IoTString(keyB);
1421 IoTString iValueB = new IoTString(valueB);
1423 IoTString testValB1 = t1.getSpeculative(iKeyB);
1424 IoTString testValB2 = t2.getSpeculative(iKeyB);
1426 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1427 System.out.println("Key-Value t1 incorrect: " + keyB);
1431 if ((testValB2 != null)) {
1432 System.out.println("Key-Value t2 incorrect: " + keyB);
1437 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
1438 for (int i = 0; i < 4; i++) {
1439 String keyC = "c" + i;
1440 String valueC = "c" + (i + t);
1442 IoTString iKeyC = new IoTString(keyC);
1443 IoTString iValueC = new IoTString(valueC);
1445 t2.startTransaction();
1446 t2.addKV(iKeyC, iValueC);
1447 t2.commitTransaction();
1451 for (int i = 0; i < 4; i++) {
1452 String keyC = "c" + i;
1453 String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
1454 IoTString iKeyC = new IoTString(keyC);
1455 IoTString iValueC = new IoTString(valueC);
1457 IoTString testValC1 = t1.getSpeculative(iKeyC);
1458 IoTString testValC2 = t2.getSpeculative(iKeyC);
1460 if ((testValC1 != null)) {
1461 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
1465 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1466 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1471 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
1472 for (int i = 0; i < 4; i++) {
1473 String keyA = "a" + i;
1474 String keyD = "d" + i;
1475 String valueA = "a" + (i + t);
1476 String valueD = "d" + (i + t);
1478 IoTString iKeyA = new IoTString(keyA);
1479 IoTString iKeyD = new IoTString(keyD);
1480 IoTString iValueA = new IoTString(valueA);
1481 IoTString iValueD = new IoTString(valueD);
1483 t1.startTransaction();
1484 t1.addKV(iKeyA, iValueA);
1485 t1.commitTransaction();
1487 t2.startTransaction();
1488 t2.addKV(iKeyD, iValueD);
1489 t2.commitTransaction();
1493 System.out.println("Updating Clients...");
1500 System.out.println("Checking Key-Values...");
1501 for (int i = 0; i < 4; i++) {
1503 String keyA = "a" + i;
1504 String keyB = "b" + i;
1505 String keyC = "c" + i;
1506 String keyD = "d" + i;
1507 String valueA = "a" + (i + NUMBER_OF_TESTS - 1);
1508 String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
1509 String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
1510 String valueD = "d" + (i + NUMBER_OF_TESTS - 1);
1512 IoTString iKeyA = new IoTString(keyA);
1513 IoTString iKeyB = new IoTString(keyB);
1514 IoTString iKeyC = new IoTString(keyC);
1515 IoTString iKeyD = new IoTString(keyD);
1516 IoTString iValueA = new IoTString(valueA);
1517 IoTString iValueB = new IoTString(valueB);
1518 IoTString iValueC = new IoTString(valueC);
1519 IoTString iValueD = new IoTString(valueD);
1522 IoTString testValA1 = t1.getCommitted(iKeyA);
1523 IoTString testValB1 = t1.getCommitted(iKeyB);
1524 IoTString testValC1 = t1.getCommitted(iKeyC);
1525 IoTString testValD1 = t1.getCommitted(iKeyD);
1527 IoTString testValA2 = t2.getCommitted(iKeyA);
1528 IoTString testValB2 = t2.getCommitted(iKeyB);
1529 IoTString testValC2 = t2.getCommitted(iKeyC);
1530 IoTString testValD2 = t2.getCommitted(iKeyD);
1532 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
1533 System.out.println("Key-Value t1 incorrect: " + keyA + " " + testValA1);
1537 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1538 System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1);
1542 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
1543 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
1547 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
1548 System.out.println("Key-Value t1 incorrect: " + keyD + " " + testValD1);
1553 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
1554 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
1558 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
1559 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
1563 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1564 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1568 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
1569 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
1575 System.out.println("Found Errors...");
1577 System.out.println("No Errors Found...");
1581 static void test4() throws ServerException {
1586 // Setup the 2 clients
1587 Table t1 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
1589 Table t2 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
1594 System.out.println("Setting up keys");
1595 startTime = System.currentTimeMillis();
1596 for (int i = 0; i < 4; i++) {
1601 IoTString ia = new IoTString(a);
1602 IoTString ib = new IoTString(b);
1603 IoTString ic = new IoTString(c);
1604 IoTString id = new IoTString(d);
1605 t1.createNewKey(ia, 321);
1606 t1.createNewKey(ib, 351);
1607 t2.createNewKey(ic, 321);
1608 t2.createNewKey(id, 351);
1610 endTime = System.currentTimeMillis();
1614 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1615 System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
1616 System.out.println();
1619 // Do Updates for the keys
1620 System.out.println("Setting Key-Values...");
1621 startTime = System.currentTimeMillis();
1622 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
1623 for (int i = 0; i < 4; i++) {
1624 String keyA = "a" + i;
1625 String keyB = "b" + i;
1626 String keyC = "c" + i;
1627 String keyD = "d" + i;
1628 String valueA = "a" + i;
1629 String valueB = "b" + i;
1630 String valueC = "c" + i;
1631 String valueD = "d" + i;
1633 IoTString iKeyA = new IoTString(keyA);
1634 IoTString iKeyB = new IoTString(keyB);
1635 IoTString iKeyC = new IoTString(keyC);
1636 IoTString iKeyD = new IoTString(keyD);
1637 IoTString iValueA = new IoTString(valueA);
1638 IoTString iValueB = new IoTString(valueB);
1639 IoTString iValueC = new IoTString(valueC);
1640 IoTString iValueD = new IoTString(valueD);
1642 t1.startTransaction();
1643 t1.addKV(iKeyA, iValueA);
1644 t1.commitTransaction();
1646 t1.startTransaction();
1647 t1.addKV(iKeyB, iValueB);
1648 t1.commitTransaction();
1650 t2.startTransaction();
1651 t2.addKV(iKeyC, iValueC);
1652 t2.commitTransaction();
1654 t2.startTransaction();
1655 t2.addKV(iKeyD, iValueD);
1656 t2.commitTransaction();
1659 endTime = System.currentTimeMillis();
1661 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1662 System.out.println("Time Taken Per Update: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 16)) );
1663 System.out.println();
1666 System.out.println("Updating Clients...");
1672 boolean foundError = false;
1674 System.out.println("Checking Key-Values...");
1675 for (int i = 0; i < 4; i++) {
1677 String keyA = "a" + i;
1678 String keyB = "b" + i;
1679 String keyC = "c" + i;
1680 String keyD = "d" + i;
1681 String valueA = "a" + i;
1682 String valueB = "b" + i;
1683 String valueC = "c" + i;
1684 String valueD = "d" + i;
1686 IoTString iKeyA = new IoTString(keyA);
1687 IoTString iKeyB = new IoTString(keyB);
1688 IoTString iKeyC = new IoTString(keyC);
1689 IoTString iKeyD = new IoTString(keyD);
1690 IoTString iValueA = new IoTString(valueA);
1691 IoTString iValueB = new IoTString(valueB);
1692 IoTString iValueC = new IoTString(valueC);
1693 IoTString iValueD = new IoTString(valueD);
1696 IoTString testValA1 = t1.getCommitted(iKeyA);
1697 IoTString testValB1 = t1.getCommitted(iKeyB);
1698 IoTString testValC1 = t1.getCommitted(iKeyC);
1699 IoTString testValD1 = t1.getCommitted(iKeyD);
1701 IoTString testValA2 = t2.getCommitted(iKeyA);
1702 IoTString testValB2 = t2.getCommitted(iKeyB);
1703 IoTString testValC2 = t2.getCommitted(iKeyC);
1704 IoTString testValD2 = t2.getCommitted(iKeyD);
1706 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
1707 System.out.println("Key-Value t1 incorrect: " + keyA);
1711 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1712 System.out.println("Key-Value t1 incorrect: " + keyB);
1716 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
1717 System.out.println("Key-Value t1 incorrect: " + keyC);
1721 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
1722 System.out.println("Key-Value t1 incorrect: " + keyD);
1727 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
1728 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
1732 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
1733 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
1737 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1738 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1742 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
1743 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
1749 System.out.println("Found Errors...");
1751 System.out.println("No Errors Found...");
1755 static void test3() throws ServerException {
1759 boolean foundError = false;
1761 // Setup the 2 clients
1762 Table t1 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
1764 Table t2 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
1769 System.out.println("Setting up keys");
1770 startTime = System.currentTimeMillis();
1771 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1776 IoTString ia = new IoTString(a);
1777 IoTString ib = new IoTString(b);
1778 IoTString ic = new IoTString(c);
1779 IoTString id = new IoTString(d);
1780 t1.createNewKey(ia, 321);
1781 t1.createNewKey(ib, 351);
1782 t2.createNewKey(ic, 321);
1783 t2.createNewKey(id, 351);
1785 endTime = System.currentTimeMillis();
1789 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1790 System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
1791 System.out.println();
1794 // Do Updates for the keys
1795 System.out.println("Setting Key-Values...");
1796 startTime = System.currentTimeMillis();
1797 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1798 String keyB = "b" + i;
1799 String valueB = "b" + i;
1801 IoTString iKeyB = new IoTString(keyB);
1802 IoTString iValueB = new IoTString(valueB);
1804 t1.startTransaction();
1805 t1.addKV(iKeyB, iValueB);
1806 t1.commitTransaction();
1809 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1810 String keyC = "c" + i;
1811 String valueC = "c" + i;
1813 IoTString iKeyC = new IoTString(keyC);
1814 IoTString iValueC = new IoTString(valueC);
1816 t2.startTransaction();
1817 t2.addKV(iKeyC, iValueC);
1818 t2.commitTransaction();
1821 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1822 String keyA = "a" + i;
1823 String keyD = "d" + i;
1824 String valueA = "a" + i;
1825 String valueD = "d" + i;
1827 IoTString iKeyA = new IoTString(keyA);
1828 IoTString iKeyD = new IoTString(keyD);
1829 IoTString iValueA = new IoTString(valueA);
1830 IoTString iValueD = new IoTString(valueD);
1832 t1.startTransaction();
1833 t1.addKV(iKeyA, iValueA);
1834 t1.commitTransaction();
1836 t2.startTransaction();
1837 t2.addKV(iKeyD, iValueD);
1838 t2.commitTransaction();
1840 endTime = System.currentTimeMillis();
1842 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1843 System.out.println("Time Taken Per Update: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
1844 System.out.println();
1847 System.out.println("Updating Clients...");
1854 System.out.println("Checking Key-Values...");
1855 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1857 String keyA = "a" + i;
1858 String keyB = "b" + i;
1859 String keyC = "c" + i;
1860 String keyD = "d" + i;
1861 String valueA = "a" + i;
1862 String valueB = "b" + i;
1863 String valueC = "c" + i;
1864 String valueD = "d" + i;
1866 IoTString iKeyA = new IoTString(keyA);
1867 IoTString iKeyB = new IoTString(keyB);
1868 IoTString iKeyC = new IoTString(keyC);
1869 IoTString iKeyD = new IoTString(keyD);
1870 IoTString iValueA = new IoTString(valueA);
1871 IoTString iValueB = new IoTString(valueB);
1872 IoTString iValueC = new IoTString(valueC);
1873 IoTString iValueD = new IoTString(valueD);
1876 IoTString testValA1 = t1.getCommitted(iKeyA);
1877 IoTString testValB1 = t1.getCommitted(iKeyB);
1878 IoTString testValC1 = t1.getCommitted(iKeyC);
1879 IoTString testValD1 = t1.getCommitted(iKeyD);
1881 IoTString testValA2 = t2.getCommitted(iKeyA);
1882 IoTString testValB2 = t2.getCommitted(iKeyB);
1883 IoTString testValC2 = t2.getCommitted(iKeyC);
1884 IoTString testValD2 = t2.getCommitted(iKeyD);
1886 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
1887 System.out.println("Key-Value t1 incorrect: " + keyA);
1891 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1892 System.out.println("Key-Value t1 incorrect: " + keyB);
1896 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
1897 System.out.println("Key-Value t1 incorrect: " + keyC);
1901 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
1902 System.out.println("Key-Value t1 incorrect: " + keyD);
1907 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
1908 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
1912 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
1913 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
1917 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1918 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1922 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
1923 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
1929 System.out.println("Found Errors...");
1931 System.out.println("No Errors Found...");
1935 static void test2() throws ServerException {
1940 // Setup the 2 clients
1941 Table t1 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
1943 Table t2 = new Table("127.0.0.1", "http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
1946 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
1949 System.out.println("Setting up keys");
1950 startTime = System.currentTimeMillis();
1951 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1956 IoTString ia = new IoTString(a);
1957 IoTString ib = new IoTString(b);
1958 IoTString ic = new IoTString(c);
1959 IoTString id = new IoTString(d);
1960 t1.createNewKey(ia, 321);
1961 t1.createNewKey(ib, 351);
1962 t2.createNewKey(ic, 321);
1963 t2.createNewKey(id, 351);
1965 endTime = System.currentTimeMillis();
1966 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1967 System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
1968 System.out.println();
1971 // Do Updates for the keys
1972 System.out.println("Setting Key-Values...");
1973 startTime = System.currentTimeMillis();
1974 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1975 String keyA = "a" + i;
1976 String keyB = "b" + i;
1977 String keyC = "c" + i;
1978 String keyD = "d" + i;
1979 String valueA = "a" + i;
1980 String valueB = "b" + i;
1981 String valueC = "c" + i;
1982 String valueD = "d" + i;
1984 IoTString iKeyA = new IoTString(keyA);
1985 IoTString iKeyB = new IoTString(keyB);
1986 IoTString iKeyC = new IoTString(keyC);
1987 IoTString iKeyD = new IoTString(keyD);
1988 IoTString iValueA = new IoTString(valueA);
1989 IoTString iValueB = new IoTString(valueB);
1990 IoTString iValueC = new IoTString(valueC);
1991 IoTString iValueD = new IoTString(valueD);
1993 t1.startTransaction();
1994 t1.addKV(iKeyA, iValueA);
1995 transStatusList.add(t1.commitTransaction());
1997 t1.startTransaction();
1998 t1.addKV(iKeyB, iValueB);
1999 transStatusList.add(t1.commitTransaction());
2001 t2.startTransaction();
2002 t2.addKV(iKeyC, iValueC);
2003 transStatusList.add(t2.commitTransaction());
2005 t2.startTransaction();
2006 t2.addKV(iKeyD, iValueD);
2007 transStatusList.add(t2.commitTransaction());
2009 endTime = System.currentTimeMillis();
2010 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
2011 System.out.println("Time Taken Per Update: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
2012 System.out.println();
2015 System.out.println("Updating Clients...");
2021 boolean foundError = false;
2023 System.out.println("Checking Key-Values...");
2024 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
2026 String keyA = "a" + i;
2027 String keyB = "b" + i;
2028 String keyC = "c" + i;
2029 String keyD = "d" + i;
2030 String valueA = "a" + i;
2031 String valueB = "b" + i;
2032 String valueC = "c" + i;
2033 String valueD = "d" + i;
2035 IoTString iKeyA = new IoTString(keyA);
2036 IoTString iKeyB = new IoTString(keyB);
2037 IoTString iKeyC = new IoTString(keyC);
2038 IoTString iKeyD = new IoTString(keyD);
2039 IoTString iValueA = new IoTString(valueA);
2040 IoTString iValueB = new IoTString(valueB);
2041 IoTString iValueC = new IoTString(valueC);
2042 IoTString iValueD = new IoTString(valueD);
2045 IoTString testValA1 = t1.getCommitted(iKeyA);
2046 IoTString testValB1 = t1.getCommitted(iKeyB);
2047 IoTString testValC1 = t1.getCommitted(iKeyC);
2048 IoTString testValD1 = t1.getCommitted(iKeyD);
2050 IoTString testValA2 = t2.getCommitted(iKeyA);
2051 IoTString testValB2 = t2.getCommitted(iKeyB);
2052 IoTString testValC2 = t2.getCommitted(iKeyC);
2053 IoTString testValD2 = t2.getCommitted(iKeyD);
2055 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
2056 System.out.println("Key-Value t1 incorrect: " + keyA);
2060 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
2061 System.out.println("Key-Value t1 incorrect: " + keyB);
2065 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
2066 System.out.println("Key-Value t1 incorrect: " + keyC);
2070 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
2071 System.out.println("Key-Value t1 incorrect: " + keyD);
2076 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
2077 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
2081 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
2082 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
2086 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
2087 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
2091 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
2092 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
2097 for (TransactionStatus status : transStatusList) {
2098 if (status.getStatus() != TransactionStatus.StatusCommitted) {
2104 System.out.println("Found Errors...");
2106 System.out.println("No Errors Found...");
2110 System.out.println();
2111 System.out.println();
2112 System.out.println();
2114 System.out.println();
2115 System.out.println();