예제 #1
0
  public static void Stoomanyrsv(ResourceManagerImpl rm)
      throws RemoteException, TransactionAbortedException, InvalidTransactionException {
    int xid = rm.start();
    rm.addFlight(xid, "347", 1, 310);
    rm.addRooms(xid, "Stanford", 1, 150);
    rm.addCars(xid, "SFO", 1, 30);
    rm.newCustomer(xid, "John");
    rm.newCustomer(xid, "Bob");
    rm.commit(xid);
    // printTables(rm);

    xid = rm.start();
    boolean returnVal = rm.reserveFlight(xid, "John", "347");
    returnVal = rm.reserveRoom(xid, "John", "Stanford");
    returnVal = rm.reserveCar(xid, "John", "SFO");
    returnVal = rm.commit(xid);
    // printTables(rm);

    xid = rm.start();
    returnVal = rm.reserveFlight(xid, "Bob", "347");
    returnVal = rm.reserveRoom(xid, "Bob", "Stanford");
    returnVal = rm.reserveCar(xid, "Bob", "SFO");
    returnVal = rm.commit(xid);
    rm.commit(xid);
    // printTables(rm);

  }
예제 #2
0
  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);
  }
예제 #3
0
  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);
  }
예제 #4
0
 public static void deleteItems(ResourceManagerImpl rm)
     throws RemoteException, TransactionAbortedException, InvalidTransactionException {
   int xid = rm.start();
   rm.deleteFlight(xid, "4");
   // rm.deleteCustomer(xid, "Joe");
   rm.commit(xid);
 }
예제 #5
0
  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);
  }
예제 #6
0
 public static void printCustomerBills(ResourceManagerImpl rm)
     throws RemoteException, TransactionAbortedException, InvalidTransactionException {
   int xid = rm.start();
   for (String cust : customers) {
     int bill = rm.queryCustomerBill(xid, cust);
     System.out.println("Bill for " + cust + " : " + bill);
   }
   int bill = rm.queryCustomerBill(xid, "Joe");
   System.out.println("Bill for " + "Joe" + " : " + bill);
   rm.commit(xid);
 }