コード例 #1
0
  public static void Baddabtrd(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();
    rm.addFlight(xid, "347", 100, 310);
    rm.addRooms(xid, "Stanford", 200, 150);
    rm.addCars(xid, "SFO", 300, 30);
    rm.abort(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);
  }
コード例 #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 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);

  }