Squashed Last bugs
authorAli Younis <ayounis@uci.edu>
Wed, 28 Dec 2016 04:30:42 +0000 (20:30 -0800)
committerAli Younis <ayounis@uci.edu>
Wed, 28 Dec 2016 04:30:42 +0000 (20:30 -0800)
version2/src/java/iotcloud/CloudComm.java
version2/src/java/iotcloud/Commit.java
version2/src/java/iotcloud/Guard.java
version2/src/java/iotcloud/Slot.java
version2/src/java/iotcloud/Table.java
version2/src/java/iotcloud/Test.java

index f38756d5fea4f3b6d877828ac392030f3b09169b..33e3d00fe7c1c4513f9d724e727a408d092e52b3 100644 (file)
@@ -106,7 +106,7 @@ class CloudComm {
                        int responsecode = http.getResponseCode();
                        if (responsecode != HttpURLConnection.HTTP_OK) {
                                // TODO: Remove this print
-                               System.out.println(responsecode);
+                               // System.out.println(responsecode);
                                throw new Error("Invalid response");
                        }
                } catch (Exception e) {
index 72249225b777c2ca4875b9df7d23cf0375a5b4ca..deeb501c8ef47ed51192393914c66a270790e5db 100644 (file)
@@ -87,7 +87,6 @@ class Commit extends Entry {
        }
 
        public Entry getCopy(Slot s) {
-               // System.out.println("Commit Rescued:  " + this);  // TODO remove
                return new Commit(s, seqnumtrans, transarbitrator, keyValueUpdateSet);
        }
 
@@ -103,7 +102,6 @@ class Commit extends Entry {
                                KeyValue kv2 = i.next();
 
                                if (kv1.getKey().equals(kv2.getKey())) {
-                                       // keyValueUpdateSet.remove(kv2);
                                        toDelete.add(kv2);
                                        i.remove();
                                        break;
@@ -112,7 +110,6 @@ class Commit extends Entry {
                }
 
                if (keyValueUpdateSet.size() == 0) {
-                       // System.out.println("Killed Commit:  " + this); // TODO remove
                        this.setDead();
                }
 
index 4e426fd92ef831af45a6e49fdb8a760820778721..f768b7f647e3375b0d7122be307e8f0fce241fa2 100644 (file)
@@ -3,6 +3,9 @@ package iotcloud;
 import java.util.Set;
 import java.util.HashSet;
 import java.util.Collection;
+import java.util.List;
+import java.util.ArrayList;
+
 import java.nio.ByteBuffer;
 
 import javax.script.ScriptEngine;
@@ -15,8 +18,8 @@ class Guard {
 
     static final byte Equal = 1;
     static final byte NotEqual = 2;
-
     private IoTString booleanExpression;
+    private List<KeyValue> keyValsNeeded = null;
 
     public Guard() {
         booleanExpression = null;
@@ -60,24 +63,59 @@ class Guard {
             return true;
         }
 
+        ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript");
+
+        if (keyValsNeeded == null) {
+            keyValsNeeded = new ArrayList<KeyValue>();
+
+            String booleanExprString = booleanExpression.toString();
+            for (KeyValue kv : kvSet) {
+                if (booleanExprString.contains(kv.getKey().toString())) {
+                    keyValsNeeded.add(kv);
+                }
+            }
+        }
+
         // All the current key value pairs that we need to evaluate the condition
-        String[] variables = new String[kvSet.size()];
+        // String[] variables = new String[kvSet.size()];
 
         // Fill the variables array
-        int i = 0;
-        for (KeyValue kv : kvSet) {
-            variables[i] = kv.getKey() + " ='" + kv.getValue() + "'";
-            i++;
+        // int i = 0;
+        // for (KeyValue kv : kvSet) {
+        // for (KeyValue kv : keyValsNeeded) {
+        //     variables[i] = kv.getKey() + " ='" + kv.getValue() + "'";
+        //     i++;
+        // }
+
+        String varEval = "";
+        for (KeyValue kv : keyValsNeeded) {
+            varEval += "var " + kv.getKey() + " ='" + kv.getValue() + "'; \n";
         }
 
+        varEval += booleanExpression.toString();
+
         // Prep the evaluation engine (script engine)
-        ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript");
-        for (String s : variables) {
-            engine.eval(s);
+
+        // for (String s : variables) {
+        //     engine.eval(s);
+        // }
+        // engine.eval(varEval);
+
+
+
+        // boolean engineEval = (Boolean)engine.eval(booleanExpression.toString());
+        boolean engineEval = false;
+
+        try {
+            engineEval = (Boolean)engine.eval(varEval);
+        } catch (Exception e) {
+            // If there was an error then the script evaluated to false 
+            engineEval = false;
         }
 
         // Evaluate the guard condition
-        return 1 == (Integer)engine.eval(booleanExpression.toString());
+        // return 1 == (Integer)engine.eval(booleanExpression.toString());
+        return engineEval;
     }
 
     /**
index 2ceb142b9ae1d4448c60ce1c6a807d5c068f5cb5..ab0435963101341775976166c57a140363648c1d 100644 (file)
@@ -204,7 +204,6 @@ class Slot implements Liveness {
        void decrementLiveCount() {
                livecount--;
                if (livecount == 0) {
-                       // System.out.println("Slot Set Dead"); // TODO: remove
                        table.decrementLiveCount();
                }
        }
index 99dc9bac945d02aea2dac5387eb8886542b73015..d42679d8add869edf9273074f6dd7b4e2f3965ae 100644 (file)
@@ -39,12 +39,12 @@ final public class Table {
        private TableStatus lastTableStatus;
        static final int FREE_SLOTS = 10; //number of slots that should be kept free
        static final int SKIP_THRESHOLD = 10;
-       public long liveslotcount = 0;  // TODO:  MAKE PRIVATE
+       private long liveslotcount = 0; 
        private int chance;
        static final double RESIZE_MULTIPLE = 1.2;
        static final double RESIZE_THRESHOLD = 0.75;
        static final int REJECTED_THRESHOLD = 5;
-       public int resizethreshold;     // TODO:  MAKE PRIVATE
+       private int resizethreshold;
        private long lastliveslotseqn;  //smallest sequence number with a live entry
        private Random random = new Random();
        private long lastUncommittedTransaction = 0;
@@ -53,13 +53,12 @@ final public class Table {
        private Queue<PendingTransaction> pendingTransQueue = null; // Queue of pending transactions
        private Map<Long, Commit> commitMap = null; // List of all the most recent live commits
        private Map<Long, Abort> abortMap = null; // Set of the live aborts
-       private Map<IoTString, Commit> committedMapByKey = null; // Table of committed KV       TODO: Make Private
-       public  Map<IoTString, KeyValue> commitedTable = null; // Table of committed KV       TODO: Make Private
+       private Map<IoTString, Commit> committedMapByKey = null; // Table of committed KV   
+       private  Map<IoTString, KeyValue> commitedTable = null; // Table of committed KV    
        private Map<IoTString, KeyValue> speculativeTable = null; // Table of speculative KV
-       public Map<Long, Transaction> uncommittedTransactionsMap = null; // TODO: make private
+       private Map<Long, Transaction> uncommittedTransactionsMap = null;
        private Map<IoTString, Long> arbitratorTable = null; // Table of arbitrators
        private Map<IoTString, NewKey> newKeyTable = null; // Table of speculative KV
-       // private Set<Abort> arbitratorTable = null; // Table of arbitrators
        private Map<Long, Commit> newCommitMap = null; // Map of all the new commits
        private Map<Long, Long> lastCommitSeenSeqNumMap = null; // sequence number of the last commit that was seen grouped by arbitrator
        private Map<Long, Long> lastAbortSeenSeqNumMap = null; // sequence number of the last commit that was seen grouped by arbitrator
@@ -110,44 +109,44 @@ final public class Table {
        }
 
        // TODO: delete method
-       public void printSlots() {
-               long o = buffer.getOldestSeqNum();
-               long n = buffer.getNewestSeqNum();
-
-               int[] types = new int[10];
-
-               int num = 0;
-
-               int livec = 0;
-               int deadc = 0;
-               for (long i = o; i < (n + 1); i++) {
-                       Slot s = buffer.getSlot(i);
-
-                       Vector<Entry> entries = s.getEntries();
-
-                       for (Entry e : entries) {
-                               if (e.isLive()) {
-                                       int type = e.getType();
-                                       types[type] = types[type] + 1;
-                                       num++;
-                                       livec++;
-                               } else {
-                                       deadc++;
-                               }
-                       }
-               }
-
-               for (int i = 0; i < 10; i++) {
-                       System.out.println(i + "    " + types[i]);
-               }
-               System.out.println("Live count:   " + livec);
-               System.out.println("Dead count:   " + deadc);
-               System.out.println("Old:   " + o);
-               System.out.println("New:   " + n);
-               System.out.println("Size:   " + buffer.size());
-               System.out.println("Commits Map:   " + commitedTable.size());
-               System.out.println("Commits List:   " + commitMap.size());
-       }
+       // public void printSlots() {
+       //      long o = buffer.getOldestSeqNum();
+       //      long n = buffer.getNewestSeqNum();
+
+       //      int[] types = new int[10];
+
+       //      int num = 0;
+
+       //      int livec = 0;
+       //      int deadc = 0;
+       //      for (long i = o; i < (n + 1); i++) {
+       //              Slot s = buffer.getSlot(i);
+
+       //              Vector<Entry> entries = s.getEntries();
+
+       //              for (Entry e : entries) {
+       //                      if (e.isLive()) {
+       //                              int type = e.getType();
+       //                              types[type] = types[type] + 1;
+       //                              num++;
+       //                              livec++;
+       //                      } else {
+       //                              deadc++;
+       //                      }
+       //              }
+       //      }
+
+       //      for (int i = 0; i < 10; i++) {
+       //              System.out.println(i + "    " + types[i]);
+       //      }
+       //      System.out.println("Live count:   " + livec);
+       //      System.out.println("Dead count:   " + deadc);
+       //      System.out.println("Old:   " + o);
+       //      System.out.println("New:   " + n);
+       //      System.out.println("Size:   " + buffer.size());
+       //      System.out.println("Commits Map:   " + commitedTable.size());
+       //      System.out.println("Commits List:   " + commitMap.size());
+       // }
 
        public IoTString getCommitted(IoTString key) {
                KeyValue kv = commitedTable.get(key);
@@ -167,6 +166,10 @@ final public class Table {
                }
        }
 
+       public Long getArbitrator(IoTString key) {
+               return arbitratorTable.get(key);
+       }
+
        public void initTable() {
                cloud.setSalt();//Set the salt
                Slot s = new Slot(this, 1, localmachineid);
@@ -314,7 +317,6 @@ final public class Table {
                        }
 
                        if (tryput(keyName, machineId, false)) {
-
                                // If successfully inserted
                                return true;
                        }
@@ -323,7 +325,6 @@ final public class Table {
 
        public void decrementLiveCount() {
                liveslotcount--;
-               // System.out.println("Decrement Live Count");
        }
 
        private void setResizeThreshold() {
@@ -485,9 +486,6 @@ final public class Table {
                                } else if (seqn == firstiffull) { //if there's no space but the entry is about to fall off the queue
                                        if (!resize) {
                                                System.out.println("B"); //?
-
-                                               // TODO delete
-                                               System.out.println("==============================NEEEEDDDD RESIZING");
                                                return new ThreeTuple<Boolean, Boolean, Long>(true, seenliveslot, seqn);
                                        }
                                }
@@ -515,19 +513,8 @@ final public class Table {
                        KeyValue keyVal = (KeyValue)(ut.getkeyValueUpdateSet().toArray())[0];
                        // Check if this machine arbitrates for this transaction
                        if (arbitratorTable.get( keyVal.getKey() ) != localmachineid ) {
-
-                               // TODO delete
-                               // if (localmachineid == 351) {
-                               //      System.out.println("Mis match Machine: " + localmachineid + "   Key: " + keyVal.getKey().toString());
-                               // }
                                continue;
                        }
-                       // else {
-                       //      // TODO delete
-                       //      if (localmachineid == 351) {
-                       //              System.out.println("Full Match Machine: " + localmachineid + "   Key: " + keyVal.getKey().toString());
-                       //      }
-                       // }
 
                        // we did have something to arbitrate on
                        didNeedArbitration = true;
@@ -609,18 +596,7 @@ final public class Table {
                        inserted = false;
                }
 
-
-               // TODO remove Timers
-               // long startTime = System.currentTimeMillis();
-               /* update data structure */
                validateandupdate(array, true);
-               // long endTime = System.currentTimeMillis();
-
-               // long diff = endTime - startTime;
-               // if (diff >= 1) {
-               //      System.out.println("Time Taken: " + diff);
-               // }
-
                return inserted;
        }
 
index 7e791ff6205d59d1cb042b78722ffbef7cc4fb15..fcbc44dfe5a2a2aabeb91a6b3ee0bcd27544b540 100644 (file)
@@ -8,7 +8,7 @@ package iotcloud;
 
 public class Test {
 
-       public static final  int NUMBER_OF_TESTS = 10000;
+       public static final  int NUMBER_OF_TESTS = 1000;
 
        public static void main(String[] args) {
                if (args[0].equals("2")) {
@@ -17,45 +17,1105 @@ public class Test {
                        test3();
                } else if (args[0].equals("4")) {
                        test4();
+               } else if (args[0].equals("5")) {
+                       test5();
+               } else if (args[0].equals("6")) {
+                       test6();
+               } else if (args[0].equals("7")) {
+                       test7();
+               } else if (args[0].equals("8")) {
+                       test8();
+               } else if (args[0].equals("9")) {
+                       test9();
+               }
+       }
+
+       static void test9() {
+
+               // Setup the 2 clients
+               Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
+               t1.initTable();
+               Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
+               t2.update();
+
+
+               // Make the Keys
+               System.out.println("Setting up keys");
+               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
+                       String a = "a" + i;
+                       String b = "b" + i;
+                       String c = "c" + i;
+                       String d = "d" + i;
+                       IoTString ia = new IoTString(a);
+                       IoTString ib = new IoTString(b);
+                       IoTString ic = new IoTString(c);
+                       IoTString id = new IoTString(d);
+                       t1.createNewKey(ia, 321);
+                       t1.createNewKey(ib, 351);
+                       t2.createNewKey(ic, 321);
+                       t2.createNewKey(id, 351);
+               }
+
+               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
+                       String a = "a" + i;
+                       String b = "b" + i;
+                       String c = "c" + i;
+                       String d = "d" + i;
+                       IoTString ia = new IoTString(a);
+                       IoTString ib = new IoTString(b);
+                       IoTString ic = new IoTString(c);
+                       IoTString id = new IoTString(d);
+                       t1.createNewKey(ia, 1000);
+                       t1.createNewKey(ib, 1000);
+                       t2.createNewKey(ic, 1000);
+                       t2.createNewKey(id, 1000);
+               }
+
+               System.out.println("Updating Clients...");
+               t1.update();
+               t2.update();
+               t1.update();
+               t2.update();
+
+               boolean foundError = false;
+
+               System.out.println("Checking Key-Values...");
+               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
+
+                       String keyA = "a" + i;
+                       String keyB = "b" + i;
+                       String keyC = "c" + i;
+                       String keyD = "d" + i;
+
+                       IoTString iKeyA = new IoTString(keyA);
+                       IoTString iKeyB = new IoTString(keyB);
+                       IoTString iKeyC = new IoTString(keyC);
+                       IoTString iKeyD = new IoTString(keyD);
+
+
+                       Long testValA1 = t1.getArbitrator(iKeyA);
+                       Long testValB1 = t1.getArbitrator(iKeyB);
+                       Long testValC1 = t1.getArbitrator(iKeyC);
+                       Long testValD1 = t1.getArbitrator(iKeyD);
+
+                       Long testValA2 = t2.getArbitrator(iKeyA);
+                       Long testValB2 = t2.getArbitrator(iKeyB);
+                       Long testValC2 = t2.getArbitrator(iKeyC);
+                       Long testValD2 = t2.getArbitrator(iKeyD);
+
+                       if ((testValA1 == null) || (testValA1 != 321)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyA + "    " + testValA1);
+                               foundError = true;
+                       }
+
+                       if ((testValB1 == null) || (testValB1 != 351)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyB + "    " + testValB1);
+                               foundError = true;
+                       }
+
+                       if ((testValC1 == null) || (testValC1 != 321)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyC + "    " + testValC1);
+                               foundError = true;
+                       }
+
+                       if ((testValD1 == null) || (testValD1 != 351)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyD + "    " + testValD1);
+                               foundError = true;
+                       }
+
+                       if ((testValA2 == null) || (testValA2 != 321)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyA + "    " + testValA2);
+                               foundError = true;
+                       }
+
+                       if ((testValB2 == null) || (testValB2 != 351)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyB + "    " + testValB2);
+                               foundError = true;
+                       }
+
+                       if ((testValC2 == null) || (testValC2 != 321)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyC + "    " + testValC2);
+                               foundError = true;
+                       }
+
+                       if ((testValD2 == null) || (testValD2 != 351)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyD + "    " + testValD2);
+                               foundError = true;
+                       }
+               }
+
+               if (foundError) {
+                       System.out.println("Found Errors...");
+               } else {
+                       System.out.println("No Errors Found...");
+               }
+       }
+
+       static void test8() {
+
+               boolean foundError = false;
+
+               // Setup the 2 clients
+               Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
+               t1.initTable();
+               Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
+               t2.update();
+
+               // t1.rebuild();
+               // t2.rebuild();
+
+               // Make the Keys
+               System.out.println("Setting up keys");
+               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
+                       String a = "a" + i;
+                       String b = "b" + i;
+                       String c = "c" + i;
+                       String d = "d" + i;
+                       IoTString ia = new IoTString(a);
+                       IoTString ib = new IoTString(b);
+                       IoTString ic = new IoTString(c);
+                       IoTString id = new IoTString(d);
+                       t1.createNewKey(ia, 321);
+                       t1.createNewKey(ib, 351);
+                       t2.createNewKey(ic, 321);
+                       t2.createNewKey(id, 351);
+               }
+
+
+               // Do Updates for the keys
+               System.out.println("Setting Key-Values...");
+
+
+               String keyA0 = "a0";
+               String keyB0 = "b0";
+               String keyC0 = "c0";
+               String keyD0 = "d0";
+               String valueA0 = "a0";
+               String valueB0 = "b0";
+               String valueC0 = "c0";
+               String valueD0 = "d0";
+
+               IoTString iKeyA0 = new IoTString(keyA0);
+               IoTString iKeyB0 = new IoTString(keyB0);
+               IoTString iKeyC0 = new IoTString(keyC0);
+               IoTString iKeyD0 = new IoTString(keyD0);
+               IoTString iValueA0 = new IoTString(valueA0);
+               IoTString iValueB0 = new IoTString(valueB0);
+               IoTString iValueC0 = new IoTString(valueC0);
+               IoTString iValueD0 = new IoTString(valueD0);
+
+               t1.startTransaction();
+               t1.addKV( iKeyA0, iValueA0);
+               t1.commitTransaction();
+
+               t1.startTransaction();
+               t1.addKV(iKeyB0, iValueB0);
+               t1.commitTransaction();
+
+               t2.startTransaction();
+               t2.addKV(iKeyC0, iValueC0);
+               t2.commitTransaction();
+
+               t2.startTransaction();
+               t2.addKV(iKeyD0, iValueD0);
+               t2.commitTransaction();
+
+               for (int i = 1; i < NUMBER_OF_TESTS; i++) {
+                       String keyB = "b" + i;
+                       String valueB = "b" + i;
+                       IoTString iKeyB = new IoTString(keyB);
+                       IoTString iValueB = new IoTString(valueB);
+
+                       String keyBOld = "b" + (i - 1);
+                       String valueBOld = "b" + (i - 1);
+                       IoTString iKeyBOld = new IoTString(keyBOld);
+                       IoTString iValueBOld = new IoTString(valueBOld);
+
+
+                       t1.startTransaction();
+                       t1.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyBOld, iValueBOld, Guard.Equal))));
+                       t1.addKV(iKeyB, iValueB);
+                       t1.commitTransaction();
+               }
+
+               System.out.println("Checking Key-Values...");
+               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
+
+                       String keyB = "b" + i;
+                       String valueB = "b" + i;
+
+                       IoTString iKeyB = new IoTString(keyB);
+                       IoTString iValueB = new IoTString(valueB);
+
+                       IoTString testValB1 = t1.getSpeculative(iKeyB);
+
+                       if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyB);
+                               foundError = true;
+
+                       }
+               }
+
+
+               System.out.println("Updating Clients...");
+               t1.update();
+               t2.update();
+               t1.update();
+               t2.update();
+
+               System.out.println("Checking Key-Values...");
+               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
+
+                       String keyA = "a" + i;
+                       String keyB = "b" + i;
+                       String keyC = "c" + i;
+                       String keyD = "d" + i;
+                       String valueA = "a" + i;
+                       String valueB = "b" + i;
+                       String valueC = "c" + i;
+                       String valueD = "d" + i;
+
+                       IoTString iKeyA = new IoTString(keyA);
+                       IoTString iKeyB = new IoTString(keyB);
+                       IoTString iKeyC = new IoTString(keyC);
+                       IoTString iKeyD = new IoTString(keyD);
+                       IoTString iValueA = new IoTString(valueA);
+                       IoTString iValueB = new IoTString(valueB);
+                       IoTString iValueC = new IoTString(valueC);
+                       IoTString iValueD = new IoTString(valueD);
+
+
+                       IoTString testValA1 = t1.getCommitted(iKeyA);
+                       IoTString testValB1 = t1.getCommitted(iKeyB);
+                       IoTString testValC1 = t1.getCommitted(iKeyC);
+                       IoTString testValD1 = t1.getCommitted(iKeyD);
+
+                       IoTString testValA2 = t2.getCommitted(iKeyA);
+                       IoTString testValB2 = t2.getCommitted(iKeyB);
+                       IoTString testValC2 = t2.getCommitted(iKeyC);
+                       IoTString testValD2 = t2.getCommitted(iKeyD);
+
+
+                       if (i == 0) {
+                               if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
+                                       System.out.println("Key-Value t1 incorrect: " + keyA);
+                                       foundError = true;
+                               }
+
+                               if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
+                                       System.out.println("Key-Value t1 incorrect: " + keyB);
+                                       foundError = true;
+                               }
+
+                               if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
+                                       System.out.println("Key-Value t1 incorrect: " + keyC);
+                                       foundError = true;
+                               }
+
+                               if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
+                                       System.out.println("Key-Value t1 incorrect: " + keyD);
+                                       foundError = true;
+                               }
+
+
+                               if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
+                                       System.out.println("Key-Value t2 incorrect: " + keyA + "    " + testValA2);
+                                       foundError = true;
+                               }
+
+                               if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
+                                       System.out.println("Key-Value t2 incorrect: " + keyB + "    " + testValB2);
+                                       foundError = true;
+                               }
+
+                               if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
+                                       System.out.println("Key-Value t2 incorrect: " + keyC + "    " + testValC2);
+                                       foundError = true;
+                               }
+
+                               if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
+                                       System.out.println("Key-Value t2 incorrect: " + keyD + "    " + testValD2);
+                                       foundError = true;
+                               }
+                       } else {
+                               if (testValA1 != null) {
+                                       System.out.println("Key-Value t1 incorrect: " + keyA);
+                                       foundError = true;
+                               }
+
+                               if (testValB1 != null) {
+                                       System.out.println("Key-Value t1 incorrect: " + keyB);
+                                       foundError = true;
+                               }
+
+                               if (testValC1 != null) {
+                                       System.out.println("Key-Value t1 incorrect: " + keyC);
+                                       foundError = true;
+                               }
+
+                               if (testValD1 != null) {
+                                       System.out.println("Key-Value t1 incorrect: " + keyD);
+                                       foundError = true;
+                               }
+
+                               if (testValA2 != null) {
+                                       System.out.println("Key-Value t2 incorrect: " + keyA + "    " + testValA2);
+                                       foundError = true;
+                               }
+
+                               if (testValB2 != null) {
+                                       System.out.println("Key-Value t2 incorrect: " + keyB + "    " + testValB2);
+                                       foundError = true;
+                               }
+
+                               if (testValC2 != null) {
+                                       System.out.println("Key-Value t2 incorrect: " + keyC + "    " + testValC2);
+                                       foundError = true;
+                               }
+
+                               if (testValD2 != null) {
+                                       System.out.println("Key-Value t2 incorrect: " + keyD + "    " + testValD2);
+                                       foundError = true;
+                               }
+                       }
+               }
+
+               if (foundError) {
+                       System.out.println("Found Errors...");
+               } else {
+                       System.out.println("No Errors Found...");
+               }
+       }
+
+       static void test7() {
+
+               long startTime = 0;
+               long endTime = 0;
+
+               // Setup the 2 clients
+               Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
+               t1.initTable();
+               Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
+               t2.update();
+
+               // t1.rebuild();
+               // t2.rebuild();
+
+               // Make the Keys
+               System.out.println("Setting up keys");
+               startTime = System.currentTimeMillis();
+               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
+                       String a = "a" + i;
+                       String b = "b" + i;
+                       String c = "c" + i;
+                       String d = "d" + i;
+                       IoTString ia = new IoTString(a);
+                       IoTString ib = new IoTString(b);
+                       IoTString ic = new IoTString(c);
+                       IoTString id = new IoTString(d);
+                       t1.createNewKey(ia, 321);
+                       t1.createNewKey(ib, 351);
+                       t2.createNewKey(ic, 321);
+                       t2.createNewKey(id, 351);
+               }
+               endTime = System.currentTimeMillis();
+
+               System.out.println("Time Taken: " + (double)   ((endTime - startTime) / 1000.0)    );
+               System.out.println("Time Taken Per Key: " + (double)  (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4))   );
+               System.out.println();
+
+
+               // Do Updates for the keys
+               System.out.println("Setting Key-Values...");
+               startTime = System.currentTimeMillis();
+
+
+
+               String keyA0 = "a0";
+               String keyB0 = "b0";
+               String keyC0 = "c0";
+               String keyD0 = "d0";
+               String valueA0 = "a0";
+               String valueB0 = "b0";
+               String valueC0 = "c0";
+               String valueD0 = "d0";
+
+               IoTString iKeyA0 = new IoTString(keyA0);
+               IoTString iKeyB0 = new IoTString(keyB0);
+               IoTString iKeyC0 = new IoTString(keyC0);
+               IoTString iKeyD0 = new IoTString(keyD0);
+               IoTString iValueA0 = new IoTString(valueA0);
+               IoTString iValueB0 = new IoTString(valueB0);
+               IoTString iValueC0 = new IoTString(valueC0);
+               IoTString iValueD0 = new IoTString(valueD0);
+
+               t1.startTransaction();
+               t1.addKV( iKeyA0, iValueA0);
+               t1.commitTransaction();
+
+               t1.startTransaction();
+               t1.addKV(iKeyB0, iValueB0);
+               t1.commitTransaction();
+
+               t2.startTransaction();
+               t2.addKV(iKeyC0, iValueC0);
+               t2.commitTransaction();
+
+               t2.startTransaction();
+               t2.addKV(iKeyD0, iValueD0);
+               t2.commitTransaction();
+
+               for (int i = 1; i < NUMBER_OF_TESTS; i++) {
+                       String keyB = "b" + i;
+                       String valueB = "b" + i;
+                       IoTString iKeyB = new IoTString(keyB);
+                       IoTString iValueB = new IoTString(valueB);
+
+                       String keyBOld = "b" + (i - 1);
+                       String valueBOld = "b" + (i - 2);
+                       IoTString iKeyBOld = new IoTString(keyBOld);
+                       IoTString iValueBOld = new IoTString(valueBOld);
+
+
+                       t1.startTransaction();
+                       t1.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyBOld, iValueBOld, Guard.Equal))));
+                       t1.addKV(iKeyB, iValueB);
+                       t1.commitTransaction();
+               }
+
+               for (int i = 1; i < NUMBER_OF_TESTS; i++) {
+                       String keyC = "c" + i;
+                       String valueC = "c" + i;
+                       IoTString iKeyC = new IoTString(keyC);
+                       IoTString iValueC = new IoTString(valueC);
+
+                       String keyCOld = "c" + (i - 1);
+                       String valueCOld = "c" + (i - 2);
+                       IoTString iKeyCOld = new IoTString(keyCOld);
+                       IoTString iValueCOld = new IoTString(valueCOld);
+
+
+                       t2.startTransaction();
+                       t2.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyCOld, iValueCOld, Guard.Equal))));
+                       t2.addKV(iKeyC, iValueC);
+                       t2.commitTransaction();
+               }
+
+               for (int i = 1; i < NUMBER_OF_TESTS; i++) {
+                       String keyA = "a" + i;
+                       String keyD = "d" + i;
+                       String valueA = "a" + i;
+                       String valueD = "d" + i;
+
+                       IoTString iKeyA = new IoTString(keyA);
+                       IoTString iKeyD = new IoTString(keyD);
+                       IoTString iValueA = new IoTString(valueA);
+                       IoTString iValueD = new IoTString(valueD);
+
+
+                       String keyAOld = "a" + (i - 1);
+                       String keyDOld = "d" + (i - 1);
+                       String valueAOld = "a" + (i - 2);
+                       String valueDOld = "d" + (i - 2);
+                       IoTString iKeyAOld = new IoTString(keyAOld);
+                       IoTString iKeyDOld = new IoTString(keyDOld);
+                       IoTString iValueAOld = new IoTString(valueAOld);
+                       IoTString iValueDOld = new IoTString(valueDOld);
+
+
+                       t1.startTransaction();
+                       t1.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyAOld, iValueAOld, Guard.Equal))));
+                       t1.addKV(iKeyA, iValueA);
+                       t1.commitTransaction();
+
+                       t2.startTransaction();
+                       t2.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyDOld, iValueDOld, Guard.Equal))));
+                       t2.addKV(iKeyD, iValueD);
+                       t2.commitTransaction();
+               }
+
+               endTime = System.currentTimeMillis();
+
+               System.out.println("Time Taken: " + (double)   ((endTime - startTime) / 1000.0)    );
+               System.out.println("Time Taken Per Update: " + (double)  (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4))   );
+               System.out.println();
+
+
+               System.out.println("Updating Clients...");
+               t1.update();
+               t2.update();
+               t1.update();
+               t2.update();
+
+               boolean foundError = false;
+
+               System.out.println("Checking Key-Values...");
+               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
+
+                       String keyA = "a" + i;
+                       String keyB = "b" + i;
+                       String keyC = "c" + i;
+                       String keyD = "d" + i;
+                       String valueA = "a" + i;
+                       String valueB = "b" + i;
+                       String valueC = "c" + i;
+                       String valueD = "d" + i;
+
+                       IoTString iKeyA = new IoTString(keyA);
+                       IoTString iKeyB = new IoTString(keyB);
+                       IoTString iKeyC = new IoTString(keyC);
+                       IoTString iKeyD = new IoTString(keyD);
+                       IoTString iValueA = new IoTString(valueA);
+                       IoTString iValueB = new IoTString(valueB);
+                       IoTString iValueC = new IoTString(valueC);
+                       IoTString iValueD = new IoTString(valueD);
+
+
+                       IoTString testValA1 = t1.getCommitted(iKeyA);
+                       IoTString testValB1 = t1.getCommitted(iKeyB);
+                       IoTString testValC1 = t1.getCommitted(iKeyC);
+                       IoTString testValD1 = t1.getCommitted(iKeyD);
+
+                       IoTString testValA2 = t2.getCommitted(iKeyA);
+                       IoTString testValB2 = t2.getCommitted(iKeyB);
+                       IoTString testValC2 = t2.getCommitted(iKeyC);
+                       IoTString testValD2 = t2.getCommitted(iKeyD);
+
+
+                       if (i == 0) {
+                               if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
+                                       System.out.println("Key-Value t1 incorrect: " + keyA);
+                                       foundError = true;
+                               }
+
+                               if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
+                                       System.out.println("Key-Value t1 incorrect: " + keyB);
+                                       foundError = true;
+                               }
+
+                               if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
+                                       System.out.println("Key-Value t1 incorrect: " + keyC);
+                                       foundError = true;
+                               }
+
+                               if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
+                                       System.out.println("Key-Value t1 incorrect: " + keyD);
+                                       foundError = true;
+                               }
+
+
+                               if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
+                                       System.out.println("Key-Value t2 incorrect: " + keyA + "    " + testValA2);
+                                       foundError = true;
+                               }
+
+                               if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
+                                       System.out.println("Key-Value t2 incorrect: " + keyB + "    " + testValB2);
+                                       foundError = true;
+                               }
+
+                               if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
+                                       System.out.println("Key-Value t2 incorrect: " + keyC + "    " + testValC2);
+                                       foundError = true;
+                               }
+
+                               if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
+                                       System.out.println("Key-Value t2 incorrect: " + keyD + "    " + testValD2);
+                                       foundError = true;
+                               }
+                       } else {
+                               if (testValA1 != null) {
+                                       System.out.println("Key-Value t1 incorrect: " + keyA);
+                                       foundError = true;
+                               }
+
+                               if (testValB1 != null) {
+                                       System.out.println("Key-Value t1 incorrect: " + keyB);
+                                       foundError = true;
+                               }
+
+                               if (testValC1 != null) {
+                                       System.out.println("Key-Value t1 incorrect: " + keyC);
+                                       foundError = true;
+                               }
+
+                               if (testValD1 != null) {
+                                       System.out.println("Key-Value t1 incorrect: " + keyD);
+                                       foundError = true;
+                               }
+
+                               if (testValA2 != null) {
+                                       System.out.println("Key-Value t2 incorrect: " + keyA + "    " + testValA2);
+                                       foundError = true;
+                               }
+
+                               if (testValB2 != null) {
+                                       System.out.println("Key-Value t2 incorrect: " + keyB + "    " + testValB2);
+                                       foundError = true;
+                               }
+
+                               if (testValC2 != null) {
+                                       System.out.println("Key-Value t2 incorrect: " + keyC + "    " + testValC2);
+                                       foundError = true;
+                               }
+
+                               if (testValD2 != null) {
+                                       System.out.println("Key-Value t2 incorrect: " + keyD + "    " + testValD2);
+                                       foundError = true;
+                               }
+                       }
+               }
+
+               if (foundError) {
+                       System.out.println("Found Errors...");
+               } else {
+                       System.out.println("No Errors Found...");
+               }
+       }
+
+       static void test6() {
+
+               long startTime = 0;
+               long endTime = 0;
+
+               // Setup the 2 clients
+               Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
+               t1.initTable();
+               Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
+               t2.update();
+
+               // t1.rebuild();
+               // t2.rebuild();
+
+               // Make the Keys
+               System.out.println("Setting up keys");
+               startTime = System.currentTimeMillis();
+               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
+                       String a = "a" + i;
+                       String b = "b" + i;
+                       String c = "c" + i;
+                       String d = "d" + i;
+                       IoTString ia = new IoTString(a);
+                       IoTString ib = new IoTString(b);
+                       IoTString ic = new IoTString(c);
+                       IoTString id = new IoTString(d);
+                       t1.createNewKey(ia, 321);
+                       t1.createNewKey(ib, 351);
+                       t2.createNewKey(ic, 321);
+                       t2.createNewKey(id, 351);
+               }
+               endTime = System.currentTimeMillis();
+
+               System.out.println("Time Taken: " + (double)   ((endTime - startTime) / 1000.0)    );
+               System.out.println("Time Taken Per Key: " + (double)  (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4))   );
+               System.out.println();
+
+
+               // Do Updates for the keys
+               System.out.println("Setting Key-Values...");
+               startTime = System.currentTimeMillis();
+
+
+               t1.startTransaction();
+               t1.addKV( new IoTString("a0"), new IoTString("a0"));
+               t1.commitTransaction();
+
+               t1.startTransaction();
+               t1.addKV(new IoTString("b0"), new IoTString("b0"));
+               t1.commitTransaction();
+
+               t2.startTransaction();
+               t2.addKV(new IoTString("c0"), new IoTString("c0"));
+               t2.commitTransaction();
+
+               t2.startTransaction();
+               t2.addKV(new IoTString("d0"), new IoTString("d0"));
+               t2.commitTransaction();
+
+               for (int i = 1; i < NUMBER_OF_TESTS; i++) {
+                       String keyB = "b" + i;
+                       String valueB = "b" + i;
+                       IoTString iKeyB = new IoTString(keyB);
+                       IoTString iValueB = new IoTString(valueB);
+
+                       String keyBOld = "b" + (i - 1);
+                       String valueBOld = "b" + (i - 1);
+                       IoTString iKeyBOld = new IoTString(keyBOld);
+                       IoTString iValueBOld = new IoTString(valueBOld);
+
+
+                       t1.startTransaction();
+                       t1.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyBOld, iValueBOld, Guard.Equal))));
+                       t1.addKV(iKeyB, iValueB);
+                       t1.commitTransaction();
+               }
+
+               for (int i = 1; i < NUMBER_OF_TESTS; i++) {
+                       String keyC = "c" + i;
+                       String valueC = "c" + i;
+                       IoTString iKeyC = new IoTString(keyC);
+                       IoTString iValueC = new IoTString(valueC);
+
+                       String keyCOld = "c" + (i - 1);
+                       String valueCOld = "c" + (i - 1);
+                       IoTString iKeyCOld = new IoTString(keyCOld);
+                       IoTString iValueCOld = new IoTString(valueCOld);
+
+
+                       t2.startTransaction();
+                       t2.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyCOld, iValueCOld, Guard.Equal))));
+                       t2.addKV(iKeyC, iValueC);
+                       t2.commitTransaction();
+               }
+
+               for (int i = 1; i < NUMBER_OF_TESTS; i++) {
+                       String keyA = "a" + i;
+                       String keyD = "d" + i;
+                       String valueA = "a" + i;
+                       String valueD = "d" + i;
+
+                       IoTString iKeyA = new IoTString(keyA);
+                       IoTString iKeyD = new IoTString(keyD);
+                       IoTString iValueA = new IoTString(valueA);
+                       IoTString iValueD = new IoTString(valueD);
+
+
+                       String keyAOld = "a" + (i - 1);
+                       String keyDOld = "d" + (i - 1);
+                       String valueAOld = "a" + (i - 1);
+                       String valueDOld = "d" + (i - 1);
+                       IoTString iKeyAOld = new IoTString(keyAOld);
+                       IoTString iKeyDOld = new IoTString(keyDOld);
+                       IoTString iValueAOld = new IoTString(valueAOld);
+                       IoTString iValueDOld = new IoTString(valueDOld);
+
+
+                       t1.startTransaction();
+                       t1.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyAOld, iValueAOld, Guard.Equal))));
+                       t1.addKV(iKeyA, iValueA);
+                       t1.commitTransaction();
+
+                       t2.startTransaction();
+                       t2.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyDOld, iValueDOld, Guard.Equal))));
+                       t2.addKV(iKeyD, iValueD);
+                       t2.commitTransaction();
+               }
+
+               endTime = System.currentTimeMillis();
+
+               System.out.println("Time Taken: " + (double)   ((endTime - startTime) / 1000.0)    );
+               System.out.println("Time Taken Per Update: " + (double)  (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4))   );
+               System.out.println();
+
+
+               System.out.println("Updating Clients...");
+               t1.update();
+               t2.update();
+               t1.update();
+               t2.update();
+
+               boolean foundError = false;
+
+               System.out.println("Checking Key-Values...");
+               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
+
+                       String keyA = "a" + i;
+                       String keyB = "b" + i;
+                       String keyC = "c" + i;
+                       String keyD = "d" + i;
+                       String valueA = "a" + i;
+                       String valueB = "b" + i;
+                       String valueC = "c" + i;
+                       String valueD = "d" + i;
+
+                       IoTString iKeyA = new IoTString(keyA);
+                       IoTString iKeyB = new IoTString(keyB);
+                       IoTString iKeyC = new IoTString(keyC);
+                       IoTString iKeyD = new IoTString(keyD);
+                       IoTString iValueA = new IoTString(valueA);
+                       IoTString iValueB = new IoTString(valueB);
+                       IoTString iValueC = new IoTString(valueC);
+                       IoTString iValueD = new IoTString(valueD);
+
+
+                       IoTString testValA1 = t1.getCommitted(iKeyA);
+                       IoTString testValB1 = t1.getCommitted(iKeyB);
+                       IoTString testValC1 = t1.getCommitted(iKeyC);
+                       IoTString testValD1 = t1.getCommitted(iKeyD);
+
+                       IoTString testValA2 = t2.getCommitted(iKeyA);
+                       IoTString testValB2 = t2.getCommitted(iKeyB);
+                       IoTString testValC2 = t2.getCommitted(iKeyC);
+                       IoTString testValD2 = t2.getCommitted(iKeyD);
+
+                       if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyA);
+                               foundError = true;
+                       }
+
+                       if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyB);
+                               foundError = true;
+                       }
+
+                       if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyC);
+                               foundError = true;
+                       }
+
+                       if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyD);
+                               foundError = true;
+                       }
+
+
+                       if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyA + "    " + testValA2);
+                               foundError = true;
+                       }
+
+                       if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyB + "    " + testValB2);
+                               foundError = true;
+                       }
+
+                       if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyC + "    " + testValC2);
+                               foundError = true;
+                       }
+
+                       if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyD + "    " + testValD2);
+                               foundError = true;
+                       }
+               }
+
+               if (foundError) {
+                       System.out.println("Found Errors...");
+               } else {
+                       System.out.println("No Errors Found...");
                }
        }
 
        static void test5() {
+
+               long startTime = 0;
+               long endTime = 0;
+
+               // Setup the 2 clients
                Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
-               t1.rebuild();
-               System.out.println(t1);
-
-               // // Print the results
-               // for (int i = 0; i < NUMBER_OF_TESTS; i++) {
-               //      String a = "a" + i;
-               //      String b = "b" + i;
-               //      IoTString ia = new IoTString(a);
-               //      IoTString ib = new IoTString(b);
-
-               //      System.out.println(ib + " -> " + t1.getCommitted(ib));
-               //      System.out.println(ia + " -> " + t2.getCommitted(ia));
-               //      System.out.println();
-               // }
-       }
+               t1.initTable();
+               Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
+               t2.update();
+
+               // t1.rebuild();
+               // t2.rebuild();
+
+
+
+               // Make the Keys
+               System.out.println("Setting up keys");
+               startTime = System.currentTimeMillis();
+               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
+                       String a = "a" + i;
+                       String b = "b" + i;
+                       String c = "c" + i;
+                       String d = "d" + i;
+                       IoTString ia = new IoTString(a);
+                       IoTString ib = new IoTString(b);
+                       IoTString ic = new IoTString(c);
+                       IoTString id = new IoTString(d);
+                       t1.createNewKey(ia, 321);
+                       t1.createNewKey(ib, 351);
+                       t2.createNewKey(ic, 321);
+                       t2.createNewKey(id, 351);
+               }
+               endTime = System.currentTimeMillis();
+
+
+
+               System.out.println("Time Taken: " + (double)   ((endTime - startTime) / 1000.0)    );
+               System.out.println("Time Taken Per Key: " + (double)  (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4))   );
+               System.out.println();
+
+
+               // Do Updates for the keys
+               System.out.println("Setting Key-Values...");
+               startTime = System.currentTimeMillis();
+               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
+                       String keyA = "a" + i;
+                       String keyB = "b" + i;
+                       String keyC = "c" + i;
+                       String keyD = "d" + i;
+                       String valueA = "a" + i;
+                       String valueB = "b" + i;
+                       String valueC = "c" + i;
+                       String valueD = "d" + i;
+
+                       IoTString iKeyA = new IoTString(keyA);
+                       IoTString iKeyB = new IoTString(keyB);
+                       IoTString iKeyC = new IoTString(keyC);
+                       IoTString iKeyD = new IoTString(keyD);
+                       IoTString iValueA = new IoTString(valueA);
+                       IoTString iValueB = new IoTString(valueB);
+                       IoTString iValueC = new IoTString(valueC);
+                       IoTString iValueD = new IoTString(valueD);
+
+
+
+                       if (i != 0) {
+                               String keyAOld = "a" + (i - 1);
+                               String keyBOld = "b" + (i - 1);
+                               String keyCOld = "c" + (i - 1);
+                               String keyDOld = "d" + (i - 1);
+                               String valueAOld = "a" + (i - 1);
+                               String valueBOld = "b" + (i - 1);
+                               String valueCOld = "c" + (i - 1);
+                               String valueDOld = "d" + (i - 1);
+
+                               IoTString iKeyAOld = new IoTString(keyAOld);
+                               IoTString iKeyBOld = new IoTString(keyBOld);
+                               IoTString iKeyCOld = new IoTString(keyCOld);
+                               IoTString iKeyDOld = new IoTString(keyDOld);
+                               IoTString iValueAOld = new IoTString(valueAOld);
+                               IoTString iValueBOld = new IoTString(valueBOld);
+                               IoTString iValueCOld = new IoTString(valueCOld);
+                               IoTString iValueDOld = new IoTString(valueDOld);
+
+                               t1.startTransaction();
+                               t1.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyAOld, iValueAOld, Guard.Equal))));
+                               t1.addKV(iKeyA, iValueA);
+                               t1.commitTransaction();
+
+                               t1.startTransaction();
+                               t1.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyBOld, iValueBOld, Guard.Equal))));
+                               t1.addKV(iKeyB, iValueB);
+                               t1.commitTransaction();
+
+                               t2.startTransaction();
+                               t2.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyCOld, iValueCOld, Guard.Equal))));
+                               t2.addKV(iKeyC, iValueC);
+                               t2.commitTransaction();
+
+                               t2.startTransaction();
+                               t2.addGuard(new Guard(new IoTString(Guard.createExpression(iKeyDOld, iValueDOld, Guard.Equal))));
+                               t2.addKV(iKeyD, iValueD);
+                               t2.commitTransaction();
+
+
+                       } else {
+                               t1.startTransaction();
+                               t1.addKV(iKeyA, iValueA);
+                               t1.commitTransaction();
+
+                               t1.startTransaction();
+                               t1.addKV(iKeyB, iValueB);
+                               t1.commitTransaction();
+
+                               t2.startTransaction();
+                               t2.addKV(iKeyC, iValueC);
+                               t2.commitTransaction();
+
+                               t2.startTransaction();
+                               t2.addKV(iKeyD, iValueD);
+                               t2.commitTransaction();
+                       }
+               }
+               endTime = System.currentTimeMillis();
+
+               System.out.println("Time Taken: " + (double)   ((endTime - startTime) / 1000.0)    );
+               System.out.println("Time Taken Per Update: " + (double)  (((endTime - startTime) / 1000.0) / (NUMBER_OF_TESTS * 4))   );
+               System.out.println();
+
+
+               System.out.println("Updating Clients...");
+               t1.update();
+               t2.update();
+               t1.update();
+               t2.update();
+
+               boolean foundError = false;
+
+               System.out.println("Checking Key-Values...");
+               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
+
+                       String keyA = "a" + i;
+                       String keyB = "b" + i;
+                       String keyC = "c" + i;
+                       String keyD = "d" + i;
+                       String valueA = "a" + i;
+                       String valueB = "b" + i;
+                       String valueC = "c" + i;
+                       String valueD = "d" + i;
+
+                       IoTString iKeyA = new IoTString(keyA);
+                       IoTString iKeyB = new IoTString(keyB);
+                       IoTString iKeyC = new IoTString(keyC);
+                       IoTString iKeyD = new IoTString(keyD);
+                       IoTString iValueA = new IoTString(valueA);
+                       IoTString iValueB = new IoTString(valueB);
+                       IoTString iValueC = new IoTString(valueC);
+                       IoTString iValueD = new IoTString(valueD);
+
+
+                       IoTString testValA1 = t1.getCommitted(iKeyA);
+                       IoTString testValB1 = t1.getCommitted(iKeyB);
+                       IoTString testValC1 = t1.getCommitted(iKeyC);
+                       IoTString testValD1 = t1.getCommitted(iKeyD);
+
+                       IoTString testValA2 = t2.getCommitted(iKeyA);
+                       IoTString testValB2 = t2.getCommitted(iKeyB);
+                       IoTString testValC2 = t2.getCommitted(iKeyC);
+                       IoTString testValD2 = t2.getCommitted(iKeyD);
+
+                       if ((testValA1 == null) || (testValA1.equals(iValueA) == false)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyA);
+                               foundError = true;
+                       }
+
+                       if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyB);
+                               foundError = true;
+                       }
+
+                       if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyC);
+                               foundError = true;
+                       }
+
+                       if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyD);
+                               foundError = true;
+                       }
+
+
+                       if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyA + "    " + testValA2);
+                               foundError = true;
+                       }
+
+                       if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyB + "    " + testValB2);
+                               foundError = true;
+                       }
+
+                       if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyC + "    " + testValC2);
+                               foundError = true;
+                       }
+
+                       if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyD + "    " + testValD2);
+                               foundError = true;
+                       }
+               }
 
