public static void bstcmt(WorkflowControllerImpl wc) throws RemoteException, TransactionAbortedException, InvalidTransactionException { int xid = wc.start(); System.out.println(xid); boolean returnValue = wc.commit(xid); System.out.println(returnValue); }
public static void Sbadxid(WorkflowControllerImpl wc) throws RemoteException, TransactionAbortedException, InvalidTransactionException { int xid = wc.start(); xid = wc.start(); try { wc.addFlight(7123894, "347", 100, 310); } catch (InvalidTransactionException e) { System.out.println("Caught remote exception"); } }
public static void badd(WorkflowControllerImpl wc) throws RemoteException, TransactionAbortedException, InvalidTransactionException { int xid = wc.start(); boolean returnValue = wc.addFlight(xid, "347", 100, 310); assert returnValue == true; returnValue = wc.addRooms(xid, "Stanford", 200, 150); assert returnValue == true; returnValue = wc.addCars(xid, "SFO", 300, 30); assert returnValue == true; returnValue = wc.newCustomer(xid, "John"); assert returnValue == true; }
public static void Fdieall(WorkflowControllerImpl wc) throws RemoteException, TransactionAbortedException, InvalidTransactionException { // int xid = wc.start(); // boolean returnValue = wc.addFlight(xid, "347", 100, 310); // assert returnValue == true; // returnValue = wc.addRooms(xid, "Stanford", 200, 150); // assert returnValue == true; // returnValue = wc.addCars(xid, "SFO", 300, 30); // assert returnValue == true; // returnValue = wc.newCustomer(xid, "John"); // assert returnValue == true; // wc.commit(xid); // try{ // wc.dieNow("ALL"); // } catch(RemoteException e) // { // System.out.println("Caught remote exception"); // } int xid2 = wc.start(); int flight = wc.queryFlight(xid2, "347"); assert flight == 100; int flightPrice = wc.queryFlightPrice(xid2, "347"); assert flightPrice == 310; int rooms = wc.queryRooms(xid2, "Stanford"); assert rooms == 200; int roomsPrice = wc.queryRoomsPrice(xid2, "Stanford"); assert roomsPrice == 150; int cars = wc.queryCars(xid2, "SFO"); assert cars == 300; int carsprice = wc.queryCarsPrice(xid2, "SFO"); assert carsprice == 30; int customerbill = wc.queryCustomerBill(xid2, "John"); assert customerbill == 0; }
public static void FunLock(WorkflowControllerImpl wc) throws RemoteException, TransactionAbortedException, InvalidTransactionException { /* int xid = wc.start(); wc.addFlight(xid, "347", 100, 310); wc.addRooms(xid, "Stanford", 200, 150); wc.addCars(xid, "SFO", 300, 30); wc.newCustomer(xid, "John"); wc.commit(xid); xid = wc.start(); int xid2 = wc.start(); wc.addFlight(xid2, "347", 100, 620); wc.addRooms(xid, "Stanford", 200, 300); try { wc.queryRooms(xid2, "Stanford"); }catch(TransactionAbortedException e){ System.out.println("Caught deadlock"); } wc.commit(xid); //printTables(wc); xid = wc.start(); int value = wc.queryFlight(xid, "347"); System.out.println(value); value = wc.queryFlightPrice(xid, "347"); System.out.println(value); value = wc.queryRooms(xid, "Stanford"); System.out.println(value); value = wc.queryRoomsPrice(xid, "Stanford"); System.out.println(value); */ int xid = wc.start(); boolean returnValue = wc.addFlight(xid, "347", 100, 310); assert returnValue == true; wc.commit(xid); xid = wc.start(); xid = wc.start(); returnValue = wc.addFlight(xid, "347", 100, 620); assert returnValue == true; int flight = wc.queryFlight(xid, "347"); assert flight == 100; returnValue = wc.dieTMAfterCommit(); assert returnValue == true; try { wc.commit(xid); } catch (RemoteException e) { System.out.println("Caught remote exception"); } }
public static void main(String args[]) throws RemoteException, TransactionAbortedException, InvalidTransactionException, FileNotFoundException, IOException { TransactionManagerImpl tm = new TransactionManagerImpl(); ResourceManagerImpl rmflights = new ResourceManagerImpl(ResourceManager.RMINameFlights); rmflights.setTm(tm); ResourceManagerImpl rmcustomers = new ResourceManagerImpl(ResourceManager.RMINameCustomers); rmcustomers.setTm(tm); ResourceManagerImpl rmcars = new ResourceManagerImpl(ResourceManager.RMINameCars); rmcars.setTm(tm); ResourceManagerImpl rmhotels = new ResourceManagerImpl(ResourceManager.RMINameRooms); rmhotels.printRooms(); rmhotels.setTm(tm); WorkflowControllerImpl wc = new WorkflowControllerImpl(); wc.setRM(ResourceManager.RMINameFlights, rmflights); wc.setRM(ResourceManager.RMINameCars, rmcars); wc.setRM(ResourceManager.RMINameCustomers, rmcustomers); wc.setRM(ResourceManager.RMINameRooms, rmhotels); wc.setTM(tm); tm.setRM(ResourceManager.RMINameFlights, rmflights); tm.setRM(ResourceManager.RMINameCars, rmcars); tm.setRM(ResourceManager.RMINameCustomers, rmcustomers); tm.setRM(ResourceManager.RMINameRooms, rmhotels); // badd(wc); // baddabt(wc); // baddabtrd(wc); // baddcmtrd(wc); // baddcmtrsv(wc); // bstcmt(wc); // bstabt(wc); // bstart(wc); Fdieall(wc); // FunLock(wc); // Lconc(wc); // Saddcmtdelcmt(wc); // Saddrd(wc); // Sbadxid(wc); // sbill(wc); // Sitiabt(wc); // Siticmt(wc); // Sitifail(wc); System.exit(1); }
public static void sbill(WorkflowControllerImpl wc) throws RemoteException, TransactionAbortedException, InvalidTransactionException { int xid = wc.start(); boolean returnVal = wc.addFlight(xid, "347", 100, 310); returnVal = wc.addRooms(xid, "Stanford", 200, 150); returnVal = wc.addCars(xid, "SFO", 300, 30); returnVal = wc.newCustomer(xid, "John"); wc.commit(xid); // printTables(wc); xid = wc.start(); returnVal = wc.reserveFlight(xid, "John", "347"); returnVal = wc.reserveRoom(xid, "John", "Stanford"); returnVal = wc.reserveCar(xid, "John", "SFO"); // returnVal = rm.commit(xid); wc.commit(xid); // printTables(wc); xid = wc.start(); int bill = wc.queryCustomerBill(xid, "John"); System.out.println("Bill for john " + bill); wc.commit(xid); }
public static void Sitifail(WorkflowControllerImpl wc) throws RemoteException, TransactionAbortedException, InvalidTransactionException { int xid = wc.start(); xid = wc.start(); boolean returnValue = wc.addFlight(xid, "347", 100, 310); assert returnValue == true; returnValue = wc.addFlight(xid, "3471", 1001, 3101); assert returnValue == true; returnValue = wc.addRooms(xid, "Stanford", 200, 150); assert returnValue == true; returnValue = wc.addCars(xid, "SFO", 300, 30); assert returnValue == true; returnValue = wc.newCustomer(xid, "John"); assert returnValue == true; wc.commit(xid); xid = wc.start(); returnValue = wc.reserveCar(xid, "John", "SFO"); assert returnValue == true; List<String> FlightList = new ArrayList<String>(); FlightList.add("347"); FlightList.add("3471"); returnValue = wc.reserveItinerary(xid, "John", FlightList, "Stanford", true, true); assert returnValue == false; wc.commit(xid); xid = wc.start(); int flight = wc.queryFlight(xid, "347"); assert flight == 100; int flightPrice = wc.queryFlightPrice(xid, "347"); assert flightPrice == 310; flight = wc.queryFlight(xid, "3471"); assert flight == 1001; flightPrice = wc.queryFlightPrice(xid, "3471"); assert flightPrice == 3101; int noofrooms = wc.queryRooms(xid, "Stanford"); assert noofrooms == 200; int roomsPrice = wc.queryRoomsPrice(xid, "Stanford"); assert roomsPrice == 150; int noofcars = wc.queryCars(xid, "SFO"); assert noofcars == 299; int carsprice = wc.queryCarsPrice(xid, "SFO"); assert carsprice == 30; int customerbill = wc.queryCustomerBill(xid, "John"); assert customerbill == 30; }
public static void Saddrd(WorkflowControllerImpl wc) throws RemoteException, TransactionAbortedException, InvalidTransactionException { int xid = wc.start(); xid = wc.start(); boolean returnValue = wc.addFlight(xid, "347", 100, 310); assert returnValue == true; returnValue = wc.addRooms(xid, "Stanford", 200, 150); assert returnValue == true; returnValue = wc.addCars(xid, "SFO", 300, 30); assert returnValue == true; int flight = wc.queryFlight(xid, "347"); assert flight == 100; int flightPrice = wc.queryFlightPrice(xid, "347"); assert flightPrice == 310; int noofrooms = wc.queryRooms(xid, "Stanford"); assert noofrooms == 200; int roomsPrice = wc.queryRoomsPrice(xid, "Stanford"); assert roomsPrice == 150; int noofcars = wc.queryCars(xid, "SFO"); assert noofcars == 300; int carsprice = wc.queryCarsPrice(xid, "SFO"); assert carsprice == 30; }
public static void Saddcmtdelcmt(WorkflowControllerImpl wc) throws RemoteException, TransactionAbortedException, InvalidTransactionException { int xid = wc.start(); xid = wc.start(); boolean returnValue = wc.addRooms(xid, "Stanford", 200, 150); assert returnValue == true; returnValue = wc.addCars(xid, "SFO", 300, 30); assert returnValue == true; wc.commit(xid); int xid2 = wc.start(); boolean rooms = wc.deleteRooms(xid2, "Stanford", 5); assert rooms == true; boolean cars = wc.deleteCars(xid2, "Stanford", 5); assert cars == true; wc.commit(xid2); int xid3 = wc.start(); int noofrooms = wc.queryRooms(xid3, "Stanford"); assert noofrooms == 195; int noofcars = wc.queryCars(xid3, "Stanford"); assert noofcars == 195; }
public static void bstart(WorkflowControllerImpl wc) throws RemoteException, TransactionAbortedException, InvalidTransactionException { int xid = wc.start(); System.out.println(xid); }
public static void baddcmtrsv(WorkflowControllerImpl wc) throws RemoteException, TransactionAbortedException, InvalidTransactionException { int xid = wc.start(); boolean returnValue = wc.addFlight(xid, "347", 100, 310); assert returnValue == true; returnValue = wc.addRooms(xid, "Stanford", 200, 150); assert returnValue == true; returnValue = wc.addCars(xid, "SFO", 300, 30); assert returnValue == true; returnValue = wc.newCustomer(xid, "John"); assert returnValue == true; wc.commit(xid); int xid2 = wc.start(); int flight = wc.queryFlight(xid2, "347"); assert flight == 100; int flightPrice = wc.queryFlightPrice(xid2, "347"); assert flightPrice == 310; int rooms = wc.queryRooms(xid2, "SFO"); assert rooms == 200; int roomsPrice = wc.queryRoomsPrice(xid2, "SFO"); assert roomsPrice == 150; int cars = wc.queryCars(xid2, "SFO"); assert cars == 300; int carsprice = wc.queryCarsPrice(xid2, "SFO"); assert carsprice == 30; int customerbill = wc.queryCustomerBill(xid2, "John"); assert customerbill == 0; }