|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object tp.impl.CSEP545ServiceObject tp.impl.MyWC
public class MyWC
Your Workflow Controller. Rudimentary implementation is provided for your convenience.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface tp.impl.CSEP545Service |
---|
CSEP545Service.Type |
Field Summary |
---|
Fields inherited from class tp.impl.CSEP545ServiceObject |
---|
dir, registry, svcid |
Constructor Summary | |
---|---|
MyWC()
|
Method Summary | |
---|---|
void |
abort(Transaction context)
Abort a transaction |
boolean |
addCars(Transaction context,
String location,
int numCars,
int price)
Add cars to a location. |
boolean |
addRooms(Transaction context,
String location,
int numRooms,
int price)
Add rooms to a location. |
boolean |
addSeats(Transaction context,
String flight,
int flightSeats,
int flightPrice)
Add seats to a flight This method will be used to create a new flight but if the flight already exists, seats will be added and the price overwritten |
boolean |
cancelItinerary(Customer customer)
Cancel an itinerary owned by customer |
void |
commit(Transaction context)
Commit a transaction |
boolean |
deleteCars(Transaction context,
String location,
int numCars)
Delete cars. |
boolean |
deleteFlight(Transaction context,
String flight)
Delete the entire flight. |
boolean |
deleteRooms(Transaction context,
String location,
int numRooms)
Delete rooms. |
boolean |
deleteSeats(Transaction context,
String flight,
int numSeats)
delete seats from a flight |
protected void |
init(String[] args)
IMPLEMENT THIS METHOD process command line parameters and setup any parameterized values. |
protected void |
initStorage()
IMPLEMENT THIS METHOD Initialize necessary data files. |
String[] |
listCars(Transaction context)
list existing cars |
Customer[] |
listCustomers(Transaction context)
list existing customers that have itinerary |
String[] |
listFlights(Transaction context)
list existing flights |
String[] |
listRooms(Transaction context)
list existing rooms |
int |
queryCar(Transaction context,
String location)
Get the number of cars available. |
int |
queryCarPrice(Transaction context,
String location)
Get the cars price. |
int |
queryFlight(Transaction context,
String flight)
Get the number of seats available. |
int |
queryFlightPrice(Transaction context,
String flight)
Get the flight price. |
String |
queryItinerary(Transaction context,
Customer customer)
Get the bill for the customer |
int |
queryItineraryPrice(Transaction context,
Customer customer)
Get the total amount of money the customer owes |
int |
queryRoom(Transaction context,
String location)
Get the number of rooms available. |
int |
queryRoomPrice(Transaction context,
String location)
Get the room price. |
protected void |
readyToServe()
IMPLEMENT THIS METHOD Bootstrapping completed and the server is up and running. |
protected void |
recovery()
IMPLEMENT THIS METHOD Run recovery algorithm and reconstruct the state of service before failure. |
void |
refresh()
IMPLEMENT THIS METHOD if you want to implement a different service architecture. |
boolean |
reserveItinerary(Customer customer,
String[] flights,
String location,
boolean car,
boolean room)
Reserve an itinerary |
Transaction |
start()
Start a transaction return a unique transaction ID |
protected void |
startUp()
IMPLEMENT THIS METHOD If you use extra threads in your service, start them in this method. |
Methods inherited from class tp.impl.CSEP545ServiceObject |
---|
getDataRoot, getServiceID, kill, lookupRemote, lookupRemote, lookupRemote, lookupRemote, main, shutdown |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MyWC()
Method Detail |
---|
public boolean reserveItinerary(Customer customer, String[] flights, String location, boolean car, boolean room) throws RemoteException
WC
reserveItinerary
in interface WC
customer
- the customerflights
- an integer array of flight numberslocation
- travel locationcar
- true if car reservation is neededroom
- true if a room reservation is needed
true
on success, false
otherwise.
RemoteException
RM.reserve(Transaction, Customer, RID)
public boolean cancelItinerary(Customer customer) throws RemoteException
WC
customer
cancelItinerary
in interface WC
customer
- the customer
true
on success, false
otherwise.
RemoteException
RM.unreserve(Transaction, Customer)
public int queryItineraryPrice(Transaction context, Customer customer) throws RemoteException, TransactionAbortedException, InvalidTransactionException
WC
customer
owes
queryItineraryPrice
in interface WC
context
- the transaction IDcustomer
- the customer ID
RemoteException
TransactionAbortedException
InvalidTransactionException
RM.queryReserved(Transaction, Customer)
public String queryItinerary(Transaction context, Customer customer) throws RemoteException, TransactionAbortedException, InvalidTransactionException
WC
customer
queryItinerary
in interface WC
context
- the transaction IDcustomer
- the customer ID
RemoteException
TransactionAbortedException
InvalidTransactionException
RM.queryReserved(Transaction, Customer)
public boolean addSeats(Transaction context, String flight, int flightSeats, int flightPrice) throws RemoteException, TransactionAbortedException, InvalidTransactionException
WC
addSeats
in interface WC
context
- the transaction IDflight
- a flight numberflightSeats
- the number of flight SeatsflightPrice
- price per seat
true
on success, false
otherwise.
RemoteException
TransactionAbortedException
InvalidTransactionException
RM.add(Transaction, RID, int, int)
public boolean deleteSeats(Transaction context, String flight, int numSeats) throws RemoteException, TransactionAbortedException, InvalidTransactionException
WC
flight
deleteSeats
in interface WC
context
- the transaction IDflight
- a flight numbernumSeats
- the number of flight Seats
true
on success, false
otherwise.
RemoteException
TransactionAbortedException
InvalidTransactionException
RM.delete(Transaction,RID,int)
public boolean deleteFlight(Transaction context, String flight) throws RemoteException, TransactionAbortedException, InvalidTransactionException
WC
deleteFlight
in interface WC
context
- the transaction IDflight
- the flight number
true
on success, false
otherwise.
RemoteException
TransactionAbortedException
InvalidTransactionException
RM.delete(Transaction,RID)
public boolean addRooms(Transaction context, String location, int numRooms, int price) throws RemoteException, TransactionAbortedException, InvalidTransactionException
WC
addRooms
in interface WC
context
- the transaction IDlocation
- the location to add roomsnumRooms
- number of rooms to addprice
- room price
true
on success, false
otherwise.
RemoteException
TransactionAbortedException
InvalidTransactionException
RM.add(Transaction, RID, int, int)
public boolean deleteRooms(Transaction context, String location, int numRooms) throws RemoteException, TransactionAbortedException, InvalidTransactionException
WC
deleteRooms
in interface WC
context
- the transaction IDlocation
- the location to add roomsnumRooms
- the number of rooms to delete
true
on success, false
otherwise.
RemoteException
TransactionAbortedException
InvalidTransactionException
RM.delete(Transaction,RID,int)
public boolean addCars(Transaction context, String location, int numCars, int price) throws RemoteException, TransactionAbortedException, InvalidTransactionException
WC
addCars
in interface WC
context
- the transaction IDlocation
- the location to add carsnumCars
- number of cars to addprice
- rental price
true
on success, false
otherwise.
RemoteException
TransactionAbortedException
InvalidTransactionException
RM.add(Transaction, RID, int, int)
public boolean deleteCars(Transaction context, String location, int numCars) throws RemoteException, TransactionAbortedException, InvalidTransactionException
WC
deleteCars
in interface WC
context
- the transaction IDlocation
- the location to add carsnumCars
- the number of cars to delete
true
on success, false
otherwise.
RemoteException
TransactionAbortedException
InvalidTransactionException
RM.delete(Transaction,RID,int)
public int queryFlight(Transaction context, String flight) throws RemoteException, TransactionAbortedException, InvalidTransactionException
WC
queryFlight
in interface WC
context
- the transaction IDflight
- the flight number
RemoteException
TransactionAbortedException
InvalidTransactionException
RM.query(Transaction, RID)
public int queryFlightPrice(Transaction context, String flight) throws RemoteException, TransactionAbortedException, InvalidTransactionException
WC
queryFlightPrice
in interface WC
context
- the transaction IDflight
- the flight number
RemoteException
TransactionAbortedException
InvalidTransactionException
RM.queryPrice(Transaction, RID)
public int queryRoom(Transaction context, String location) throws RemoteException, TransactionAbortedException, InvalidTransactionException
WC
queryRoom
in interface WC
context
- the transaction IDlocation
- the rooms location
RemoteException
TransactionAbortedException
InvalidTransactionException
RM.query(Transaction, RID)
public int queryRoomPrice(Transaction context, String location) throws RemoteException, TransactionAbortedException, InvalidTransactionException
WC
queryRoomPrice
in interface WC
context
- the transaction IDlocation
- the rooms location
RemoteException
TransactionAbortedException
InvalidTransactionException
RM.queryPrice(Transaction, RID)
public int queryCar(Transaction context, String location) throws RemoteException, TransactionAbortedException, InvalidTransactionException
WC
queryCar
in interface WC
context
- the transaction IDlocation
- the cars location
RemoteException
TransactionAbortedException
InvalidTransactionException
RM.query(Transaction, RID)
public int queryCarPrice(Transaction context, String location) throws RemoteException, TransactionAbortedException, InvalidTransactionException
WC
queryCarPrice
in interface WC
context
- the transaction IDlocation
- the cars location
RemoteException
TransactionAbortedException
InvalidTransactionException
RM.queryPrice(Transaction, RID)
public String[] listFlights(Transaction context) throws RemoteException, TransactionAbortedException, InvalidTransactionException
WC
listFlights
in interface WC
context
- transaction id
RemoteException
TransactionAbortedException
InvalidTransactionException
WC.addSeats(Transaction, String, int, int)
,
RM.listResources(Transaction, RID.Type)
public String[] listCars(Transaction context) throws RemoteException, TransactionAbortedException, InvalidTransactionException
WC
listCars
in interface WC
context
- transaction id
RemoteException
TransactionAbortedException
InvalidTransactionException
WC.addCars(Transaction, String, int, int)
,
RM.listResources(Transaction, RID.Type)
public String[] listRooms(Transaction context) throws RemoteException, TransactionAbortedException, InvalidTransactionException
WC
listRooms
in interface WC
context
- transaction id
RemoteException
TransactionAbortedException
InvalidTransactionException
WC.addRooms(Transaction, String, int, int)
,
RM.listResources(Transaction, RID.Type)
public Customer[] listCustomers(Transaction context) throws RemoteException, TransactionAbortedException, InvalidTransactionException
WC
listCustomers
in interface WC
context
- transaction id
RemoteException
TransactionAbortedException
InvalidTransactionException
WC.reserveItinerary(Customer, String[], String, boolean, boolean)
,
RM.listCustomers(Transaction)
public Transaction start() throws RemoteException
WC
start
in interface WC
RemoteException
public void commit(Transaction context) throws RemoteException, InvalidTransactionException, TransactionAbortedException
WC
commit
in interface WC
context
- the transaction ID
RemoteException
InvalidTransactionException
TransactionAbortedException
public void abort(Transaction context) throws RemoteException, InvalidTransactionException
WC
abort
in interface WC
context
- the transaction ID
RemoteException
InvalidTransactionException
protected void init(String[] args) throws Exception
CSEP545ServiceObject
init
in class CSEP545ServiceObject
args
- command line arguments except common arguments
Exception
protected void initStorage() throws Exception
CSEP545ServiceObject
RM
and commit log file for TM
initStorage
in class CSEP545ServiceObject
Exception
protected void recovery() throws Exception
CSEP545ServiceObject
recovery
in class CSEP545ServiceObject
Exception
protected void startUp() throws Exception
CSEP545ServiceObject
startUp
in class CSEP545ServiceObject
Exception
protected void readyToServe() throws Exception
CSEP545ServiceObject
readyToServe
in class CSEP545ServiceObject
Exception
public void refresh() throws RemoteException, NotBoundException
refresh
in interface CSEP545Service
RemoteException
NotBoundException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |