Fixing Bugs
authorAli Younis <ayounis@uci.edu>
Tue, 27 Dec 2016 09:18:45 +0000 (01:18 -0800)
committerAli Younis <ayounis@uci.edu>
Tue, 27 Dec 2016 09:18:45 +0000 (01:18 -0800)
version2/src/java/iotcloud/Abort.java
version2/src/java/iotcloud/Commit.java
version2/src/java/iotcloud/Guard.java
version2/src/java/iotcloud/PendingTransaction.java
version2/src/java/iotcloud/Table.java
version2/src/java/iotcloud/Test.java
version2/src/java/iotcloud/Transaction.java

index 4d0c59bde39d443e214d46522fc5c370109d02f2..f27c787d1a8b60d9861b58f52f6c10371600ffdf 100644 (file)
@@ -12,42 +12,52 @@ import java.nio.ByteBuffer;
 class Abort extends Entry {
        private long seqnumtrans;
        private long machineid;
 class Abort extends Entry {
        private long seqnumtrans;
        private long machineid;
+       private long transarbitrator;
 
 
-       Abort(Slot slot, long _seqnumtrans, long _machineid) {
+
+       public Abort(Slot slot, long _seqnumtrans, long _machineid, long _transarbitrator) {
                super(slot);
                super(slot);
-               seqnumtrans=_seqnumtrans;
-               machineid=_machineid;
+               seqnumtrans = _seqnumtrans;
+               machineid = _machineid;
+               transarbitrator = _transarbitrator;
        }
 
        }
 
-       long getMachineID() {
+       public long getMachineID() {
                return machineid;
        }
 
                return machineid;
        }
 
-       long getTransSequenceNumber() {
+       public long getTransSequenceNumber() {
                return seqnumtrans;
        }
 
                return seqnumtrans;
        }
 
+       public long getTransArbitrator() {
+               return transarbitrator;
+       }
+
+
        static Entry decode(Slot slot, ByteBuffer bb) {
        static Entry decode(Slot slot, ByteBuffer bb) {
-               long seqnumtrans=bb.getLong();
-               long machineid=bb.getLong();
-               return new Abort(slot, seqnumtrans, machineid);
+               long seqnumtrans = bb.getLong();
+               long machineid = bb.getLong();
+               long transarbitrator = bb.getLong();
+               return new Abort(slot, seqnumtrans, machineid, transarbitrator);
        }
 
        }
 
-       void encode(ByteBuffer bb) {
+       public void encode(ByteBuffer bb) {
                bb.put(Entry.TypeAbort);
                bb.putLong(seqnumtrans);
                bb.putLong(machineid);
                bb.put(Entry.TypeAbort);
                bb.putLong(seqnumtrans);
                bb.putLong(machineid);
+               bb.putLong(transarbitrator);
        }
 
        }
 
-       int getSize() {
-               return (2 * Long.BYTES) + Byte.BYTES;
+       public int getSize() {
+               return (3 * Long.BYTES) + Byte.BYTES;
        }
 
        }
 
-       byte getType() {
+       public byte getType() {
                return Entry.TypeAbort;
        }
 
                return Entry.TypeAbort;
        }
 
-       Entry getCopy(Slot s) {
-               return new Abort(s, seqnumtrans, machineid);
+       public Entry getCopy(Slot s) {
+               return new Abort(s, seqnumtrans, machineid, transarbitrator);
        }
 }
\ No newline at end of file
        }
 }
