last changes
authorbdemsky <bdemsky>
Thu, 16 Jul 2009 11:47:46 +0000 (11:47 +0000)
committerbdemsky <bdemsky>
Thu, 16 Jul 2009 11:47:46 +0000 (11:47 +0000)
Robust/src/Benchmarks/SingleTM/Vacation/Client.java
Robust/src/Benchmarks/SingleTM/Vacation/RBTree.java
Robust/src/Benchmarks/SingleTM/Vacation/Vacation.java

index e0bc915e35b1a380f469123e067eef11accf5e9d..e70fbee6df7fb67240032c9b1bd280eec56367a0 100644 (file)
@@ -196,7 +196,7 @@ public class Client extends Thread {
          if (maxIds[RESERVATION_ROOM] > 0) {
            managerPtr.manager_reserveRoom(customerId, maxIds[RESERVATION_ROOM]);
          }
-       }
+       }//end atomic
       } else if (action==ACTION_DELETE_CUSTOMER) {
        int customerId = randomPtr.posrandom_generate() % queryRange + 1;
        atomic {
index f7826c8ffb12285a88c6587ccb6a2f3038563d07..e5acd3e54c3fb08adb687a3cad6b5d4b154faee6 100644 (file)
@@ -604,15 +604,14 @@ public class RBTree {
  * =============================================================================
  * bool_t rbtree_insert (rbtree_t* r, void* key, void* val);
  */
-    public boolean insert(int key,Object val)
-    {
-        Node node = new Node();
-        Node ex = insert(key,val,node);
-        if ( ex != null) {
-            node = null;
-        }
-        return ((ex == null) ? true : false);
+  public boolean insert(int key,Object val) {
+    Node node = new Node();
+    Node ex = insert(key,val,node);
+    if ( ex != null) {
+      node = null;
     }
+    return ex == null;
+  }
 
 
 /* =============================================================================
index dcc16f6a711de114f21721bf1dbb3e76fd26e96c..900294a7a89e3aaa2a89cbbe16c5999b0a13b59a 100644 (file)
@@ -303,7 +303,7 @@ public class Vacation {
     System.out.print("done.");
     long diff=stop-start;
     System.out.println("Time = "+diff);
-    //checkTables(managerPtr);
+    vac.checkTables(managerPtr);
     
     /* Clean up */
     System.out.println("Deallocating memory... ");
@@ -312,6 +312,72 @@ public class Vacation {
      */
     System.out.println("done.");
   }
+  
+  void checkTables (Manager managerPtr) {
+    int i;
+    int numRelation = RELATIONS;
+    RBTree customerTablePtr = managerPtr.customerTablePtr;
+    RBTree tables[]=new RBTree[3];
+    tables[0]=managerPtr.carTablePtr;
+    tables[1]=managerPtr.flightTablePtr;
+    tables[2]=managerPtr.roomTablePtr;
+    int numTable = 3;
+
+    int t;
+
+    System.out.println("Checking tables... ");
+
+    /* Check for unique customer IDs */
+    int percentQuery = QUERIES;
+    int queryRange = (int)((double)percentQuery / 100.0 * (double)numRelation + 0.5);
+    int maxCustomerId = queryRange + 1;
+    for (i = 1; i <= maxCustomerId; i++) {
+      if (customerTablePtr.find(i)!=null) {
+       if (customerTablePtr.remove(i)) {
+         if (customerTablePtr.find(i)!=null) {
+           System.out.println("ERROR");
+           System.exit(-1);
+         }
+       }
+      }
+    }
+
+    /* Check reservation tables for consistency and unique ids */
+    for (t = 0; t < numTable; t++) {
+      RBTree tablePtr = tables[t];
+      for (i = 1; i <= numRelation; i++) {
+       if (tablePtr.find(i)!=null) {
+         if (t==0) {
+           if (!managerPtr.manager_addCar(i,0,0)) {
+             System.out.println("ERROR3");
+             System.exit(-1);
+           }
+         } else if (t==1) {
+           if (!managerPtr.manager_addFlight(i, 0, 0)) {
+             System.out.println("ERROR3");
+             System.exit(-1);
+           }
+         } else if (t==2) {
+           if (!managerPtr.manager_addRoom(i,0,0)) {
+             System.out.println("ERROR3");
+             System.exit(-1);
+           }
+         }
+
+         if (tablePtr.remove(i)) {
+           if (tablePtr.remove(i)) {
+             System.out.println("ERROR2");
+             System.exit(-1);
+           }
+         }
+       }
+      }
+    }
+
+    System.out.println("done.");
+  }
+
+
 }  
   
   /* =============================================================================
@@ -320,4 +386,4 @@ public class Vacation {
    *
    * =============================================================================
    */
-  
\ No newline at end of file
+