Initial Working version of IoTCloudv2, needs more testing
[iotcloud.git] / src2 / java / iotcloud / Table.java
index 00d48b0cac44d1b1a4016735684f982d009ca7c4..cf21f48d29d81324249559f08cd16a7d37f4fc1b 100644 (file)
@@ -689,45 +689,48 @@ final public class Table {
                }
 
 
-               // Arbitrate
-               Map speculativeTableTmp = new HashMap<IoTString, KeyValue>(commitedTable);
-               for (Transaction ut : uncommittedTransactionsList) {
-
-                       KeyValue keyVal = (KeyValue)(ut.getkeyValueUpdateSet().toArray())[0];
-                       // Check if this machine arbitrates for this transaction
-                       if (arbitratorTable.get( keyVal.getKey() ) != localmachineid ) {
-                               continue;
-                       }
-
-                       Entry newEntry = null;
-
-                       try {
-                               if ( ut.getGuard().evaluate(new HashSet<KeyValue>(speculativeTableTmp.values()))) {
-                                       // Guard evaluated as true
-
-                                       // update the local tmp current key set
-                                       for (KeyValue kv : ut.getkeyValueUpdateSet()) {
-                                               speculativeTableTmp.put(kv.getKey(), kv);
-                                       }
-
-                                       // create the commit
-                                       newEntry = new Commit(s, ut.getSequenceNumber(), ut.getkeyValueUpdateSet());
-                               } else {
-                                       // Guard was false
-
-                                       // create the abort
-                                       newEntry = new Abort(s, ut.getSequenceNumber(), ut.getMachineID());
-                               }
-                       } catch (Exception e) {
-                               e.printStackTrace();
-                       }
-
-                       if ((newEntry != null) && s.hasSpace(newEntry)) {
-                               s.addEntry(newEntry);
-                       } else {
-                               break;
-                       }
-               }
+               // // Arbitrate
+               // Map speculativeTableTmp = new HashMap<IoTString, KeyValue>(commitedTable);
+               // for (Transaction ut : uncommittedTransactionsList) {
+
+               //      KeyValue keyVal = (KeyValue)(ut.getkeyValueUpdateSet().toArray())[0];
+               //      // Check if this machine arbitrates for this transaction
+               //      if (arbitratorTable.get( keyVal.getKey() ) != localmachineid ) {
+               //              continue;
+               //      }
+
+               //      Entry newEntry = null;
+
+               //      try {
+               //              if ( ut.getGuard().evaluate(new HashSet<KeyValue>(speculativeTableTmp.values()))) {
+               //                      // Guard evaluated as true
+
+               //                      // update the local tmp current key set
+               //                      for (KeyValue kv : ut.getkeyValueUpdateSet()) {
+               //                              speculativeTableTmp.put(kv.getKey(), kv);
+               //                      }
+
+               //                      // create the commit
+               //                      newEntry = new Commit(s, ut.getSequenceNumber(), ut.getkeyValueUpdateSet());
+               //              } else {
+               //                      // Guard was false
+
+               //                      // create the abort
+               //                      newEntry = new Abort(s, ut.getSequenceNumber(), ut.getMachineID());
+               //              }
+               //      } catch (Exception e) {
+               //              e.printStackTrace();
+               //      }
+
+               //      if ((newEntry != null) && s.hasSpace(newEntry)) {
+
+               //              // TODO: Remove print
+               //              System.out.println("Arbitrating...");
+               //              s.addEntry(newEntry);
+               //      } else {
+               //              break;
+               //      }
+               // }
 
 
                NewKey newKey = new NewKey(s, keyName, arbMachineid);
@@ -960,7 +963,8 @@ final public class Table {
                        prevcommit.updateLiveKeys(entry.getkeyValueUpdateSet());
 
                        if (!prevcommit.isLive()) {
-                               commitList.remove(prevcommit);
+                               //commitList.remove(prevcommit);
+                               i.remove();
                        }
                }
 
@@ -979,7 +983,8 @@ final public class Table {
                        Transaction prevtrans = i.next();
 
                        if (prevtrans.getSequenceNumber() <= committedTransSeq) {
-                               uncommittedTransactionsList.remove(prevtrans);
+                               // uncommittedTransactionsList.remove(prevtrans);
+                               i.remove();
                                prevtrans.setDead();
                        }
                }