\ No newline at end of file
index 86650c98a203bc83dac3f504b99d7554f7957c5f..72249225b777c2ca4875b9df7d23cf0375a5b4ca 100644 (file)
@@ -14,12 +14,15 @@ import java.util.Iterator;
 
 class Commit extends Entry {
        private long seqnumtrans;
 
 class Commit extends Entry {
        private long seqnumtrans;
+       private long transarbitrator;
+
        private Set<KeyValue> keyValueUpdateSet = null;
 
 
        private Set<KeyValue> keyValueUpdateSet = null;
 
 
-       public Commit(Slot slot, long _seqnumtrans, Set<KeyValue> _keyValueUpdateSet) {
+       public Commit(Slot slot, long _seqnumtrans, long _transarbitrator, Set<KeyValue> _keyValueUpdateSet) {
                super(slot);
                seqnumtrans = _seqnumtrans;
                super(slot);
                seqnumtrans = _seqnumtrans;
+               transarbitrator = _transarbitrator;
 
                keyValueUpdateSet = new HashSet<KeyValue>();
 
 
                keyValueUpdateSet = new HashSet<KeyValue>();
 
@@ -33,6 +36,10 @@ class Commit extends Entry {
                return seqnumtrans;
        }
 
                return seqnumtrans;
        }
 
+       public long getTransArbitrator() {
+               return transarbitrator;
+       }
+
        public Set<KeyValue> getkeyValueUpdateSet() {
                return keyValueUpdateSet;
        }
        public Set<KeyValue> getkeyValueUpdateSet() {
                return keyValueUpdateSet;
        }
@@ -42,7 +49,7 @@ class Commit extends Entry {
        }
 
        public int getSize() {
        }
 
        public int getSize() {
-               int size = Long.BYTES + Byte.BYTES; // seq id, entry type
+               int size = 2 * Long.BYTES + Byte.BYTES; // seq id, entry type
                size += Integer.BYTES; // number of KV's
 
                // Size of each KV
                size += Integer.BYTES; // number of KV's
 
                // Size of each KV
@@ -55,6 +62,7 @@ class Commit extends Entry {
 
        static Entry decode(Slot slot, ByteBuffer bb) {
                long seqnumtrans = bb.getLong();
 
        static Entry decode(Slot slot, ByteBuffer bb) {
                long seqnumtrans = bb.getLong();
+               long transarbitrator = bb.getLong();
                int numberOfKeys = bb.getInt();
 
                Set<KeyValue> kvSet = new HashSet<KeyValue>();
                int numberOfKeys = bb.getInt();
 
                Set<KeyValue> kvSet = new HashSet<KeyValue>();
@@ -63,12 +71,14 @@ class Commit extends Entry {
                        kvSet.add(kv);
                }
 
                        kvSet.add(kv);
                }
 
-               return new Commit(slot, seqnumtrans, kvSet);
+               return new Commit(slot, seqnumtrans, transarbitrator, kvSet);
        }
 
        public void encode(ByteBuffer bb) {
                bb.put(Entry.TypeCommit);
                bb.putLong(seqnumtrans);
        }
 
        public void encode(ByteBuffer bb) {
                bb.put(Entry.TypeCommit);
                bb.putLong(seqnumtrans);
+               bb.putLong(transarbitrator);
+
                bb.putInt(keyValueUpdateSet.size());
 
                for (KeyValue kv : keyValueUpdateSet) {
                bb.putInt(keyValueUpdateSet.size());
 
                for (KeyValue kv : keyValueUpdateSet) {
@@ -78,13 +88,15 @@ class Commit extends Entry {
 
        public Entry getCopy(Slot s) {
                // System.out.println("Commit Rescued:  " + this);  // TODO remove
 
        public Entry getCopy(Slot s) {
                // System.out.println("Commit Rescued:  " + this);  // TODO remove
-               return new Commit(s, seqnumtrans, keyValueUpdateSet);
+               return new Commit(s, seqnumtrans, transarbitrator, keyValueUpdateSet);
        }
 
        }
 
-       public void updateLiveKeys(Set<KeyValue> kvSet) {
+       public Set<KeyValue> updateLiveKeys(Set<KeyValue> kvSet) {
 
                if (!this.isLive())
 
                if (!this.isLive())
-                       return;
+                       return new HashSet<KeyValue>();
+
+               Set<KeyValue> toDelete = new HashSet<KeyValue>();
 
                for (KeyValue kv1 : kvSet) {
                        for (Iterator<KeyValue> i = keyValueUpdateSet.iterator(); i.hasNext();) {
 
                for (KeyValue kv1 : kvSet) {
                        for (Iterator<KeyValue> i = keyValueUpdateSet.iterator(); i.hasNext();) {
@@ -92,6 +104,7 @@ class Commit extends Entry {
 
                                if (kv1.getKey().equals(kv2.getKey())) {
                                        // keyValueUpdateSet.remove(kv2);
 
                                if (kv1.getKey().equals(kv2.getKey())) {
                                        // keyValueUpdateSet.remove(kv2);
+                                       toDelete.add(kv2);
                                        i.remove();
                                        break;
                                }
                                        i.remove();
                                        break;
                                }
@@ -102,5 +115,7 @@ class Commit extends Entry {
                        // System.out.println("Killed Commit:  " + this); // TODO remove
                        this.setDead();
                }
                        // System.out.println("Killed Commit:  " + this); // TODO remove
                        this.setDead();
                }
+
+               return toDelete;
        }
 }
\ No newline at end of file
        }
 }
\ No newline at end of file
index c08ed28b68110a91cf8415e1c07c2a5b5a4613ab..4e426fd92ef831af45a6e49fdb8a760820778721 100644 (file)
@@ -2,6 +2,7 @@ package iotcloud;
 
 import java.util.Set;
 import java.util.HashSet;
 
 import java.util.Set;
 import java.util.HashSet;
+import java.util.Collection;
 import java.nio.ByteBuffer;
 
 import javax.script.ScriptEngine;
 import java.nio.ByteBuffer;
 
 import javax.script.ScriptEngine;
@@ -52,7 +53,7 @@ class Guard {
      * Evaluate the guard expression for a given set of key value pairs.
      *
      */
      * Evaluate the guard expression for a given set of key value pairs.
      *
      */
-    public boolean evaluate(Set<KeyValue> kvSet) throws ScriptException, NullPointerException {
+    public boolean evaluate(Collection<KeyValue> kvSet) throws ScriptException, NullPointerException {
 
         // There are no conditions to evaluate
         if (booleanExpression == null) {
 
         // There are no conditions to evaluate
         if (booleanExpression == null) {
index c3c41c553b4f80b06078c787f4fd2a7c994e1f6c..24c4ad7f1ece49363f28b697a964f6e4ce093683 100644 (file)
@@ -57,7 +57,9 @@ class PendingTransaction {
         return arb == arbitrator;
     }
 
         return arb == arbitrator;
     }
 
-
+    public long getArbitrator() {
+        return arbitrator;
+    }
 
     /**
      * Get the key value update set
 
     /**
      * Get the key value update set
index b0b4c1a7da1788e92154aab4d09071ded3178b38..99dc9bac945d02aea2dac5387eb8886542b73015 100644 (file)
@@ -47,14 +47,13 @@ final public class Table {
        public int resizethreshold;     // TODO:  MAKE PRIVATE
        private long lastliveslotseqn;  //smallest sequence number with a live entry
        private Random random = new Random();
        public int resizethreshold;     // TODO:  MAKE PRIVATE
        private long lastliveslotseqn;  //smallest sequence number with a live entry
        private Random random = new Random();
-       private long lastCommitSeenSeqNum = 0; // sequence number of the last commit that was seen
+       private long lastUncommittedTransaction = 0;
 
        private PendingTransaction pendingTransBuild = null; // Pending Transaction used in building
        private Queue<PendingTransaction> pendingTransQueue = null; // Queue of pending transactions
 
        private PendingTransaction pendingTransBuild = null; // Pending Transaction used in building
        private Queue<PendingTransaction> pendingTransQueue = null; // Queue of pending transactions
-       private List<Commit> commitList = null; // List of all the most recent live commits
-       private List<Long> commitListSeqNum = null; // List of all the most recent live commits trans sequence numbers
-
-       private Set<Abort> abortSet = null; // Set of the live aborts
+       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, KeyValue> speculativeTable = null; // Table of speculative KV
        public Map<Long, Transaction> uncommittedTransactionsMap = null; // TODO: make private
        public  Map<IoTString, KeyValue> commitedTable = null; // Table of committed KV       TODO: Make Private
        private Map<IoTString, KeyValue> speculativeTable = null; // Table of speculative KV
        public Map<Long, Transaction> uncommittedTransactionsMap = null; // TODO: make private
@@ -62,6 +61,8 @@ final public class Table {
        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<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
 
 
 
 
 
 
@@ -90,14 +91,17 @@ final public class Table {
 
        private void setupDataStructs() {
                pendingTransQueue = new LinkedList<PendingTransaction>();
 
        private void setupDataStructs() {
                pendingTransQueue = new LinkedList<PendingTransaction>();
-               commitList = new LinkedList<Commit>();
-               abortSet = new HashSet<Abort>();
+               commitMap = new HashMap<Long, Commit>();
+               abortMap = new HashMap<Long, Abort>();
+               committedMapByKey = new HashMap<IoTString, Commit>();
                commitedTable = new HashMap<IoTString, KeyValue>();
                speculativeTable = new HashMap<IoTString, KeyValue>();
                uncommittedTransactionsMap = new HashMap<Long, Transaction>();
                arbitratorTable = new HashMap<IoTString, Long>();
                newKeyTable = new HashMap<IoTString, NewKey>();
                commitedTable = new HashMap<IoTString, KeyValue>();
                speculativeTable = new HashMap<IoTString, KeyValue>();
                uncommittedTransactionsMap = new HashMap<Long, Transaction>();
                arbitratorTable = new HashMap<IoTString, Long>();
                newKeyTable = new HashMap<IoTString, NewKey>();
-               newCommitMap = new HashMap<Long, Commit> ();
+               newCommitMap = new HashMap<Long, Commit>();
+               lastCommitSeenSeqNumMap = new HashMap<Long, Long>();
+               lastAbortSeenSeqNumMap = new HashMap<Long, Long>();
        }
 
        public void rebuild() {
        }
 
        public void rebuild() {
@@ -142,7 +146,7 @@ final public class Table {
                System.out.println("New:   " + n);
                System.out.println("Size:   " + buffer.size());
                System.out.println("Commits Map:   " + commitedTable.size());
                System.out.println("New:   " + n);
                System.out.println("Size:   " + buffer.size());
                System.out.println("Commits Map:   " + commitedTable.size());
-               System.out.println("Commits List:   " + commitList.size());
+               System.out.println("Commits List:   " + commitMap.size());
        }
 
        public IoTString getCommitted(IoTString key) {
        }
 
        public IoTString getCommitted(IoTString key) {
@@ -333,23 +337,16 @@ final public class Table {
                int newsize = 0;
                if (liveslotcount > resizethreshold) {
                        resize = true; //Resize is forced
                int newsize = 0;
                if (liveslotcount > resizethreshold) {
                        resize = true; //Resize is forced
-                       System.out.println("Live count resize: " + liveslotcount + "   " + resizethreshold);
-
                }
 
                if (resize) {
                        newsize = (int) (numslots * RESIZE_MULTIPLE);
                }
 
                if (resize) {
                        newsize = (int) (numslots * RESIZE_MULTIPLE);
-
-                       System.out.println("New Size:  " + newsize + "  old: " + buffer.oldestseqn); // TODO remove
-
                        TableStatus status = new TableStatus(s, newsize);
                        s.addEntry(status);
                }
 
                doRejectedMessages(s);
 
                        TableStatus status = new TableStatus(s, newsize);
                        s.addEntry(status);
                }
 
                doRejectedMessages(s);
 
-
-
                ThreeTuple<Boolean, Boolean, Long> retTup = doMandatoryResuce(s, resize);
 
                // Resize was needed so redo call
                ThreeTuple<Boolean, Boolean, Long> retTup = doMandatoryResuce(s, resize);
 
                // Resize was needed so redo call
@@ -361,11 +358,13 @@ final public class Table {
                boolean seenliveslot = retTup.getSecond();
                long seqn = retTup.getThird();
 
                boolean seenliveslot = retTup.getSecond();
                long seqn = retTup.getThird();
 
+
                doArbitration(s);
 
                Transaction trans = new Transaction(s,
                                                    s.getSequenceNumber(),
                                                    localmachineid,
                doArbitration(s);
 
                Transaction trans = new Transaction(s,
                                                    s.getSequenceNumber(),
                                                    localmachineid,
+                                                   pendingTrans.getArbitrator(),
                                                    pendingTrans.getKVUpdates(),
                                                    pendingTrans.getGuard());
                boolean insertedTrans = false;
                                                    pendingTrans.getKVUpdates(),
                                                    pendingTrans.getGuard());
                boolean insertedTrans = false;
@@ -375,13 +374,7 @@ final public class Table {
                }
 
                doOptionalRescue(s, seenliveslot, seqn, resize);
                }
 
                doOptionalRescue(s, seenliveslot, seqn, resize);
-               insertedTrans = doSendSlotsAndInsert(s, insertedTrans, resize, newsize);
-
-               if (insertedTrans) {
-                       // System.out.println("Inserted: " + trans.getSequenceNumber());
-               }
-
-               return insertedTrans;
+               return doSendSlotsAndInsert(s, insertedTrans, resize, newsize);
        }
 
        private boolean tryput(IoTString keyName, long arbMachineid, boolean resize) {
        }
 
        private boolean tryput(IoTString keyName, long arbMachineid, boolean resize) {
@@ -493,6 +486,7 @@ final public class Table {
                                        if (!resize) {
                                                System.out.println("B"); //?
 
                                        if (!resize) {
                                                System.out.println("B"); //?
 
+                                               // TODO delete
                                                System.out.println("==============================NEEEEDDDD RESIZING");
                                                return new ThreeTuple<Boolean, Boolean, Long>(true, seenliveslot, seqn);
                                        }
                                                System.out.println("==============================NEEEEDDDD RESIZING");
                                                return new ThreeTuple<Boolean, Boolean, Long>(true, seenliveslot, seqn);
                                        }
@@ -521,8 +515,19 @@ 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 ) {
                        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;
                        }
                                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;
 
                        // we did have something to arbitrate on
                        didNeedArbitration = true;
@@ -530,7 +535,7 @@ final public class Table {
                        Entry newEntry = null;
 
                        try {
                        Entry newEntry = null;
 
                        try {
-                               if ( ut.getGuard().evaluate(new HashSet<KeyValue>(speculativeTableTmp.values()))) {
+                               if ( ut.getGuard().evaluate(speculativeTableTmp.values())) {
                                        // Guard evaluated as true
 
                                        // update the local tmp current key set
                                        // Guard evaluated as true
 
                                        // update the local tmp current key set
@@ -539,12 +544,12 @@ final public class Table {
                                        }
 
                                        // create the commit
                                        }
 
                                        // create the commit
-                                       newEntry = new Commit(s, ut.getSequenceNumber(), ut.getkeyValueUpdateSet());
+                                       newEntry = new Commit(s, ut.getSequenceNumber(), ut.getArbitrator(), ut.getkeyValueUpdateSet());
                                } else {
                                        // Guard was false
 
                                        // create the abort
                                } else {
                                        // Guard was false
 
                                        // create the abort
-                                       newEntry = new Abort(s, ut.getSequenceNumber(), ut.getMachineID());
+                                       newEntry = new Abort(s, ut.getSequenceNumber(), ut.getMachineID(), ut.getArbitrator());
                                }
                        } catch (Exception e) {
                                e.printStackTrace();
                                }
                        } catch (Exception e) {
                                e.printStackTrace();
@@ -604,8 +609,17 @@ final public class Table {
                        inserted = false;
                }
 
                        inserted = false;
                }
 
+
+               // TODO remove Timers
+               // long startTime = System.currentTimeMillis();
                /* update data structure */
                validateandupdate(array, true);
                /* 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;
        }
 
                return inserted;
        }
@@ -631,8 +645,8 @@ final public class Table {
                        updateExpectedSize();
                }
 
                        updateExpectedSize();
                }
 
-               proccessAllNewCommits();
 
 
+               boolean hasGap = false;
                /* If there is a gap, check to see if the server sent us everything. */
                if (firstseqnum != (sequencenumber + 1)) {
 
                /* If there is a gap, check to see if the server sent us everything. */
                if (firstseqnum != (sequencenumber + 1)) {
 
@@ -652,6 +666,12 @@ final public class Table {
                }
                sequencenumber = newslots[newslots.length - 1].getSequenceNumber();
 
                }
                sequencenumber = newslots[newslots.length - 1].getSequenceNumber();
 
+               // Process all on key value pairs
+               proccessAllNewCommits();
+
+               // Go through all uncommitted transactions and kill the ones that are dead
+               deleteDeadUncommittedTransactions();
+
                // Speculate on key value pairs
                createSpeculativeTable();
        }
                // Speculate on key value pairs
                createSpeculativeTable();
        }
@@ -672,81 +692,156 @@ final public class Table {
                for (Long entrySeqNum : commitSeqNums) {
                        Commit entry = newCommitMap.get(entrySeqNum);
 
                for (Long entrySeqNum : commitSeqNums) {
                        Commit entry = newCommitMap.get(entrySeqNum);
 
+                       long lastCommitSeenSeqNum = 0;
+
+                       if (lastCommitSeenSeqNumMap.get(entry.getTransArbitrator()) != null) {
+                               lastCommitSeenSeqNum = lastCommitSeenSeqNumMap.get(entry.getTransArbitrator());
+                       }
+
                        if (entry.getTransSequenceNumber() <= lastCommitSeenSeqNum) {
 
                        if (entry.getTransSequenceNumber() <= lastCommitSeenSeqNum) {
 
-                               // Remove any old commits
-                               for (Iterator<Commit> i = commitList.iterator(); i.hasNext();) {
-                                       Commit prevcommit = i.next();
+                               Commit prevCommit = commitMap.put(entry.getTransSequenceNumber(), entry);
 
 
-                                       if (entry.getTransSequenceNumber() == prevcommit.getTransSequenceNumber()) {
-                                               prevcommit.setDead();
-                                               i.remove();
+                               if (prevCommit != null) {
+                                       prevCommit.setDead();
+
+                                       for (KeyValue kv : prevCommit.getkeyValueUpdateSet()) {
+                                               committedMapByKey.put(kv.getKey(), entry);
                                        }
                                }
                                        }
                                }
-                               commitList.add(entry);
+
                                continue;
                        }
 
                                continue;
                        }
 
-                       // Remove any old commits
-                       for (Iterator<Commit> i = commitList.iterator(); i.hasNext();) {
-                               Commit prevcommit = i.next();
-                               prevcommit.updateLiveKeys(entry.getkeyValueUpdateSet());
+                       Set<Commit> commitsToEditSet = new HashSet<Commit>();
+
+                       for (KeyValue kv : entry.getkeyValueUpdateSet()) {
+                               commitsToEditSet.add(committedMapByKey.get(kv.getKey()));
+                       }
+
+                       commitsToEditSet.remove(null);
+
+                       for (Commit prevCommit : commitsToEditSet) {
 
 
-                               if (!prevcommit.isLive()) {
-                                       i.remove();
+                               Set<KeyValue> deletedKV = prevCommit.updateLiveKeys(entry.getkeyValueUpdateSet());
+
+                               if (!prevCommit.isLive()) {
+                                       commitMap.remove(prevCommit.getTransSequenceNumber());
                                }
                        }
 
                                }
                        }
 
-                       // Add the new commit
-                       commitList.add(entry);
-                       lastCommitSeenSeqNum = entry.getTransSequenceNumber();
-                       // System.out.println("Last Seq Num: " + lastCommitSeenSeqNum);
+                       // // Remove any old commits
+                       // for (Iterator<Map.Entry<Long, Commit>> i = commitMap.entrySet().iterator(); i.hasNext();) {
+                       //      Commit prevCommit = i.next().getValue();
+                       //      prevCommit.updateLiveKeys(entry.getkeyValueUpdateSet());
+
+                       //      if (!prevCommit.isLive()) {
+                       //              i.remove();
+                       //      }
+                       // }
+
+                       // Remove any old commits
+                       // for (Iterator<Map.Entry<Long, Commit>> i = commitMap.entrySet().iterator(); i.hasNext();) {
+                       //      Commit prevCommit = i.next().getValue();
 
 
+                       //      if (prevCommit.getTransArbitrator() != entry.getTransArbitrator()) {
+                       //              continue;
+                       //      }
+
+                       //      prevCommit.updateLiveKeys(entry.getkeyValueUpdateSet());
+
+                       //      if (!prevCommit.isLive()) {
+                       //              i.remove();
+                       //      }
+                       // }
+
+
+                       // Add the new commit
+                       commitMap.put(entry.getTransSequenceNumber(), entry);
+                       lastCommitSeenSeqNumMap.put(entry.getTransArbitrator(), entry.getTransSequenceNumber());
 
                        // Update the committed table list
                        for (KeyValue kv : entry.getkeyValueUpdateSet()) {
                                IoTString key = kv.getKey();
                                commitedTable.put(key, kv);
 
                        // Update the committed table list
                        for (KeyValue kv : entry.getkeyValueUpdateSet()) {
                                IoTString key = kv.getKey();
                                commitedTable.put(key, kv);
-                       }
 
 
-                       long committedTransSeq = entry.getTransSequenceNumber();
-
-                       // Make dead the transactions
-                       for (Iterator<Map.Entry<Long, Transaction>> i = uncommittedTransactionsMap.entrySet().iterator(); i.hasNext();) {
-                               Transaction prevtrans = i.next().getValue();
-
-                               if (prevtrans.getSequenceNumber() <= committedTransSeq) {
-                                       i.remove();
-                                       prevtrans.setDead();
-                               }
+                               committedMapByKey.put(key, entry);
                        }
                }
 
                        }
                }
 
-
                // Clear the new commits storage so we can use it later
                newCommitMap.clear();
        }
 
                // Clear the new commits storage so we can use it later
                newCommitMap.clear();
        }
 
+       private void deleteDeadUncommittedTransactions() {
+               // Make dead the transactions
+               for (Iterator<Map.Entry<Long, Transaction>> i = uncommittedTransactionsMap.entrySet().iterator(); i.hasNext();) {
+                       Transaction prevtrans = i.next().getValue();
+                       long transArb = prevtrans.getArbitrator();
+
+                       if ((lastCommitSeenSeqNumMap.get(transArb) != null) && (prevtrans.getSequenceNumber() <= lastCommitSeenSeqNumMap.get(transArb)) ||
+                               (lastAbortSeenSeqNumMap.get(transArb) != null) && (prevtrans.getSequenceNumber() <= lastAbortSeenSeqNumMap.get(transArb))) {
+                               i.remove();
+                               prevtrans.setDead();
+                       }
+               }
+       }
+
        private void createSpeculativeTable() {
        private void createSpeculativeTable() {
-               Map speculativeTableTmp = new HashMap<IoTString, KeyValue>(commitedTable);
+
+               if (uncommittedTransactionsMap.keySet().size() == 0) {
+                       speculativeTable = commitedTable; // Ok that they are the same object
+                       return;
+               }
+
+               Map speculativeTableTmp = null;
                List<Long> utSeqNums = new ArrayList<Long>(uncommittedTransactionsMap.keySet());
 
                // Sort from oldest to newest commit
                Collections.sort(utSeqNums);
 
                List<Long> utSeqNums = new ArrayList<Long>(uncommittedTransactionsMap.keySet());
 
                // Sort from oldest to newest commit
                Collections.sort(utSeqNums);
 
+               if (utSeqNums.get(0) > (lastUncommittedTransaction)) {
+                       speculativeTableTmp = new HashMap<IoTString, KeyValue>(commitedTable);
 
 
-               for (Long key : utSeqNums) {
-                       Transaction trans = uncommittedTransactionsMap.get(key);
+                       for (Long key : utSeqNums) {
+                               Transaction trans = uncommittedTransactionsMap.get(key);
 
 
-                       try {
-                               if (trans.getGuard().evaluate(new HashSet<KeyValue>(speculativeTableTmp.values()))) {
-                                       for (KeyValue kv : trans.getkeyValueUpdateSet()) {
-                                               speculativeTableTmp.put(kv.getKey(), kv);
+                               lastUncommittedTransaction = key;
+
+                               try {
+                                       if (trans.getGuard().evaluate(speculativeTableTmp.values())) {
+                                               for (KeyValue kv : trans.getkeyValueUpdateSet()) {
+                                                       speculativeTableTmp.put(kv.getKey(), kv);
+                                               }
                                        }
                                        }
+
+                               } catch (Exception e) {
+                                       e.printStackTrace();
                                }
                                }
+                       }
+               } else {
+                       speculativeTableTmp = new HashMap<IoTString, KeyValue>(speculativeTable);
 
 
-                       } catch (Exception e) {
-                               e.printStackTrace();
+                       for (Long key : utSeqNums) {
+
+                               if (key <= lastUncommittedTransaction) {
+                                       continue;
+                               }
+
+                               lastUncommittedTransaction = key;
+
+                               Transaction trans = uncommittedTransactionsMap.get(key);
+
+                               try {
+                                       if (trans.getGuard().evaluate(speculativeTableTmp.values())) {
+                                               for (KeyValue kv : trans.getkeyValueUpdateSet()) {
+                                                       speculativeTableTmp.put(kv.getKey(), kv);
+                                               }
+                                       }
+
+                               } catch (Exception e) {
+                                       e.printStackTrace();
+                               }
                        }
                }
 
                        }
                }
 
@@ -780,7 +875,6 @@ final public class Table {
 
        private void commitNewMaxSize() {
                if (numslots != currmaxsize) {
 
        private void commitNewMaxSize() {
                if (numslots != currmaxsize) {
-                       System.out.println("Resizing the buffer"); // TODO: Remove
                        buffer.resize(currmaxsize);
                }
 
                        buffer.resize(currmaxsize);
                }
 
@@ -850,21 +944,17 @@ final public class Table {
 
                if (lastmessagetable.get(entry.getMachineID()).getFirst() < entry.getTransSequenceNumber()) {
                        // Abort has not been seen yet so we need to keep track of it
 
                if (lastmessagetable.get(entry.getMachineID()).getFirst() < entry.getTransSequenceNumber()) {
                        // Abort has not been seen yet so we need to keep track of it
-                       abortSet.add(entry);
+
+                       Abort prevAbort = abortMap.put(entry.getTransSequenceNumber(), entry);
+                       if (prevAbort != null) {
+                               prevAbort.setDead(); // delete old version of the duplicate
+                       }
                } else {
                        // The machine already saw this so it is dead
                        entry.setDead();
                }
 
                } else {
                        // The machine already saw this so it is dead
                        entry.setDead();
                }
 
-               // Make dead the transactions
-               for (Iterator<Map.Entry<Long, Transaction>> i = uncommittedTransactionsMap.entrySet().iterator(); i.hasNext();) {
-                       Transaction prevtrans = i.next().getValue();
-
-                       if (prevtrans.getSequenceNumber() <= entry.getTransSequenceNumber()) {
-                               i.remove();
-                               prevtrans.setDead();
-                       }
-               }
+               lastAbortSeenSeqNumMap.put(entry.getTransArbitrator(), entry.getTransSequenceNumber());
        }
 
        private void processEntry(Commit entry, Slot s) {
        }
 
        private void processEntry(Commit entry, Slot s) {
@@ -882,7 +972,6 @@ final public class Table {
                lastTableStatus = entry;
        }
 
                lastTableStatus = entry;
        }
 
-
        private void addWatchList(long machineid, RejectedMessage entry) {
                HashSet<RejectedMessage> entries = watchlist.get(machineid);
                if (entries == null)
        private void addWatchList(long machineid, RejectedMessage entry) {
                HashSet<RejectedMessage> entries = watchlist.get(machineid);
                if (entries == null)
@@ -918,16 +1007,15 @@ final public class Table {
                }
 
                // Set dead the abort
                }
 
                // Set dead the abort
-               for (Iterator<Abort> ait = abortSet.iterator(); ait.hasNext(); ) {
-                       Abort abort = ait.next();
+               for (Iterator<Map.Entry<Long, Abort>> i = abortMap.entrySet().iterator(); i.hasNext();) {
+                       Abort abort = i.next().getValue();
 
                        if ((abort.getMachineID() == machineid) && (abort.getTransSequenceNumber() <= seqnum)) {
                                abort.setDead();
 
                        if ((abort.getMachineID() == machineid) && (abort.getTransSequenceNumber() <= seqnum)) {
                                abort.setDead();
-                               ait.remove();
+                               i.remove();
                        }
                }
 
                        }
                }
 
-
                Pair<Long, Liveness> lastmsgentry = lastmessagetable.put(machineid, new Pair<Long, Liveness>(seqnum, liveness));
                if (lastmsgentry == null)
                        return;
                Pair<Long, Liveness> lastmsgentry = lastmessagetable.put(machineid, new Pair<Long, Liveness>(seqnum, liveness));
                if (lastmsgentry == null)
                        return;
index 24af2f8cbf3ecc745e6856ac17f40b12d61b8b5e..7e791ff6205d59d1cb042b78722ffbef7cc4fb15 100644 (file)
@@ -8,7 +8,7 @@ package iotcloud;
 
 public class Test {
 
 
 public class Test {
 
-       public static final  int NUMBER_OF_TESTS = 20000; //66
+       public static final  int NUMBER_OF_TESTS = 10000;
 
        public static void main(String[] args) {
                if (args[0].equals("2")) {
 
        public static void main(String[] args) {
                if (args[0].equals("2")) {
@@ -20,8 +20,6 @@ public class Test {
                }
        }
 
                }
        }
 
-
-
        static void test5() {
                Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
                t1.rebuild();
        static void test5() {
                Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
                t1.rebuild();
@@ -40,105 +38,213 @@ public class Test {
                // }
        }
 
                // }
        }
 
-       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();
-                               }
-                       }
-               };
-       }
+       // 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();
+       //                      }
+       //              }
+       //      };
+       // }
 
        static void test4() {
 
        static void test4() {
+
+               long startTime = 0;
+               long endTime = 0;
+
+               // Setup the 2 clients
                Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
                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);
                Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
-               t1.rebuild();
-               t2.rebuild();
-
-               Thread thr1 = buildThreadTest4("b", t1);
-               Thread thr2 = buildThreadTest4("a", t2);
-               thr1.start();
-               thr2.start();
-               try {
-                       thr1.join();
-                       thr2.join();
-               } catch (Exception e) {
-                       e.printStackTrace();
-               }
-
-               t1.update();
                t2.update();
                t2.update();
-               // t1.update();
 
 
-               // Print the results
-               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
+
+               // Make the Keys
+               System.out.println("Setting up keys");
+               startTime = System.currentTimeMillis();
+               for (int i = 0; i < 4; i++) {
                        String a = "a" + i;
                        String b = "b" + 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 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();
+                       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();
 
 
-       static void test3() {
-               Table t1 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 321);
-               Table t2 = new Table("http://127.0.0.1/test.iotcloud/", "reallysecret", 351);
-               t1.rebuild();
-               t2.rebuild();
 
 
 
 
-               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
-                       String key = "a" + i;
-                       String value = "a" + (i + 1000);
-                       IoTString iKey = new IoTString(key);
-                       IoTString iValue = new IoTString(value);
+               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();
 
 
-                       t1.startTransaction();
-                       t1.addKV(iKey, iValue);
-                       t1.commitTransaction();
+
+               // Do Updates for the keys
+               System.out.println("Setting Key-Values...");
+               startTime = System.currentTimeMillis();
+               for (int t = 0; t < NUMBER_OF_TESTS; t++) {
+                       for (int i = 0; i < 4; 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);
+
+                               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();
 
 
-               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
-                       String key = "b" + i;
-                       String value = "b" + (i + 1000);
-                       IoTString iKey = new IoTString(key);
-                       IoTString iValue = new IoTString(value);
+               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 * 8))   );
+               System.out.println();
 
 
-                       t2.startTransaction();
-                       t2.addKV(iKey, iValue);
-                       t2.commitTransaction();
-               }
 
 
-               // Make sure t1 sees the new updates from t2
+               System.out.println("Updating Clients...");
+               t1.update();
+               t2.update();
                t1.update();
                t1.update();
+               t2.update();
 
 
-               // 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);
+               boolean foundError = false;
+
+               System.out.println("Checking Key-Values...");
+               for (int i = 0; i < 4; 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;
+                       }
 
 
-                       System.out.println(ib + " -> " + t1.getCommitted(ib));
-                       System.out.println(ia + " -> " + t2.getCommitted(ia));
-                       System.out.println();
+                       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...");
+               }
+
+               System.out.println();
+               System.out.println();
+               System.out.println();
+               System.out.println();
+               t1.printSlots();
+               System.out.println();
+               t2.printSlots();
        }
 
        }
 
-       static void test2() {
+       static void test3() {
+
+               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);
                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);
@@ -147,268 +253,366 @@ public class Test {
 
                // Make the Keys
                System.out.println("Setting up keys");
 
                // 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;
                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 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(ia, 321);
-                       t1.createNewKey(ib, 321);
+                       t1.createNewKey(ib, 351);
+                       t2.createNewKey(ic, 321);
+                       t2.createNewKey(id, 351);
                }
                }
+               endTime = System.currentTimeMillis();
 
 
-               // System.out.println("=========t1 live" + t1.liveslotcount + "     thresh: " + t1.resizethreshold);
-               // System.out.println("=========t2 live" + t2.liveslotcount + "     thresh: " + t2.resizethreshold);
-               // System.out.println();
 
 
 
 
+               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
 
                // Do Updates for the keys
-               System.out.println("Writing Keys a...");
+               System.out.println("Setting Key-Values...");
+               startTime = System.currentTimeMillis();
                for (int i = 0; i < NUMBER_OF_TESTS; i++) {
                for (int i = 0; i < NUMBER_OF_TESTS; i++) {
-                       System.out.println(i);
-
-                       String key = "a" + i;
-                       String value = "a" + (i + 10000);
-                       IoTString iKey = new IoTString(key);
-                       IoTString iValue = new IoTString(value);
+                       String keyB = "b" + i;
+                       String valueB = "b" + i;
 
 
+                       IoTString iKeyB = new IoTString(keyB);
+                       IoTString iValueB = new IoTString(valueB);
 
                        t1.startTransaction();
 
                        t1.startTransaction();
-                       t1.addKV(iKey, iValue);
+                       t1.addKV(iKeyB, iValueB);
                        t1.commitTransaction();
                }
 
                        t1.commitTransaction();
                }
 
-               // Do Updates for the keys
-               System.out.println("Writing Keys a...");
                for (int i = 0; i < NUMBER_OF_TESTS; i++) {
                for (int i = 0; i < NUMBER_OF_TESTS; i++) {
-                       System.out.println(i);
+                       String keyC = "c" + i;
+                       String valueC = "c" + i;
 
 
-                       String key = "a" + i;
-                       String value = "a" + (i + 10000);
-                       IoTString iKey = new IoTString(key);
-                       IoTString iValue = new IoTString(value);
+                       IoTString iKeyC = new IoTString(keyC);
+                       IoTString iValueC = new IoTString(valueC);
 
 
-                       t1.startTransaction();
-                       t1.addKV(iKey, iValue);
-                       t1.commitTransaction();
+                       t2.startTransaction();
+                       t2.addKV(iKeyC, iValueC);
+                       t2.commitTransaction();
                }
 
                }
 
-
-               t2.update();
-               System.out.println("Writing Keys b...");
                for (int i = 0; i < NUMBER_OF_TESTS; i++) {
                for (int i = 0; i < NUMBER_OF_TESTS; i++) {
-                       System.out.println(i);
+                       String keyA = "a" + i;
+                       String keyD = "d" + i;
+                       String valueA = "a" + i;
+                       String valueD = "d" + i;
 
 
-                       String key = "b" + i;
-                       String value = "b" + (i + 10000);
-                       IoTString iKey = new IoTString(key);
-                       IoTString iValue = new IoTString(value);
+                       IoTString iKeyA = new IoTString(keyA);
+                       IoTString iKeyD = new IoTString(keyD);
+                       IoTString iValueA = new IoTString(valueA);
+                       IoTString iValueD = new IoTString(valueD);
 
 
+                       t1.startTransaction();
+                       t1.addKV(iKeyA, iValueA);
+                       t1.commitTransaction();
 
                        t2.startTransaction();
 
                        t2.startTransaction();
-                       t2.addKV(iKey, iValue);
+                       t2.addKV(iKeyD, iValueD);
                        t2.commitTransaction();
                }
 
 
                        t2.commitTransaction();
                }
 
 
-               // Do Updates for the keys
-               System.out.println("Writing Keys a...");
-               for (int i = 0; i < NUMBER_OF_TESTS; i += 2) {
-                       System.out.println(i);
 
 
-                       String key = "a" + i;
-                       String value = "a" + (i + 10000);
-                       IoTString iKey = new IoTString(key);
-                       IoTString iValue = new IoTString(value);
 
 
-                       t1.startTransaction();
-                       t1.addKV(iKey, iValue);
-                       t1.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();
 
                t1.update();
                t2.update();
 
-               System.out.println("Checking a keys...");
-               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
-
-                       String key = "a" + i;
-                       String value = "a" + (i + 10000);
-                       IoTString iKey = new IoTString(key);
-                       IoTString iValue = new IoTString(value);
+               boolean foundError = false;
 
 
-                       IoTString testVal = t1.getCommitted(iKey);
+               System.out.println("Checking Key-Values...");
+               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
 
 
-                       if ((testVal == null) || (testVal.equals(iValue) == false)) {
-                               System.out.println("Key val incorrect: " + key);
+                       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;
                        }
 
                        }
 
-                       key = "b" + i;
-                       value = "b" + (i + 10000);
-                       iKey = new IoTString(key);
-                       iValue = new IoTString(value);
-
-                       testVal = t1.getCommitted(iKey);
-
-                       if ((testVal == null) || (testVal.equals(iValue) == false)) {
-                               System.out.println("Key val incorrect: " + key);
+                       if ((testValB1 == null) || (testValB1.equals(iValueB) == false)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyB);
+                               foundError = true;
                        }
                        }
-               }
 
 
-               System.out.println("Checking b keys...");
-               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
+                       if ((testValC1 == null) || (testValC1.equals(iValueC) == false)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyC);
+                               foundError = true;
+                       }
 
 
-                       String key = "a" + i;
-                       String value = "a" + (i + 10000);
-                       IoTString iKey = new IoTString(key);
-                       IoTString iValue = new IoTString(value);
+                       if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyD);
+                               foundError = true;
+                       }
 
 
-                       IoTString testVal = t2.getCommitted(iKey);
 
 
-                       if ((testVal == null) || (testVal.equals(iValue) == false)) {
-                               System.out.println("Key val incorrect: " + key);
+                       if ((testValA2 == null) || (testValA2.equals(iValueA) == false)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyA + "    " + testValA2);
+                               foundError = true;
                        }
 
                        }
 
-                       key = "b" + i;
-                       value = "b" + (i + 10000);
-                       iKey = new IoTString(key);
-                       iValue = new IoTString(value);
+                       if ((testValB2 == null) || (testValB2.equals(iValueB) == false)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyB + "    " + testValB2);
+                               foundError = true;
+                       }
 
 
-                       testVal = t2.getCommitted(iKey);
+                       if ((testValC2 == null) || (testValC2.equals(iValueC) == false)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyC + "    " + testValC2);
+                               foundError = true;
+                       }
 
 
-                       if ((testVal == null) || (testVal.equals(iValue) == false)) {
-                               System.out.println("Key val incorrect: " + key);
+                       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...");
+               }
 
 
-
-
-               System.out.println();
                System.out.println();
                System.out.println();
-               System.out.println("Update");
-               // Make sure t1 sees the new updates from t2
-               t1.update();
-               t2.update();
-               t1.update();
                System.out.println();
                System.out.println();
                System.out.println();
                System.out.println();
                System.out.println();
                System.out.println();
+               t1.printSlots();
                System.out.println();
                System.out.println();
-               System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
-               System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
-               System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
+               t2.printSlots();
+       }
+
+       static void test2() {
+
+               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();
                t2.update();
-               System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
-               System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
-               System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
 
 
+               // t1.rebuild();
+               // t2.rebuild();
 
 
-               // System.out.println("=========t1 live" + t1.liveslotcount + "     thresh: " + t1.resizethreshold + "   commits: " + t1.commitedTable.size() + "   uncommits: " + t1.uncommittedTransactionsList.size());
-               // System.out.println("=========t2 live" + t2.liveslotcount + "     thresh: " + t2.resizethreshold + "   commits: " + t2.commitedTable.size() + "   uncommits: " + t2.uncommittedTransactionsList.size() );
-               System.out.println();
 
 
-               t1.printSlots();
-               System.out.println();
-               System.out.println();
-               System.out.println();
-               System.out.println();
-               t2.printSlots();
+
+               // 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();
 
 
                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);
+
+                       t1.startTransaction();
+                       t1.addKV(iKeyA, iValueA);
+                       t1.commitTransaction();
 
 
-               // // Do Updates for the keys
-               // System.out.println("Writing Keys a (actual)");
-               // for (int i = 0; i < NUMBER_OF_TESTS; i++) {
-               //      String key = "a" + i;
-               //      String value = "a" + i;
-               //      IoTString iKey = new IoTString(key);
-               //      IoTString iValue = new IoTString(value);
-
-               //      t1.startTransaction();
-               //      t1.addKV(iKey, iValue);
-               //      t1.commitTransaction();
-               // }
+                       t1.startTransaction();
+                       t1.addKV(iKeyB, iValueB);
+                       t1.commitTransaction();
 
 
-               // System.out.println("=========t1 live" + t1.liveslotcount + "     thresh: " + t1.resizethreshold + "   commits: " + t1.commitedTable.size() + "   uncommits: " + t1.uncommittedTransactionsList.size());
-               // System.out.println("=========t2 live" + t2.liveslotcount + "     thresh: " + t2.resizethreshold + "   commits: " + t2.commitedTable.size() + "   uncommits: " + t2.uncommittedTransactionsList.size());
-               // System.out.println();
+                       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("Writing Keys b (actual)");
-               // for (int i = 0; i < NUMBER_OF_TESTS; i++) {
-               //      String key = "b" + i;
-               //      String value = "b" + i;
-               //      IoTString iKey = new IoTString(key);
-               //      IoTString iValue = new IoTString(value);
-
-               //      t2.startTransaction();
-               //      t2.addKV(iKey, iValue);
-               //      t2.commitTransaction();
-               // }
 
 
-               // System.out.println("=========t1 live" + t1.liveslotcount + "     thresh: " + t1.resizethreshold + "   commits: " + t1.commitedTable.size() + "   uncommits: " + t1.uncommittedTransactionsList.size() );
-               // System.out.println("=========t2 live" + t2.liveslotcount + "     thresh: " + t2.resizethreshold + "   commits: " + t2.commitedTable.size() + "   uncommits: " + t2.uncommittedTransactionsList.size() );
-               // System.out.println();
+               System.out.println("Updating Clients...");
+               t1.update();
+               t2.update();
+               t1.update();
+               t2.update();
 
 
+               boolean foundError = false;
 
 
-               // // Do Updates for the keys
-               // System.out.println("Writing Keys a (actual)");
-               // for (int i = 0; i < NUMBER_OF_TESTS; i++) {
-               //      String key = "a" + i;
-               //      String value = "a" + i;
-               //      IoTString iKey = new IoTString(key);
-               //      IoTString iValue = new IoTString(value);
-
-               //      t1.startTransaction();
-               //      t1.addKV(iKey, iValue);
-               //      t1.commitTransaction();
-               // }
+               System.out.println("Checking Key-Values...");
+               for (int i = 0; i < NUMBER_OF_TESTS; i++) {
 
 
-               // System.out.println("=========t1 live" + t1.liveslotcount + "     thresh: " + t1.resizethreshold + "   commits: " + t1.commitedTable.size() + "   uncommits: " + t1.uncommittedTransactionsList.size());
-               // System.out.println("=========t2 live" + t2.liveslotcount + "     thresh: " + t2.resizethreshold + "   commits: " + t2.commitedTable.size() + "   uncommits: " + t2.uncommittedTransactionsList.size());
-               // System.out.println();
+                       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;
+                       }
 
 
-               // System.out.println("Writing Keys b (actual)");
-               // for (int i = 0; i < NUMBER_OF_TESTS; i++) {
-               //      String key = "b" + i;
-               //      String value = "b" + i;
-               //      IoTString iKey = new IoTString(key);
-               //      IoTString iValue = new IoTString(value);
-
-               //      t2.startTransaction();
-               //      t2.addKV(iKey, iValue);
-               //      t2.commitTransaction();
-               // }
+                       if ((testValD1 == null) || (testValD1.equals(iValueD) == false)) {
+                               System.out.println("Key-Value t1 incorrect: " + keyD);
+                               foundError = true;
+                       }
 
 
-               // System.out.println("=========t1 live" + t1.liveslotcount + "     thresh: " + t1.resizethreshold + "   commits: " + t1.commitedTable.size() + "   uncommits: " + t1.uncommittedTransactionsList.size() );
-               // System.out.println("=========t2 live" + t2.liveslotcount + "     thresh: " + t2.resizethreshold + "   commits: " + t2.commitedTable.size() + "   uncommits: " + t2.uncommittedTransactionsList.size() );
-               // System.out.println();
 
 
-               // t1.printSlots();
-               // System.out.println();
-               // t2.printSlots();
+                       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;
+                       }
 
 
-               // Make sure t1 sees the new updates from t2
-               // t1.update();
+                       if ((testValD2 == null) || (testValD2.equals(iValueD) == false)) {
+                               System.out.println("Key-Value t2 incorrect: " + keyD + "    " + testValD2);
+                               foundError = true;
+                       }
+               }
 
 
-               // // Print the results
-               // for (int i = NUMBER_OF_TESTS - 10; i < NUMBER_OF_TESTS; i++) {
-               // String a = "a" + i;
-               // String b = "b" + i;
-               // IoTString ia = new IoTString(a);
-               //      IoTString ib = new IoTString(b);
+               if (foundError) {
+                       System.out.println("Found Errors...");
+               } else {
+                       System.out.println("No Errors Found...");
+               }
 
 
-               //      System.out.println(ib + " -> " + t1.getCommitted(ib));
-               //      System.out.println(ia + " -> " + t2.getCommitted(ia));
-               //      System.out.println();
-               // }
+               System.out.println();
+               System.out.println();
+               System.out.println();
+               System.out.println();
+               t1.printSlots();
+               System.out.println();
+               t2.printSlots();
        }
 }
        }
 }
