From 5f425600cc1e66ef621e99fb20551f6768a346f1 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Thu, 16 Jul 2009 11:47:46 +0000 Subject: [PATCH] last changes --- .../Benchmarks/SingleTM/Vacation/Client.java | 2 +- .../Benchmarks/SingleTM/Vacation/RBTree.java | 15 ++-- .../SingleTM/Vacation/Vacation.java | 70 ++++++++++++++++++- 3 files changed, 76 insertions(+), 11 deletions(-) diff --git a/Robust/src/Benchmarks/SingleTM/Vacation/Client.java b/Robust/src/Benchmarks/SingleTM/Vacation/Client.java index e0bc915e..e70fbee6 100644 --- a/Robust/src/Benchmarks/SingleTM/Vacation/Client.java +++ b/Robust/src/Benchmarks/SingleTM/Vacation/Client.java @@ -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 { diff --git a/Robust/src/Benchmarks/SingleTM/Vacation/RBTree.java b/Robust/src/Benchmarks/SingleTM/Vacation/RBTree.java index f7826c8f..e5acd3e5 100644 --- a/Robust/src/Benchmarks/SingleTM/Vacation/RBTree.java +++ b/Robust/src/Benchmarks/SingleTM/Vacation/RBTree.java @@ -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; + } /* ============================================================================= diff --git a/Robust/src/Benchmarks/SingleTM/Vacation/Vacation.java b/Robust/src/Benchmarks/SingleTM/Vacation/Vacation.java index dcc16f6a..900294a7 100644 --- a/Robust/src/Benchmarks/SingleTM/Vacation/Vacation.java +++ b/Robust/src/Benchmarks/SingleTM/Vacation/Vacation.java @@ -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 + -- 2.34.1