Local communication support
[iotcloud.git] / version2 / src / java / iotcloud / Test.java
1 package iotcloud;
2
3 import java.util.List;
4 import java.util.ArrayList;
5
6 /**
7  * Test cases.
8  * @author Brian Demsky
9  * @version 1.0
10  */
11
12 public class Test {
13
14     public static final  int NUMBER_OF_TESTS = 100;
15
16     public static void main(String[] args)  throws ServerException {
17         if (args[0].equals("2")) {
18             test2();
19         } else if (args[0].equals("3")) {
20             test3();
21         } else if (args[0].equals("4")) {
22             test4();
23         } else if (args[0].equals("5")) {
24             test5();
25         } else if (args[0].equals("6")) {
26             test6();
27         } else if (args[0].equals("7")) {
28             test7();
29         } else if (args[0].equals("8")) {
30             test8();
31         }
32     }
33
34     static void test8() {
35
36         boolean foundError = false;
37         List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
38
39         // Setup the 2 clients
40         Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, 6000);
41
42         System.out.println("Init Table t1s");
43
44         while (true) {
45             try {
46                 System.out.println("-==-=-=-=-=-=-=-==-=-");
47                 t1.initTable();
48                 break;
49             } catch (Exception e) {}
50         }
51
52
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) {}
56
57         t1.addLocalCommunication(351, "127.0.0.1", 6001);
58         t2.addLocalCommunication(321, "127.0.0.1", 6000);
59
60         // Make the Keys
61         System.out.println("Setting up keys");
62         for (int i = 0; i < NUMBER_OF_TESTS; i++) {
63             System.out.println(i);
64
65             String a = "a" + i;
66             String b = "b" + i;
67             String c = "c" + i;
68             String d = "d" + 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);
73
74             while (true) {
75                 try {
76                     t1.createNewKey(ia, 321);
77                     break;
78                 } catch (Exception e) { }
79             }
80
81             while (true) {
82                 try {
83                     t1.createNewKey(ib, 351);
84                     break;
85                 } catch (Exception e) { }
86             }
87
88             while (true) {
89                 try {
90                     t2.createNewKey(ic, 321);
91                     break;
92                 } catch (Exception e) { }
93             }
94
95             while (true) {
96                 try {
97                     t2.createNewKey(id, 351);
98                     break;
99                 } catch (Exception e) { }
100             }
101         }
102
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;
115
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);
124
125
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);
134
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);
143
144             t1.startTransaction();
145             t1.addKV(iKeyA, iValueA);
146             transStatusList.add(t1.commitTransaction());
147
148             t1.startTransaction();
149             t1.addKV(iKeyB, iValueB);
150             transStatusList.add(t1.commitTransaction());
151
152             t2.startTransaction();
153             t2.addKV(iKeyC, iValueC);
154             transStatusList.add(t2.commitTransaction());
155
156             t2.startTransaction();
157             t2.addKV(iKeyD, iValueD);
158             transStatusList.add(t2.commitTransaction());
159         }
160
161         System.out.println("Updating...");
162         while (t1.update() == false) {}
163         while (t2.update() == false) {}
164         while (t1.update() == false) {}
165
166         System.out.println("Checking Key-Values...");
167         for (int i = 0; i < NUMBER_OF_TESTS; i++) {
168
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;
177
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);
186
187
188             IoTString testValA1 = t1.getCommitted(iKeyA);
189             IoTString testValB1 = t1.getCommitted(iKeyB);
190             IoTString testValC1 = t1.getCommitted(iKeyC);
191             IoTString testValD1 = t1.getCommitted(iKeyD);
192
193             IoTString testValA2 = t2.getCommitted(iKeyA);
194             IoTString testValB2 = t2.getCommitted(iKeyB);
195             IoTString testValC2 = t2.getCommitted(iKeyC);
196             IoTString testValD2 = t2.getCommitted(iKeyD);
197
198             if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
199                 System.out.println("Key-Value t1 incorrect: " + keyA + "    " + testValA1);
200                 foundError = true;
201             }
202
203             if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
204                 System.out.println("Key-Value t1 incorrect: " + keyB + "    " + testValB1);
205                 foundError = true;
206             }
207
208             if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
209                 System.out.println("Key-Value t1 incorrect: " + keyC + "    " + testValC1);
210                 foundError = true;
211             }
212
213             if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
214                 System.out.println("Key-Value t1 incorrect: " + keyD + "    " + testValD1);
215                 foundError = true;
216             }
217
218
219             if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
220                 System.out.println("Key-Value t2 incorrect: " + keyA + "    " + testValA2);
221                 foundError = true;
222             }
223
224             if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
225                 System.out.println("Key-Value t2 incorrect: " + keyB + "    " + testValB2);
226                 foundError = true;
227             }
228
229             if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
230                 System.out.println("Key-Value t2 incorrect: " + keyC + "    " + testValC2);
231                 foundError = true;
232             }
233
234             if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
235                 System.out.println("Key-Value t2 incorrect: " + keyD + "    " + testValD2);
236                 foundError = true;
237             }
238         }
239
240         for (TransactionStatus status : transStatusList) {
241             if (status.getStatus() != TransactionStatus.StatusCommitted) {
242                 foundError = true;
243             }
244         }
245
246         if (foundError) {
247             System.out.println("Found Errors...");
248         } else {
249             System.out.println("No Errors Found...");
250         }
251
252         t1.close();
253         t2.close();
254     }
255
256     static void test7() throws ServerException {
257
258         boolean foundError = false;
259         List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
260
261         // Setup the 2 clients
262         Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, -1);
263         t1.initTable();
264         Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, -1);
265         t2.update();
266
267         // Make the Keys
268         System.out.println("Setting up keys");
269         for (int i = 0; i < 4; i++) {
270             String a = "a" + i;
271             String b = "b" + i;
272             String c = "c" + i;
273             String d = "d" + 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);
282         }
283
284         // Do Updates for the keys
285         System.out.println("Setting Key-Values...");
286
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);
291
292                 IoTString iKeyB = new IoTString(keyB);
293                 IoTString iValueB = new IoTString(valueB);
294
295                 t1.startTransaction();
296                 t1.getSpeculativeAtomic(iKeyB);
297                 t1.addKV(iKeyB, iValueB);
298                 transStatusList.add(t1.commitTransaction());
299             }
300         }
301
302         for (int i = 0; i < 4; i++) {
303
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);
308
309             IoTString testValB1 = t1.getSpeculative(iKeyB);
310             IoTString testValB2 = t2.getSpeculative(iKeyB);
311
312             if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
313                 System.out.println("Key-Value t1 incorrect: " + keyB + "    " + testValB1);
314                 foundError = true;
315             }
316
317             if ((testValB2 != null)) {
318                 System.out.println("Key-Value t2 incorrect: " + keyB + "    " + testValB2);
319                 foundError = true;
320             }
321         }
322
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);
327
328                 IoTString iKeyC = new IoTString(keyC);
329                 IoTString iValueC = new IoTString(valueC);
330
331                 t2.startTransaction();
332                 t2.getSpeculativeAtomic(iKeyC);
333                 t2.addKV(iKeyC, iValueC);
334                 transStatusList.add(t2.commitTransaction());
335             }
336         }
337
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);
343
344             IoTString testValC1 = t1.getSpeculative(iKeyC);
345             IoTString testValC2 = t2.getSpeculative(iKeyC);
346
347             if ((testValC1 != null)) {
348                 System.out.println("Key-Value t1 incorrect: " + keyC + "   " + testValC1);
349                 foundError = true;
350             }
351
352             if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
353                 System.out.println("Key-Value t2 incorrect: " + keyC + "   " + testValC2);
354                 foundError = true;
355             }
356         }
357
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);
364
365                 IoTString iKeyA = new IoTString(keyA);
366                 IoTString iKeyD = new IoTString(keyD);
367                 IoTString iValueA = new IoTString(valueA);
368                 IoTString iValueD = new IoTString(valueD);
369
370                 t1.startTransaction();
371                 t1.addKV(iKeyA, iValueA);
372                 transStatusList.add(t1.commitTransaction());
373
374                 t2.startTransaction();
375                 t2.addKV(iKeyD, iValueD);
376                 transStatusList.add(t2.commitTransaction());
377             }
378         }
379
380         System.out.println("Updating Clients...");
381         t1.update();
382         t2.update();
383         t1.update();
384         t2.update();
385
386         System.out.println("Checking Key-Values...");
387         for (int i = 0; i < 4; i++) {
388
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);
397
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);
406
407
408             IoTString testValA1 = t1.getCommitted(iKeyA);
409             IoTString testValB1 = t1.getCommitted(iKeyB);
410             IoTString testValC1 = t1.getCommitted(iKeyC);
411             IoTString testValD1 = t1.getCommitted(iKeyD);
412
413             IoTString testValA2 = t2.getCommitted(iKeyA);
414             IoTString testValB2 = t2.getCommitted(iKeyB);
415             IoTString testValC2 = t2.getCommitted(iKeyC);
416             IoTString testValD2 = t2.getCommitted(iKeyD);
417
418             if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
419                 System.out.println("Key-Value t1 incorrect: " + keyA + "    " + testValA1);
420                 foundError = true;
421             }
422
423             if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
424                 System.out.println("Key-Value t1 incorrect: " + keyB + "    " + testValB1);
425                 foundError = true;
426             }
427
428             if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
429                 System.out.println("Key-Value t1 incorrect: " + keyC + "    " + testValC1);
430                 foundError = true;
431             }
432
433             if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
434                 System.out.println("Key-Value t1 incorrect: " + keyD + "    " + testValD1);
435                 foundError = true;
436             }
437
438             if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
439                 System.out.println("Key-Value t2 incorrect: " + keyA + "    " + testValA2);
440                 foundError = true;
441             }
442
443             if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
444                 System.out.println("Key-Value t2 incorrect: " + keyB + "    " + testValB2);
445                 foundError = true;
446             }
447
448             if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
449                 System.out.println("Key-Value t2 incorrect: " + keyC + "    " + testValC2);
450                 foundError = true;
451             }
452
453             if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
454                 System.out.println("Key-Value t2 incorrect: " + keyD + "    " + testValD2);
455                 foundError = true;
456             }
457         }
458
459         for (TransactionStatus status : transStatusList) {
460             if (status.getStatus() != TransactionStatus.StatusCommitted) {
461                 foundError = true;
462             }
463         }
464
465         if (foundError) {
466             System.out.println("Found Errors...");
467         } else {
468             System.out.println("No Errors Found...");
469         }
470     }
471
472     static void test6() throws ServerException {
473
474         boolean foundError = false;
475         List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
476
477         // Setup the 2 clients
478         Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, -1);
479         t1.initTable();
480         Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, -1);
481         t2.update();
482
483         // Make the Keys
484         System.out.println("Setting up keys");
485         for (int i = 0; i < NUMBER_OF_TESTS; i++) {
486             String a = "a" + i;
487             String b = "b" + i;
488             String c = "c" + i;
489             String d = "d" + 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);
498         }
499
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;
511
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);
520
521             t1.startTransaction();
522             t1.getCommittedAtomic(iKeyA);
523             t1.addKV(iKeyA, iValueA);
524             transStatusList.add(t1.commitTransaction());
525
526             t1.startTransaction();
527             t1.getCommittedAtomic(iKeyB);
528             t1.addKV(iKeyB, iValueB);
529             transStatusList.add(t1.commitTransaction());
530
531             t2.startTransaction();
532             t2.getCommittedAtomic(iKeyC);
533             t2.addKV(iKeyC, iValueC);
534             transStatusList.add(t2.commitTransaction());
535
536             t2.startTransaction();
537             t2.getCommittedAtomic(iKeyD);
538             t2.addKV(iKeyD, iValueD);
539             transStatusList.add(t2.commitTransaction());
540         }
541
542         System.out.println("Updating Clients...");
543         t1.update();
544         t2.update();
545
546         System.out.println("Checking Key-Values...");
547         for (int i = 0; i < NUMBER_OF_TESTS; i++) {
548
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;
557
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);
566
567
568             IoTString testValA1 = t1.getCommitted(iKeyA);
569             IoTString testValB1 = t1.getCommitted(iKeyB);
570             IoTString testValC1 = t1.getCommitted(iKeyC);
571             IoTString testValD1 = t1.getCommitted(iKeyD);
572
573             IoTString testValA2 = t2.getCommitted(iKeyA);
574             IoTString testValB2 = t2.getCommitted(iKeyB);
575             IoTString testValC2 = t2.getCommitted(iKeyC);
576             IoTString testValD2 = t2.getCommitted(iKeyD);
577
578             if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
579                 System.out.println("Key-Value t1 incorrect: " + keyA);
580                 foundError = true;
581             }
582
583             if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
584                 System.out.println("Key-Value t1 incorrect: " + keyB);
585                 foundError = true;
586             }
587
588             if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
589                 System.out.println("Key-Value t1 incorrect: " + keyC);
590                 foundError = true;
591             }
592
593             if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
594                 System.out.println("Key-Value t1 incorrect: " + keyD);
595                 foundError = true;
596             }
597
598
599             if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
600                 System.out.println("Key-Value t2 incorrect: " + keyA + "    " + testValA2);
601                 foundError = true;
602             }
603
604             if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
605                 System.out.println("Key-Value t2 incorrect: " + keyB + "    " + testValB2);
606                 foundError = true;
607             }
608
609             if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
610                 System.out.println("Key-Value t2 incorrect: " + keyC + "    " + testValC2);
611                 foundError = true;
612             }
613
614             if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
615                 System.out.println("Key-Value t2 incorrect: " + keyD + "    " + testValD2);
616                 foundError = true;
617             }
618         }
619
620         for (TransactionStatus status : transStatusList) {
621             if (status.getStatus() != TransactionStatus.StatusCommitted) {
622                 foundError = true;
623             }
624         }
625
626         if (foundError) {
627             System.out.println("Found Errors...");
628         } else {
629             System.out.println("No Errors Found...");
630         }
631     }
632
633     static void test5() throws ServerException {
634
635         boolean foundError = false;
636         List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
637
638         // Setup the 2 clients
639         Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, -1);
640         t1.initTable();
641         Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, -1);
642         t2.update();
643
644
645         // Make the Keys
646         System.out.println("Setting up keys");
647         for (int i = 0; i < 4; i++) {
648             String a = "a" + i;
649             String b = "b" + i;
650             String c = "c" + i;
651             String d = "d" + 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);
660         }
661
662         // Do Updates for the keys
663         System.out.println("Setting Key-Values...");
664
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);
669
670                 IoTString iKeyB = new IoTString(keyB);
671                 IoTString iValueB = new IoTString(valueB);
672
673                 t1.startTransaction();
674                 t1.addKV(iKeyB, iValueB);
675                 transStatusList.add(t1.commitTransaction());
676             }
677         }
678
679         for (int i = 0; i < 4; i++) {
680
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);
685
686             IoTString testValB1 = t1.getSpeculative(iKeyB);
687             IoTString testValB2 = t2.getSpeculative(iKeyB);
688
689             if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
690                 System.out.println("Key-Value t1 incorrect: " + keyB);
691                 foundError = true;
692             }
693
694             if ((testValB2 != null)) {
695                 System.out.println("Key-Value t2 incorrect: " + keyB);
696                 foundError = true;
697             }
698         }
699
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);
704
705                 IoTString iKeyC = new IoTString(keyC);
706                 IoTString iValueC = new IoTString(valueC);
707
708                 t2.startTransaction();
709                 t2.addKV(iKeyC, iValueC);
710                 transStatusList.add(t2.commitTransaction());
711             }
712         }
713
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);
719
720             IoTString testValC1 = t1.getSpeculative(iKeyC);
721             IoTString testValC2 = t2.getSpeculative(iKeyC);
722
723             if ((testValC1 != null)) {
724                 System.out.println("Key-Value t1 incorrect: " + keyC + "   " + testValC1);
725                 foundError = true;
726             }
727
728             if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
729                 System.out.println("Key-Value t2 incorrect: " + keyC + "   " + testValC2);
730                 foundError = true;
731             }
732         }
733
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);
740
741                 IoTString iKeyA = new IoTString(keyA);
742                 IoTString iKeyD = new IoTString(keyD);
743                 IoTString iValueA = new IoTString(valueA);
744                 IoTString iValueD = new IoTString(valueD);
745
746                 t1.startTransaction();
747                 t1.addKV(iKeyA, iValueA);
748                 transStatusList.add(t1.commitTransaction());
749
750                 t2.startTransaction();
751                 t2.addKV(iKeyD, iValueD);
752                 transStatusList.add(t2.commitTransaction());
753             }
754         }
755
756         System.out.println("Updating Clients...");
757         t1.update();
758         t2.update();
759
760
761         System.out.println("Checking Key-Values...");
762         for (int i = 0; i < 4; i++) {
763
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);
772
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);
781
782
783             IoTString testValA1 = t1.getCommitted(iKeyA);
784             IoTString testValB1 = t1.getCommitted(iKeyB);
785             IoTString testValC1 = t1.getCommitted(iKeyC);
786             IoTString testValD1 = t1.getCommitted(iKeyD);
787
788             IoTString testValA2 = t2.getCommitted(iKeyA);
789             IoTString testValB2 = t2.getCommitted(iKeyB);
790             IoTString testValC2 = t2.getCommitted(iKeyC);
791             IoTString testValD2 = t2.getCommitted(iKeyD);
792
793             if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
794                 System.out.println("Key-Value t1 incorrect: " + keyA + "    " + testValA1);
795                 foundError = true;
796             }
797
798             if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
799                 System.out.println("Key-Value t1 incorrect: " + keyB + "    " + testValB1);
800                 foundError = true;
801             }
802
803             if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
804                 System.out.println("Key-Value t1 incorrect: " + keyC + "    " + testValC1);
805                 foundError = true;
806             }
807
808             if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
809                 System.out.println("Key-Value t1 incorrect: " + keyD + "    " + testValD1);
810                 foundError = true;
811             }
812
813
814             if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
815                 System.out.println("Key-Value t2 incorrect: " + keyA + "    " + testValA2);
816                 foundError = true;
817             }
818
819             if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
820                 System.out.println("Key-Value t2 incorrect: " + keyB + "    " + testValB2);
821                 foundError = true;
822             }
823
824             if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
825                 System.out.println("Key-Value t2 incorrect: " + keyC + "    " + testValC2);
826                 foundError = true;
827             }
828
829             if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
830                 System.out.println("Key-Value t2 incorrect: " + keyD + "    " + testValD2);
831                 foundError = true;
832             }
833         }
834
835         for (TransactionStatus status : transStatusList) {
836             if (status.getStatus() != TransactionStatus.StatusCommitted) {
837                 foundError = true;
838             }
839         }
840
841         if (foundError) {
842             System.out.println("Found Errors...");
843         } else {
844             System.out.println("No Errors Found...");
845         }
846     }
847
848     static void test4() throws ServerException {
849
850         boolean foundError = false;
851         long startTime = 0;
852         long endTime = 0;
853         List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
854
855         // Setup the 2 clients
856         Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, -1);
857         t1.initTable();
858         Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, -1);
859         t2.update();
860
861         // Make the Keys
862         System.out.println("Setting up keys");
863         startTime = System.currentTimeMillis();
864         for (int i = 0; i < 4; i++) {
865             String a = "a" + i;
866             String b = "b" + i;
867             String c = "c" + i;
868             String d = "d" + 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);
877         }
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();
882
883
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;
897
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);
906
907                 t1.startTransaction();
908                 t1.addKV(iKeyA, iValueA);
909                 transStatusList.add(t1.commitTransaction());
910
911                 t1.startTransaction();
912                 t1.addKV(iKeyB, iValueB);
913                 transStatusList.add(t1.commitTransaction());
914
915                 t2.startTransaction();
916                 t2.addKV(iKeyC, iValueC);
917                 transStatusList.add(t2.commitTransaction());
918
919                 t2.startTransaction();
920                 t2.addKV(iKeyD, iValueD);
921                 transStatusList.add(t2.commitTransaction());
922             }
923         }
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();
928
929
930         System.out.println("Updating Clients...");
931         t1.update();
932         t2.update();
933
934
935         System.out.println("Checking Key-Values...");
936         for (int i = 0; i < 4; i++) {
937
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;
946
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);
955
956
957             IoTString testValA1 = t1.getCommitted(iKeyA);
958             IoTString testValB1 = t1.getCommitted(iKeyB);
959             IoTString testValC1 = t1.getCommitted(iKeyC);
960             IoTString testValD1 = t1.getCommitted(iKeyD);
961
962             IoTString testValA2 = t2.getCommitted(iKeyA);
963             IoTString testValB2 = t2.getCommitted(iKeyB);
964             IoTString testValC2 = t2.getCommitted(iKeyC);
965             IoTString testValD2 = t2.getCommitted(iKeyD);
966
967             if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
968                 System.out.println("Key-Value t1 incorrect: " + keyA);
969                 foundError = true;
970             }
971
972             if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
973                 System.out.println("Key-Value t1 incorrect: " + keyB);
974                 foundError = true;
975             }
976
977             if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
978                 System.out.println("Key-Value t1 incorrect: " + keyC);
979                 foundError = true;
980             }
981
982             if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
983                 System.out.println("Key-Value t1 incorrect: " + keyD);
984                 foundError = true;
985             }
986
987
988             if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
989                 System.out.println("Key-Value t2 incorrect: " + keyA + "    " + testValA2);
990                 foundError = true;
991             }
992
993             if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
994                 System.out.println("Key-Value t2 incorrect: " + keyB + "    " + testValB2);
995                 foundError = true;
996             }
997
998             if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
999                 System.out.println("Key-Value t2 incorrect: " + keyC + "    " + testValC2);
1000                 foundError = true;
1001             }
1002
1003             if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
1004                 System.out.println("Key-Value t2 incorrect: " + keyD + "    " + testValD2);
1005                 foundError = true;
1006             }
1007         }
1008
1009         for (TransactionStatus status : transStatusList) {
1010             if (status.getStatus() != TransactionStatus.StatusCommitted) {
1011                 foundError = true;
1012             }
1013         }
1014
1015         if (foundError) {
1016             System.out.println("Found Errors...");
1017         } else {
1018             System.out.println("No Errors Found...");
1019         }
1020     }
1021
1022     static void test3() throws ServerException {
1023
1024         long startTime = 0;
1025         long endTime = 0;
1026         boolean foundError = false;
1027
1028         List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
1029
1030         // Setup the 2 clients
1031         Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, -1);
1032         t1.initTable();
1033         Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, -1);
1034         t2.update();
1035
1036
1037         // Make the Keys
1038         System.out.println("Setting up keys");
1039         startTime = System.currentTimeMillis();
1040         for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1041             String a = "a" + i;
1042             String b = "b" + i;
1043             String c = "c" + i;
1044             String d = "d" + 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);
1053         }
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();
1058
1059
1060         // Do Updates for the keys
1061         System.out.println("Setting Key-Values...");
1062         startTime = System.currentTimeMillis();
1063
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;
1068
1069             IoTString iKeyB = new IoTString(keyB);
1070             IoTString iValueB = new IoTString(valueB);
1071
1072             t1.startTransaction();
1073             t1.addKV(iKeyB, iValueB);
1074             transStatusList.add(t1.commitTransaction());
1075         }
1076
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;
1081
1082             IoTString iKeyC = new IoTString(keyC);
1083             IoTString iValueC = new IoTString(valueC);
1084
1085             t2.startTransaction();
1086             t2.addKV(iKeyC, iValueC);
1087             transStatusList.add(t2.commitTransaction());
1088         }
1089
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;
1096
1097             IoTString iKeyA = new IoTString(keyA);
1098             IoTString iKeyD = new IoTString(keyD);
1099             IoTString iValueA = new IoTString(valueA);
1100             IoTString iValueD = new IoTString(valueD);
1101
1102             t1.startTransaction();
1103             t1.addKV(iKeyA, iValueA);
1104             transStatusList.add(t1.commitTransaction());
1105
1106             t2.startTransaction();
1107             t2.addKV(iKeyD, iValueD);
1108             transStatusList.add(t2.commitTransaction());
1109         }
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();
1114
1115
1116         System.out.println("Updating Clients...");
1117         t1.update();
1118         t2.update();
1119
1120
1121         System.out.println("Checking Key-Values...");
1122         for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1123
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;
1132
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);
1141
1142
1143             IoTString testValA1 = t1.getCommitted(iKeyA);
1144             IoTString testValB1 = t1.getCommitted(iKeyB);
1145             IoTString testValC1 = t1.getCommitted(iKeyC);
1146             IoTString testValD1 = t1.getCommitted(iKeyD);
1147
1148             IoTString testValA2 = t2.getCommitted(iKeyA);
1149             IoTString testValB2 = t2.getCommitted(iKeyB);
1150             IoTString testValC2 = t2.getCommitted(iKeyC);
1151             IoTString testValD2 = t2.getCommitted(iKeyD);
1152
1153             if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
1154                 System.out.println("Key-Value t1 incorrect: " + keyA);
1155                 foundError = true;
1156             }
1157
1158             if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1159                 System.out.println("Key-Value t1 incorrect: " + keyB);
1160                 foundError = true;
1161             }
1162
1163             if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
1164                 System.out.println("Key-Value t1 incorrect: " + keyC);
1165                 foundError = true;
1166             }
1167
1168             if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
1169                 System.out.println("Key-Value t1 incorrect: " + keyD);
1170                 foundError = true;
1171             }
1172
1173
1174             if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
1175                 System.out.println("Key-Value t2 incorrect: " + keyA + "    " + testValA2);
1176                 foundError = true;
1177             }
1178
1179             if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
1180                 System.out.println("Key-Value t2 incorrect: " + keyB + "    " + testValB2);
1181                 foundError = true;
1182             }
1183
1184             if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1185                 System.out.println("Key-Value t2 incorrect: " + keyC + "    " + testValC2);
1186                 foundError = true;
1187             }
1188
1189             if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
1190                 System.out.println("Key-Value t2 incorrect: " + keyD + "    " + testValD2);
1191                 foundError = true;
1192             }
1193         }
1194
1195         for (TransactionStatus status : transStatusList) {
1196             if (status.getStatus() != TransactionStatus.StatusCommitted) {
1197                 foundError = true;
1198             }
1199         }
1200
1201         if (foundError) {
1202             System.out.println("Found Errors...");
1203         } else {
1204             System.out.println("No Errors Found...");
1205         }
1206     }
1207
1208     static void test2() throws ServerException {
1209
1210         boolean foundError = false;
1211         long startTime = 0;
1212         long endTime = 0;
1213         List<TransactionStatus> transStatusList = new ArrayList<TransactionStatus>();
1214
1215         // Setup the 2 clients
1216         Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321, -1);
1217         t1.initTable();
1218         System.out.println("T1 Ready");
1219
1220         Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351, -1);
1221         t2.update();
1222         System.out.println("T2 Ready");
1223
1224         // Make the Keys
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);
1229             String a = "a" + i;
1230             String b = "b" + i;
1231             String c = "c" + i;
1232             String d = "d" + 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);
1241         }
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();
1246
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;
1260
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);
1269
1270
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();
1278
1279
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();
1287
1288
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();
1296
1297
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();
1305
1306         }
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();
1311
1312
1313         System.out.println("Updating Clients...");
1314         t1.update();
1315         t2.update();
1316
1317
1318         System.out.println("Checking Key-Values...");
1319         for (int i = 0; i < NUMBER_OF_TESTS; i++) {
1320
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;
1329
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);
1338
1339
1340             IoTString testValA1 = t1.getCommitted(iKeyA);
1341             IoTString testValB1 = t1.getCommitted(iKeyB);
1342             IoTString testValC1 = t1.getCommitted(iKeyC);
1343             IoTString testValD1 = t1.getCommitted(iKeyD);
1344
1345             IoTString testValA2 = t2.getCommitted(iKeyA);
1346             IoTString testValB2 = t2.getCommitted(iKeyB);
1347             IoTString testValC2 = t2.getCommitted(iKeyC);
1348             IoTString testValD2 = t2.getCommitted(iKeyD);
1349
1350             if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
1351                 System.out.println("Key-Value t1 incorrect: " + keyA);
1352                 foundError = true;
1353             }
1354
1355             if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
1356                 System.out.println("Key-Value t1 incorrect: " + keyB);
1357                 foundError = true;
1358             }
1359
1360             if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
1361                 System.out.println("Key-Value t1 incorrect: " + keyC);
1362                 foundError = true;
1363             }
1364
1365             if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
1366                 System.out.println("Key-Value t1 incorrect: " + keyD);
1367                 foundError = true;
1368             }
1369
1370
1371             if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
1372                 System.out.println("Key-Value t2 incorrect: " + keyA + "    " + testValA2);
1373                 foundError = true;
1374             }
1375
1376             if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
1377                 System.out.println("Key-Value t2 incorrect: " + keyB + "    " + testValB2);
1378                 foundError = true;
1379             }
1380
1381             if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
1382                 System.out.println("Key-Value t2 incorrect: " + keyC + "    " + testValC2);
1383                 foundError = true;
1384             }
1385
1386             if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
1387                 System.out.println("Key-Value t2 incorrect: " + keyD + "    " + testValD2);
1388                 foundError = true;
1389             }
1390         }
1391
1392         for (TransactionStatus status : transStatusList) {
1393             if (status.getStatus() != TransactionStatus.StatusCommitted) {
1394                 foundError = true;
1395                 System.out.println(status.getStatus());
1396             }
1397         }
1398
1399         if (foundError) {
1400             System.out.println("Found Errors...");
1401         } else {
1402             System.out.println("No Errors Found...");
1403         }
1404
1405         System.out.println();
1406         System.out.println();
1407         t1.printSlots();
1408
1409         System.out.println();
1410         System.out.println();
1411         t2.printSlots();
1412     }
1413 }