index 5acd5c2d0afa0ffc67435c42af198352ad69c1b8..2167d7d81804ee1f10fcb77dc61a1687a1f8f8da 100644 (file)
@@ -10,12 +10,13 @@ class Transaction extends Entry {
     private long machineid;
     private Set<KeyValue> keyValueUpdateSet = null;
     private Guard guard;
     private long machineid;
     private Set<KeyValue> keyValueUpdateSet = null;
     private Guard guard;
+    private Long arbitrator;
 
 
-    public Transaction(Slot slot, long _seqnum, long _machineid, Set<KeyValue> _keyValueUpdateSet, Guard _guard) {
+    public Transaction(Slot slot, long _seqnum, long _machineid, Long _arbitrator, Set<KeyValue> _keyValueUpdateSet, Guard _guard) {
         super(slot);
         seqnum = _seqnum;
         machineid = _machineid;
         super(slot);
         seqnum = _seqnum;
         machineid = _machineid;
-
+        arbitrator = _arbitrator;
         keyValueUpdateSet = new HashSet<KeyValue>();
 
         for (KeyValue kv : _keyValueUpdateSet) {
         keyValueUpdateSet = new HashSet<KeyValue>();
 
         for (KeyValue kv : _keyValueUpdateSet) {
@@ -30,6 +31,10 @@ class Transaction extends Entry {
         return machineid;
     }
 
         return machineid;
     }
 
+    public long getArbitrator() {
+        return arbitrator;
+    }
+
     public long getSequenceNumber() {
         return seqnum;
     }
     public long getSequenceNumber() {
         return seqnum;
     }
@@ -47,7 +52,7 @@ class Transaction extends Entry {
     }
 
     public int getSize() {
     }
 
     public int getSize() {
-        int size = 2 * Long.BYTES + Byte.BYTES; // seq, machine id, entry type
+        int size = 3 * Long.BYTES + Byte.BYTES; // seq, machine id, entry type
         size += Integer.BYTES; // number of KV's
 
         // Size of each KV
         size += Integer.BYTES; // number of KV's
 
         // Size of each KV
@@ -66,6 +71,7 @@ class Transaction extends Entry {
         bb.put(Entry.TypeTransaction);
         bb.putLong(seqnum);
         bb.putLong(machineid);
         bb.put(Entry.TypeTransaction);
         bb.putLong(seqnum);
         bb.putLong(machineid);
+        bb.putLong(arbitrator);
 
         bb.putInt(keyValueUpdateSet.size());
         for (KeyValue kv : keyValueUpdateSet) {
 
         bb.putInt(keyValueUpdateSet.size());
         for (KeyValue kv : keyValueUpdateSet) {
@@ -78,6 +84,7 @@ class Transaction extends Entry {
     static Entry decode(Slot slot, ByteBuffer bb) {
         long seqnum = bb.getLong();
         long machineid = bb.getLong();
     static Entry decode(Slot slot, ByteBuffer bb) {
         long seqnum = bb.getLong();
         long machineid = bb.getLong();
+        long arbitrator = bb.getLong();
         int numberOfKeys = bb.getInt();
 
         Set<KeyValue> kvSet = new HashSet<KeyValue>();
         int numberOfKeys = bb.getInt();
 
         Set<KeyValue> kvSet = new HashSet<KeyValue>();
@@ -88,10 +95,10 @@ class Transaction extends Entry {
 
         Guard guard = Guard.decode(bb);
 
 
         Guard guard = Guard.decode(bb);
 
-        return new Transaction(slot, seqnum, machineid, kvSet, guard);
+        return new Transaction(slot, seqnum, machineid, arbitrator, kvSet, guard);
     }
 
     public Entry getCopy(Slot s) {
     }
 
     public Entry getCopy(Slot s) {
-        return new Transaction(s, seqnum, machineid, keyValueUpdateSet, guard);
+        return new Transaction(s, seqnum, machineid, arbitrator, keyValueUpdateSet, guard);
     }
 }
\ No newline at end of file
     }
 }
\ No newline at end of file