-       // static Thread buildThreadTest4(String prefix, Table t) {
-       //      return new Thread() {
-       //              public void run() {
-       //                      for (int i = 0; i < (NUMBER_OF_TESTS * 3); i++) {
-
-       //                              int num = i % NUMBER_OF_TESTS;
-       //                              String key = prefix + num;
-       //                              String value = prefix + (num + 2000);
-       //                              IoTString iKey = new IoTString(key);
-       //                              IoTString iValue = new IoTString(value);
-
-       //                              t.startTransaction();
-       //                              t.addKV(iKey, iValue);
-       //                              t.commitTransaction();
-       //                      }
-       //              }
-       //      };
-       // }
+               if (foundError) {
+                       System.out.println("Found Errors...");
+               } else {
+                       System.out.println("No Errors Found...");
+               }
+       }
 
        static void test4() {
 
@@ -229,14 +1289,6 @@ public class Test {
                } else {
                        System.out.println("No Errors Found...");
                }
-
-               System.out.println();
-               System.out.println();
-               System.out.println();
-               System.out.println();
-               t1.printSlots();
-               System.out.println();
-               t2.printSlots();
        }
 
        static void test3() {
@@ -323,11 +1375,6 @@ public class Test {
                        t2.addKV(iKeyD, iValueD);
                        t2.commitTransaction();
                }
-
-
-
-
-
                endTime = System.currentTimeMillis();
 
                System.out.println("Time Taken: " + (double)   ((endTime - startTime) / 1000.0)    );
@@ -422,14 +1469,6 @@ public class Test {
                } else {
                        System.out.println("No Errors Found...");
                }
-
-               System.out.println();
-               System.out.println();
-               System.out.println();
-               System.out.println();
-               t1.printSlots();
-               System.out.println();
-               t2.printSlots();
        }
 
        static void test2() {
@@ -606,13 +1645,5 @@ public class Test {
                } else {
                        System.out.println("No Errors Found...");
                }
-
-               System.out.println();
-               System.out.println();
-               System.out.println();
-               System.out.println();
-               t1.printSlots();
-               System.out.println();
-               t2.printSlots();
        }
 }