Esempio n. 1
0
 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"));
 }
Esempio n. 2
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);
 }
Esempio n. 3
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);
 }
Esempio n. 4
0
  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);
  }
Esempio n. 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);
  }
Esempio n. 6
0
  public static void Saddcmtdelrsv(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.deleteFlight(xid, "347");
    rm.deleteRooms(xid, "Stanford", 200);
    rm.deleteCars(xid, "SFO", 300);

    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);
  }
Esempio n. 7
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);
  }
Esempio n. 8
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);
  }