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")) {
32 static void test7() throws ServerException {
34 boolean foundError = false;
35 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
37 // Setup the 2 clients
38 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
40 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
44 System.out.println("Setting up keys");
45 for (int i = 0; i < 4; i++) {
50 IoTString ia = new IoTString(a);
51 IoTString ib = new IoTString(b);
52 IoTString ic = new IoTString(c);
53 IoTString id = new IoTString(d);
54 t1.createNewKey(ia, 321);
55 t1.createNewKey(ib, 351);
56 t2.createNewKey(ic, 321);
57 t2.createNewKey(id, 351);
60 // Do Updates for the keys
61 System.out.println("Setting Key-Values...");
63 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
64 for (int i = 0; i < 4; i++) {
65 String keyB = "b" + i;
66 String valueB = "b" + (i + t);
68 IoTString iKeyB = new IoTString(keyB);
69 IoTString iValueB = new IoTString(valueB);
71 t1.startTransaction();
72 t1.getSpeculativeAtomic(iKeyB);
73 t1.addKV(iKeyB, iValueB);
74 transStatusList.add(t1.commitTransaction());
78 for (int i = 0; i < 4; i++) {
80 String keyB = "b" + i;
81 String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
82 IoTString iKeyB = new IoTString(keyB);
83 IoTString iValueB = new IoTString(valueB);
85 IoTString testValB1 = t1.getSpeculative(iKeyB);
86 IoTString testValB2 = t2.getSpeculative(iKeyB);
88 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
89 System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1);
93 if ((testValB2 != null)) {
94 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
99 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
100 for (int i = 0; i < 4; i++) {
101 String keyC = "c" + i;
102 String valueC = "c" + (i + t);
104 IoTString iKeyC = new IoTString(keyC);
105 IoTString iValueC = new IoTString(valueC);
107 t2.startTransaction();
108 t2.getSpeculativeAtomic(iKeyC);
109 t2.addKV(iKeyC, iValueC);
110 transStatusList.add(t2.commitTransaction());
114 for (int i = 0; i < 4; i++) {
115 String keyC = "c" + i;
116 String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
117 IoTString iKeyC = new IoTString(keyC);
118 IoTString iValueC = new IoTString(valueC);
120 IoTString testValC1 = t1.getSpeculative(iKeyC);
121 IoTString testValC2 = t2.getSpeculative(iKeyC);
123 if ((testValC1 != null)) {
124 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
128 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
129 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
134 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
135 for (int i = 0; i < 4; i++) {
136 String keyA = "a" + i;
137 String keyD = "d" + i;
138 String valueA = "a" + (i + t);
139 String valueD = "d" + (i + t);
141 IoTString iKeyA = new IoTString(keyA);
142 IoTString iKeyD = new IoTString(keyD);
143 IoTString iValueA = new IoTString(valueA);
144 IoTString iValueD = new IoTString(valueD);
146 t1.startTransaction();
147 t1.addKV(iKeyA, iValueA);
148 transStatusList.add(t1.commitTransaction());
150 t2.startTransaction();
151 t2.addKV(iKeyD, iValueD);
152 transStatusList.add(t2.commitTransaction());
156 System.out.println("Updating Clients...");
162 System.out.println("Checking Key-Values...");
163 for (int i = 0; i < 4; i++) {
165 String keyA = "a" + i;
166 String keyB = "b" + i;
167 String keyC = "c" + i;
168 String keyD = "d" + i;
169 String valueA = "a" + (i + NUMBER_OF_TESTS - 1);
170 String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
171 String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
172 String valueD = "d" + (i + NUMBER_OF_TESTS - 1);
174 IoTString iKeyA = new IoTString(keyA);
175 IoTString iKeyB = new IoTString(keyB);
176 IoTString iKeyC = new IoTString(keyC);
177 IoTString iKeyD = new IoTString(keyD);
178 IoTString iValueA = new IoTString(valueA);
179 IoTString iValueB = new IoTString(valueB);
180 IoTString iValueC = new IoTString(valueC);
181 IoTString iValueD = new IoTString(valueD);
184 IoTString testValA1 = t1.getCommitted(iKeyA);
185 IoTString testValB1 = t1.getCommitted(iKeyB);
186 IoTString testValC1 = t1.getCommitted(iKeyC);
187 IoTString testValD1 = t1.getCommitted(iKeyD);
189 IoTString testValA2 = t2.getCommitted(iKeyA);
190 IoTString testValB2 = t2.getCommitted(iKeyB);
191 IoTString testValC2 = t2.getCommitted(iKeyC);
192 IoTString testValD2 = t2.getCommitted(iKeyD);
194 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
195 System.out.println("Key-Value t1 incorrect: " + keyA + " " + testValA1);
199 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
200 System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1);
204 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
205 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
209 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
210 System.out.println("Key-Value t1 incorrect: " + keyD + " " + testValD1);
214 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
215 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
219 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
220 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
224 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
225 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
229 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
230 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
235 for (TransactionStatus status : transStatusList) {
236 if (status.getStatus() != TransactionStatus.StatusCommitted) {
242 System.out.println("Found Errors...");
244 System.out.println("No Errors Found...");
248 static void test6() throws ServerException {
250 boolean foundError = false;
251 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
253 // Setup the 2 clients
254 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
256 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
260 System.out.println("Setting up keys");
261 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
266 IoTString ia = new IoTString(a);
267 IoTString ib = new IoTString(b);
268 IoTString ic = new IoTString(c);
269 IoTString id = new IoTString(d);
270 t1.createNewKey(ia, 321);
271 t1.createNewKey(ib, 351);
272 t2.createNewKey(ic, 321);
273 t2.createNewKey(id, 351);
276 // Do Updates for the keys
277 System.out.println("Setting Key-Values...");
278 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
279 String keyA = "a" + i;
280 String keyB = "b" + i;
281 String keyC = "c" + i;
282 String keyD = "d" + i;
283 String valueA = "a" + i;
284 String valueB = "b" + i;
285 String valueC = "c" + i;
286 String valueD = "d" + i;
288 IoTString iKeyA = new IoTString(keyA);
289 IoTString iKeyB = new IoTString(keyB);
290 IoTString iKeyC = new IoTString(keyC);
291 IoTString iKeyD = new IoTString(keyD);
292 IoTString iValueA = new IoTString(valueA);
293 IoTString iValueB = new IoTString(valueB);
294 IoTString iValueC = new IoTString(valueC);
295 IoTString iValueD = new IoTString(valueD);
297 t1.startTransaction();
298 t1.getCommittedAtomic(iKeyA);
299 t1.addKV(iKeyA, iValueA);
300 transStatusList.add(t1.commitTransaction());
302 t1.startTransaction();
303 t1.getCommittedAtomic(iKeyB);
304 t1.addKV(iKeyB, iValueB);
305 transStatusList.add(t1.commitTransaction());
307 t2.startTransaction();
308 t2.getCommittedAtomic(iKeyC);
309 t2.addKV(iKeyC, iValueC);
310 transStatusList.add(t2.commitTransaction());
312 t2.startTransaction();
313 t2.getCommittedAtomic(iKeyD);
314 t2.addKV(iKeyD, iValueD);
315 transStatusList.add(t2.commitTransaction());
318 System.out.println("Updating Clients...");
322 System.out.println("Checking Key-Values...");
323 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
325 String keyA = "a" + i;
326 String keyB = "b" + i;
327 String keyC = "c" + i;
328 String keyD = "d" + i;
329 String valueA = "a" + i;
330 String valueB = "b" + i;
331 String valueC = "c" + i;
332 String valueD = "d" + i;
334 IoTString iKeyA = new IoTString(keyA);
335 IoTString iKeyB = new IoTString(keyB);
336 IoTString iKeyC = new IoTString(keyC);
337 IoTString iKeyD = new IoTString(keyD);
338 IoTString iValueA = new IoTString(valueA);
339 IoTString iValueB = new IoTString(valueB);
340 IoTString iValueC = new IoTString(valueC);
341 IoTString iValueD = new IoTString(valueD);
344 IoTString testValA1 = t1.getCommitted(iKeyA);
345 IoTString testValB1 = t1.getCommitted(iKeyB);
346 IoTString testValC1 = t1.getCommitted(iKeyC);
347 IoTString testValD1 = t1.getCommitted(iKeyD);
349 IoTString testValA2 = t2.getCommitted(iKeyA);
350 IoTString testValB2 = t2.getCommitted(iKeyB);
351 IoTString testValC2 = t2.getCommitted(iKeyC);
352 IoTString testValD2 = t2.getCommitted(iKeyD);
354 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
355 System.out.println("Key-Value t1 incorrect: " + keyA);
359 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
360 System.out.println("Key-Value t1 incorrect: " + keyB);
364 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
365 System.out.println("Key-Value t1 incorrect: " + keyC);
369 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
370 System.out.println("Key-Value t1 incorrect: " + keyD);
375 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
376 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
380 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
381 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
385 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
386 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
390 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
391 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
396 for (TransactionStatus status : transStatusList) {
397 if (status.getStatus() != TransactionStatus.StatusCommitted) {
403 System.out.println("Found Errors...");
405 System.out.println("No Errors Found...");
409 static void test5() throws ServerException {
411 boolean foundError = false;
412 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
414 // Setup the 2 clients
415 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
417 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
422 System.out.println("Setting up keys");
423 for (int i = 0; i < 4; i++) {
428 IoTString ia = new IoTString(a);
429 IoTString ib = new IoTString(b);
430 IoTString ic = new IoTString(c);
431 IoTString id = new IoTString(d);
432 t1.createNewKey(ia, 321);
433 t1.createNewKey(ib, 351);
434 t2.createNewKey(ic, 321);
435 t2.createNewKey(id, 351);
438 // Do Updates for the keys
439 System.out.println("Setting Key-Values...");
441 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
442 for (int i = 0; i < 4; i++) {
443 String keyB = "b" + i;
444 String valueB = "b" + (i + t);
446 IoTString iKeyB = new IoTString(keyB);
447 IoTString iValueB = new IoTString(valueB);
449 t1.startTransaction();
450 t1.addKV(iKeyB, iValueB);
451 transStatusList.add(t1.commitTransaction());
455 for (int i = 0; i < 4; i++) {
457 String keyB = "b" + i;
458 String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
459 IoTString iKeyB = new IoTString(keyB);
460 IoTString iValueB = new IoTString(valueB);
462 IoTString testValB1 = t1.getSpeculative(iKeyB);
463 IoTString testValB2 = t2.getSpeculative(iKeyB);
465 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
466 System.out.println("Key-Value t1 incorrect: " + keyB);
470 if ((testValB2 != null)) {
471 System.out.println("Key-Value t2 incorrect: " + keyB);
476 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
477 for (int i = 0; i < 4; i++) {
478 String keyC = "c" + i;
479 String valueC = "c" + (i + t);
481 IoTString iKeyC = new IoTString(keyC);
482 IoTString iValueC = new IoTString(valueC);
484 t2.startTransaction();
485 t2.addKV(iKeyC, iValueC);
486 transStatusList.add(t2.commitTransaction());
490 for (int i = 0; i < 4; i++) {
491 String keyC = "c" + i;
492 String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
493 IoTString iKeyC = new IoTString(keyC);
494 IoTString iValueC = new IoTString(valueC);
496 IoTString testValC1 = t1.getSpeculative(iKeyC);
497 IoTString testValC2 = t2.getSpeculative(iKeyC);
499 if ((testValC1 != null)) {
500 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
504 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
505 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
510 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
511 for (int i = 0; i < 4; i++) {
512 String keyA = "a" + i;
513 String keyD = "d" + i;
514 String valueA = "a" + (i + t);
515 String valueD = "d" + (i + t);
517 IoTString iKeyA = new IoTString(keyA);
518 IoTString iKeyD = new IoTString(keyD);
519 IoTString iValueA = new IoTString(valueA);
520 IoTString iValueD = new IoTString(valueD);
522 t1.startTransaction();
523 t1.addKV(iKeyA, iValueA);
524 transStatusList.add(t1.commitTransaction());
526 t2.startTransaction();
527 t2.addKV(iKeyD, iValueD);
528 transStatusList.add(t2.commitTransaction());
532 System.out.println("Updating Clients...");
537 System.out.println("Checking Key-Values...");
538 for (int i = 0; i < 4; i++) {
540 String keyA = "a" + i;
541 String keyB = "b" + i;
542 String keyC = "c" + i;
543 String keyD = "d" + i;
544 String valueA = "a" + (i + NUMBER_OF_TESTS - 1);
545 String valueB = "b" + (i + NUMBER_OF_TESTS - 1);
546 String valueC = "c" + (i + NUMBER_OF_TESTS - 1);
547 String valueD = "d" + (i + NUMBER_OF_TESTS - 1);
549 IoTString iKeyA = new IoTString(keyA);
550 IoTString iKeyB = new IoTString(keyB);
551 IoTString iKeyC = new IoTString(keyC);
552 IoTString iKeyD = new IoTString(keyD);
553 IoTString iValueA = new IoTString(valueA);
554 IoTString iValueB = new IoTString(valueB);
555 IoTString iValueC = new IoTString(valueC);
556 IoTString iValueD = new IoTString(valueD);
559 IoTString testValA1 = t1.getCommitted(iKeyA);
560 IoTString testValB1 = t1.getCommitted(iKeyB);
561 IoTString testValC1 = t1.getCommitted(iKeyC);
562 IoTString testValD1 = t1.getCommitted(iKeyD);
564 IoTString testValA2 = t2.getCommitted(iKeyA);
565 IoTString testValB2 = t2.getCommitted(iKeyB);
566 IoTString testValC2 = t2.getCommitted(iKeyC);
567 IoTString testValD2 = t2.getCommitted(iKeyD);
569 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
570 System.out.println("Key-Value t1 incorrect: " + keyA + " " + testValA1);
574 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
575 System.out.println("Key-Value t1 incorrect: " + keyB + " " + testValB1);
579 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
580 System.out.println("Key-Value t1 incorrect: " + keyC + " " + testValC1);
584 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
585 System.out.println("Key-Value t1 incorrect: " + keyD + " " + testValD1);
590 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
591 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
595 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
596 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
600 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
601 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
605 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
606 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
611 for (TransactionStatus status : transStatusList) {
612 if (status.getStatus() != TransactionStatus.StatusCommitted) {
618 System.out.println("Found Errors...");
620 System.out.println("No Errors Found...");
624 static void test4() throws ServerException {
626 boolean foundError = false;
629 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
631 // Setup the 2 clients
632 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
634 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
638 System.out.println("Setting up keys");
639 startTime = System.currentTimeMillis();
640 for (int i = 0; i < 4; i++) {
645 IoTString ia = new IoTString(a);
646 IoTString ib = new IoTString(b);
647 IoTString ic = new IoTString(c);
648 IoTString id = new IoTString(d);
649 t1.createNewKey(ia, 321);
650 t1.createNewKey(ib, 351);
651 t2.createNewKey(ic, 321);
652 t2.createNewKey(id, 351);
654 endTime = System.currentTimeMillis();
655 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
656 System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
657 System.out.println();
660 // Do Updates for the keys
661 System.out.println("Setting Key-Values...");
662 startTime = System.currentTimeMillis();
663 for (int t = 0; t < NUMBER_OF_TESTS; t++) {
664 for (int i = 0; i < 4; i++) {
665 String keyA = "a" + i;
666 String keyB = "b" + i;
667 String keyC = "c" + i;
668 String keyD = "d" + i;
669 String valueA = "a" + i;
670 String valueB = "b" + i;
671 String valueC = "c" + i;
672 String valueD = "d" + i;
674 IoTString iKeyA = new IoTString(keyA);
675 IoTString iKeyB = new IoTString(keyB);
676 IoTString iKeyC = new IoTString(keyC);
677 IoTString iKeyD = new IoTString(keyD);
678 IoTString iValueA = new IoTString(valueA);
679 IoTString iValueB = new IoTString(valueB);
680 IoTString iValueC = new IoTString(valueC);
681 IoTString iValueD = new IoTString(valueD);
683 t1.startTransaction();
684 t1.addKV(iKeyA, iValueA);
685 transStatusList.add(t1.commitTransaction());
687 t1.startTransaction();
688 t1.addKV(iKeyB, iValueB);
689 transStatusList.add(t1.commitTransaction());
691 t2.startTransaction();
692 t2.addKV(iKeyC, iValueC);
693 transStatusList.add(t2.commitTransaction());
695 t2.startTransaction();
696 t2.addKV(iKeyD, iValueD);
697 transStatusList.add(t2.commitTransaction());
700 endTime = System.currentTimeMillis();
701 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
702 System.out.println("Time Taken Per Update: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 16)) );
703 System.out.println();
706 System.out.println("Updating Clients...");
711 System.out.println("Checking Key-Values...");
712 for (int i = 0; i < 4; i++) {
714 String keyA = "a" + i;
715 String keyB = "b" + i;
716 String keyC = "c" + i;
717 String keyD = "d" + i;
718 String valueA = "a" + i;
719 String valueB = "b" + i;
720 String valueC = "c" + i;
721 String valueD = "d" + i;
723 IoTString iKeyA = new IoTString(keyA);
724 IoTString iKeyB = new IoTString(keyB);
725 IoTString iKeyC = new IoTString(keyC);
726 IoTString iKeyD = new IoTString(keyD);
727 IoTString iValueA = new IoTString(valueA);
728 IoTString iValueB = new IoTString(valueB);
729 IoTString iValueC = new IoTString(valueC);
730 IoTString iValueD = new IoTString(valueD);
733 IoTString testValA1 = t1.getCommitted(iKeyA);
734 IoTString testValB1 = t1.getCommitted(iKeyB);
735 IoTString testValC1 = t1.getCommitted(iKeyC);
736 IoTString testValD1 = t1.getCommitted(iKeyD);
738 IoTString testValA2 = t2.getCommitted(iKeyA);
739 IoTString testValB2 = t2.getCommitted(iKeyB);
740 IoTString testValC2 = t2.getCommitted(iKeyC);
741 IoTString testValD2 = t2.getCommitted(iKeyD);
743 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
744 System.out.println("Key-Value t1 incorrect: " + keyA);
748 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
749 System.out.println("Key-Value t1 incorrect: " + keyB);
753 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
754 System.out.println("Key-Value t1 incorrect: " + keyC);
758 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
759 System.out.println("Key-Value t1 incorrect: " + keyD);
764 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
765 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
769 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
770 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
774 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
775 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
779 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
780 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
785 for (TransactionStatus status : transStatusList) {
786 if (status.getStatus() != TransactionStatus.StatusCommitted) {
792 System.out.println("Found Errors...");
794 System.out.println("No Errors Found...");
798 static void test3() throws ServerException {
802 boolean foundError = false;
804 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
806 // Setup the 2 clients
807 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
809 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
814 System.out.println("Setting up keys");
815 startTime = System.currentTimeMillis();
816 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
821 IoTString ia = new IoTString(a);
822 IoTString ib = new IoTString(b);
823 IoTString ic = new IoTString(c);
824 IoTString id = new IoTString(d);
825 t1.createNewKey(ia, 321);
826 t1.createNewKey(ib, 351);
827 t2.createNewKey(ic, 321);
828 t2.createNewKey(id, 351);
830 endTime = System.currentTimeMillis();
831 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
832 System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
833 System.out.println();
836 // Do Updates for the keys
837 System.out.println("Setting Key-Values...");
838 startTime = System.currentTimeMillis();
840 System.out.println("B...");
841 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
842 String keyB = "b" + i;
843 String valueB = "b" + i;
845 IoTString iKeyB = new IoTString(keyB);
846 IoTString iValueB = new IoTString(valueB);
848 t1.startTransaction();
849 t1.addKV(iKeyB, iValueB);
850 transStatusList.add(t1.commitTransaction());
853 System.out.println("C...");
854 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
855 String keyC = "c" + i;
856 String valueC = "c" + i;
858 IoTString iKeyC = new IoTString(keyC);
859 IoTString iValueC = new IoTString(valueC);
861 t2.startTransaction();
862 t2.addKV(iKeyC, iValueC);
863 transStatusList.add(t2.commitTransaction());
866 System.out.println("A, D...");
867 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
868 String keyA = "a" + i;
869 String keyD = "d" + i;
870 String valueA = "a" + i;
871 String valueD = "d" + i;
873 IoTString iKeyA = new IoTString(keyA);
874 IoTString iKeyD = new IoTString(keyD);
875 IoTString iValueA = new IoTString(valueA);
876 IoTString iValueD = new IoTString(valueD);
878 t1.startTransaction();
879 t1.addKV(iKeyA, iValueA);
880 transStatusList.add(t1.commitTransaction());
882 t2.startTransaction();
883 t2.addKV(iKeyD, iValueD);
884 transStatusList.add(t2.commitTransaction());
886 endTime = System.currentTimeMillis();
887 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
888 System.out.println("Time Taken Per Update: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
889 System.out.println();
892 System.out.println("Updating Clients...");
897 System.out.println("Checking Key-Values...");
898 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
900 String keyA = "a" + i;
901 String keyB = "b" + i;
902 String keyC = "c" + i;
903 String keyD = "d" + i;
904 String valueA = "a" + i;
905 String valueB = "b" + i;
906 String valueC = "c" + i;
907 String valueD = "d" + i;
909 IoTString iKeyA = new IoTString(keyA);
910 IoTString iKeyB = new IoTString(keyB);
911 IoTString iKeyC = new IoTString(keyC);
912 IoTString iKeyD = new IoTString(keyD);
913 IoTString iValueA = new IoTString(valueA);
914 IoTString iValueB = new IoTString(valueB);
915 IoTString iValueC = new IoTString(valueC);
916 IoTString iValueD = new IoTString(valueD);
919 IoTString testValA1 = t1.getCommitted(iKeyA);
920 IoTString testValB1 = t1.getCommitted(iKeyB);
921 IoTString testValC1 = t1.getCommitted(iKeyC);
922 IoTString testValD1 = t1.getCommitted(iKeyD);
924 IoTString testValA2 = t2.getCommitted(iKeyA);
925 IoTString testValB2 = t2.getCommitted(iKeyB);
926 IoTString testValC2 = t2.getCommitted(iKeyC);
927 IoTString testValD2 = t2.getCommitted(iKeyD);
929 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
930 System.out.println("Key-Value t1 incorrect: " + keyA);
934 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
935 System.out.println("Key-Value t1 incorrect: " + keyB);
939 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
940 System.out.println("Key-Value t1 incorrect: " + keyC);
944 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
945 System.out.println("Key-Value t1 incorrect: " + keyD);
950 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
951 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
955 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
956 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
960 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
961 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
965 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
966 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
971 for (TransactionStatus status : transStatusList) {
972 if (status.getStatus() != TransactionStatus.StatusCommitted) {
978 System.out.println("Found Errors...");
980 System.out.println("No Errors Found...");
984 static void test2() throws ServerException {
986 boolean foundError = false;
989 List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
991 // Setup the 2 clients
992 Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
994 System.out.println("T1 Ready");
996 Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
998 System.out.println("T2 Ready");
1001 System.out.println("Setting up keys");
1002 startTime = System.currentTimeMillis();
1003 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1008 IoTString ia = new IoTString(a);
1009 IoTString ib = new IoTString(b);
1010 IoTString ic = new IoTString(c);
1011 IoTString id = new IoTString(d);
1012 t1.createNewKey(ia, 321);
1013 t1.createNewKey(ib, 351);
1014 t2.createNewKey(ic, 321);
1015 t2.createNewKey(id, 351);
1017 endTime = System.currentTimeMillis();
1018 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1019 System.out.println("Time Taken Per Key: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
1020 System.out.println();
1022 // Do Updates for the keys
1023 System.out.println("Setting Key-Values...");
1024 startTime = System.currentTimeMillis();
1025 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1026 String keyA = "a" + i;
1027 String keyB = "b" + i;
1028 String keyC = "c" + i;
1029 String keyD = "d" + i;
1030 String valueA = "a" + i;
1031 String valueB = "b" + i;
1032 String valueC = "c" + i;
1033 String valueD = "d" + i;
1035 IoTString iKeyA = new IoTString(keyA);
1036 IoTString iKeyB = new IoTString(keyB);
1037 IoTString iKeyC = new IoTString(keyC);
1038 IoTString iKeyD = new IoTString(keyD);
1039 IoTString iValueA = new IoTString(valueA);
1040 IoTString iValueB = new IoTString(valueB);
1041 IoTString iValueC = new IoTString(valueC);
1042 IoTString iValueD = new IoTString(valueD);
1044 t1.startTransaction();
1045 t1.addKV(iKeyA, iValueA);
1046 transStatusList.add(t1.commitTransaction());
1049 t1.startTransaction();
1050 t1.addKV(iKeyB, iValueB);
1051 transStatusList.add(t1.commitTransaction());
1054 t2.startTransaction();
1055 t2.addKV(iKeyC, iValueC);
1056 transStatusList.add(t2.commitTransaction());
1059 t2.startTransaction();
1060 t2.addKV(iKeyD, iValueD);
1061 transStatusList.add(t2.commitTransaction());
1063 endTime = System.currentTimeMillis();
1064 System.out.println("Time Taken: " + (double) ((endTime - startTime) / 1000.0) );
1065 System.out.println("Time Taken Per Update: " + (double) (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4)) );
1066 System.out.println();
1069 System.out.println("Updating Clients...");
1074 System.out.println("Checking Key-Values...");
1075 for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1077 String keyA = "a" + i;
1078 String keyB = "b" + i;
1079 String keyC = "c" + i;
1080 String keyD = "d" + i;
1081 String valueA = "a" + i;
1082 String valueB = "b" + i;
1083 String valueC = "c" + i;
1084 String valueD = "d" + i;
1086 IoTString iKeyA = new IoTString(keyA);
1087 IoTString iKeyB = new IoTString(keyB);
1088 IoTString iKeyC = new IoTString(keyC);
1089 IoTString iKeyD = new IoTString(keyD);
1090 IoTString iValueA = new IoTString(valueA);
1091 IoTString iValueB = new IoTString(valueB);
1092 IoTString iValueC = new IoTString(valueC);
1093 IoTString iValueD = new IoTString(valueD);
1096 IoTString testValA1 = t1.getCommitted(iKeyA);
1097 IoTString testValB1 = t1.getCommitted(iKeyB);
1098 IoTString testValC1 = t1.getCommitted(iKeyC);
1099 IoTString testValD1 = t1.getCommitted(iKeyD);
1101 IoTString testValA2 = t2.getCommitted(iKeyA);
1102 IoTString testValB2 = t2.getCommitted(iKeyB);
1103 IoTString testValC2 = t2.getCommitted(iKeyC);
1104 IoTString testValD2 = t2.getCommitted(iKeyD);
1106 if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
1107 System.out.println("Key-Value t1 incorrect: " + keyA);
1111 if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1112 System.out.println("Key-Value t1 incorrect: " + keyB);
1116 if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
1117 System.out.println("Key-Value t1 incorrect: " + keyC);
1121 if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
1122 System.out.println("Key-Value t1 incorrect: " + keyD);
1127 if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
1128 System.out.println("Key-Value t2 incorrect: " + keyA + " " + testValA2);
1132 if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
1133 System.out.println("Key-Value t2 incorrect: " + keyB + " " + testValB2);
1137 if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1138 System.out.println("Key-Value t2 incorrect: " + keyC + " " + testValC2);
1142 if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
1143 System.out.println("Key-Value t2 incorrect: " + keyD + " " + testValD2);
1148 for (TransactionStatus status : transStatusList) {
1149 if (status.getStatus() != TransactionStatus.StatusCommitted) {
1151 System.out.println(status.getStatus());
1156 System.out.println("Found Errors...");
1158 System.out.println("No Errors Found...");