public static void LdeadLock(ResourceManagerImpl rm) throws RemoteException, TransactionAbortedException, InvalidTransactionException { int xid = rm.start(); rm.addFlight(xid, "347", 100, 310); rm.addRooms(xid, "Stanford", 200, 150); rm.addCars(xid, "SFO", 300, 30); rm.newCustomer(xid, "John"); rm.commit(xid); xid = rm.start(); int xid2 = rm.start(); rm.addFlight(xid2, "347", 100, 620); rm.addRooms(xid, "Stanford", 200, 300); try { rm.queryRooms(xid2, "Stanford"); } catch (TransactionAbortedException e) { System.out.println("Caught deadlock"); } rm.commit(xid); // printTables(rm); xid = rm.start(); int value = rm.queryFlight(xid, "347"); System.out.println(value); value = rm.queryFlightPrice(xid, "347"); System.out.println(value); value = rm.queryRooms(xid, "Stanford"); System.out.println(value); value = rm.queryRoomsPrice(xid, "Stanford"); System.out.println(value); }
public static void queryCheck(ResourceManagerImpl rm) throws RemoteException, TransactionAbortedException, InvalidTransactionException { int xid = rm.start(); System.out.println(rm.queryFlight(xid, "1")); System.out.println(rm.queryCars(xid, "a")); System.out.println(rm.queryRooms(xid, "A")); }
public static void Baddcmtrd(ResourceManagerImpl rm) throws RemoteException, TransactionAbortedException, InvalidTransactionException { int xid = rm.start(); rm.addFlight(xid, "347", 100, 310); rm.addRooms(xid, "Stanford", 200, 150); rm.addCars(xid, "SFO", 300, 30); rm.newCustomer(xid, "John"); rm.commit(xid); // printTables(rm); xid = rm.start(); int avail = rm.queryFlight(xid, "347"); System.out.println(avail); avail = rm.queryFlightPrice(xid, "347"); System.out.println(avail); avail = rm.queryRooms(xid, "Stanford"); System.out.println(avail); avail = rm.queryRoomsPrice(xid, "Stanford"); System.out.println(avail); avail = rm.queryCars(xid, "SFO"); System.out.println(avail); avail = rm.queryCarsPrice(xid, "SFO"); System.out.println(avail); avail = rm.queryCustomerBill(xid, "John"); System.out.println(avail); }
public static void Fdieb4self(ResourceManagerImpl rm) throws RemoteException, TransactionAbortedException, InvalidTransactionException { int xid = rm.start(); rm.addFlight(xid, "347", 100, 310); rm.addRooms(xid, "Stanford", 200, 150); rm.addCars(xid, "SFO", 300, 30); rm.newCustomer(xid, "John"); rm.commit(xid); xid = rm.start(); rm.addFlight(xid, "347", 100, 620); rm.addRooms(xid, "Stanford", 200, 300); rm.addCars(xid, "SFO", 300, 60); rm.dieBeforePointerSwitch(); try { rm.commit(xid); } catch (RemoteException e) { System.out.println("Caught remote exception"); } xid = rm.start(); int value = rm.queryFlight(xid, "347"); System.out.println(value); value = rm.queryFlightPrice(xid, "347"); System.out.println(value); value = rm.queryRooms(xid, "Stanford"); System.out.println(value); value = rm.queryRoomsPrice(xid, "Stanford"); System.out.println(value); }