|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IResourceManager
/** Interface for a simple Resource Manager for the Distributed Travel Reservation System. A single resource manager can be used to manage arbitrary resources, e.g. hotels, rental cars or flights.
Failure reporting is done using two pieces, exceptions and return values. Exceptions are used for systemy things - like transactions that were forced to abort, or don't exist. Return values are used for operations that would affect the consistency of the database, like the reservation of a data item that the database does not know about.
If there is a return value and you're not sure how it would be used in your implementation, ignore it. Return values in the interface are used generously to allow flexibility in implementation.
Field Summary | |
---|---|
static java.lang.String |
RMI_NAME_CAR_RM
|
static java.lang.String |
RMI_NAME_FLIGHT_RM
|
static java.lang.String |
RMI_NAME_HOTEL_RM
|
Method Summary | |
---|---|
void |
abort(int xid)
Abort transaction. |
boolean |
addResource(int xid,
java.lang.String rid,
int num,
int price)
Add a new resource (e.g. hotel) to the database. |
int |
begin()
Deprecated. Only distributed transaction should by allowed from now on. Begin a new local transaction, and return its transaction id. |
boolean |
beginDistributed(int globalXID)
Begin a new distributed transaction. |
boolean |
commit(int xid)
Commit transaction. |
void |
dieAfterPointerSwitch()
Closes ResourceManager by calling System.exit(-1) right after switching the pointer to the shadow copy file. |
void |
dieBeforePointerSwitch()
Closes ResourceManager by calling System.exit(-1) right before switching the pointer to the shadow copy file. |
void |
dieNow()
immediately closes the ResourceManager by calling System.exit(-1) |
boolean |
newCustomer(int xid,
java.lang.String custName)
Add a new customer to the database. |
boolean |
prepare(int globalXID)
This method is part of the 2PC protocol for atomic committment of distributed transactions. |
int |
queryCustomerBill(int xid,
java.lang.String custName)
Query the bill of a customer. |
int |
queryResourceAvailability(int xid,
java.lang.String rid)
Query the availability of a resource. |
int |
queryResourcePrice(int xid,
java.lang.String rid)
Query the price of a resource. |
boolean |
reserveResource(int xid,
java.lang.String rid,
java.lang.String custName)
Reserve a resource for a given customer. |
boolean |
shutdown()
Shutdown gracefully. |
void |
start(java.lang.String workingdir,
java.lang.String rmiName)
|
boolean |
updateResource(int xid,
java.lang.String rid,
int num,
int price)
Update the attributes (total capacity and price) of a resource. |
Field Detail |
---|
static final java.lang.String RMI_NAME_HOTEL_RM
static final java.lang.String RMI_NAME_FLIGHT_RM
static final java.lang.String RMI_NAME_CAR_RM
Method Detail |
---|
void start(java.lang.String workingdir, java.lang.String rmiName) throws java.rmi.RemoteException
java.rmi.RemoteException
int begin() throws ShutdownException, java.rmi.RemoteException
ShutdownException
- thrown if no new transactions can be accepted
due to shutdown of the resource manager
java.rmi.RemoteException
boolean beginDistributed(int globalXID) throws ShutdownException, java.rmi.RemoteException, InvalidTransactionException
globalXID
- the id of the distributed transaction which
will be the parent of this local subtransaction. Use this id to
enlist this RM at the transaction manager.
ShutdownException
- thrown if no new transactions can be accepted
due to shutdown of the resource manager
InvalidTransactionException
- if a distributed transaction with
this globalXID has already been started at this RM
java.rmi.RemoteException
boolean prepare(int globalXID) throws InvalidTransactionException, java.rmi.RemoteException
globalXID
- the transaction ID of the distributed transaction
which needs to be prepared for commitment
InvalidTransactionException
java.rmi.RemoteException
boolean commit(int xid) throws TransactionAbortedException, InvalidTransactionException, java.rmi.RemoteException
xid
- id of transaction to be committed.
TransactionAbortedException
- if transaction was aborted.
InvalidTransactionException
- if transaction id is invalid.
java.rmi.RemoteException
void abort(int xid) throws InvalidTransactionException, java.rmi.RemoteException
xid
- id of transaction to be aborted.
InvalidTransactionException
- if transaction id is invalid.
java.rmi.RemoteException
boolean newCustomer(int xid, java.lang.String custName) throws TransactionAbortedException, InvalidTransactionException, java.rmi.RemoteException
xid
- the id of the transaction requesting this operationcustName
- the unique customer name
TransactionAbortedException
- if transaction was aborted.
InvalidTransactionException
- if transaction id is invalid.
java.rmi.RemoteException
int queryCustomerBill(int xid, java.lang.String custName) throws TransactionAbortedException, InvalidTransactionException, java.rmi.RemoteException
xid
- the id of the transaction requesting this operationcustName
- the unique customer name whose bill should be calculated
TransactionAbortedException
- if transaction was aborted.
InvalidTransactionException
- if transaction id is invalid.
java.rmi.RemoteException
boolean addResource(int xid, java.lang.String rid, int num, int price) throws TransactionAbortedException, InvalidTransactionException, java.rmi.RemoteException
xid
- the id of the transaction requesting this operationrid
- the unique identifier of the resource which is to be added (e.g. HotelA)num
- the total capacity of this resourceprice
- the price a customer needs to pay for reserving this resource
TransactionAbortedException
- if transaction was aborted.
InvalidTransactionException
- if transaction id is invalid.
java.rmi.RemoteException
boolean updateResource(int xid, java.lang.String rid, int num, int price) throws TransactionAbortedException, InvalidTransactionException, java.rmi.RemoteException
xid
- the id of the transaction requesting this operationrid
- the unique identifier of the resource which is to be added (e.g. HotelA)num
- a number indicating the change in total capacity, negative numbers decrease
capacity, positive values increase capacityprice
- the price a customer needs to pay for reserving this resource
TransactionAbortedException
- if transaction was aborted.
InvalidTransactionException
- if transaction id is invalid.
java.rmi.RemoteException
int queryResourceAvailability(int xid, java.lang.String rid) throws TransactionAbortedException, InvalidTransactionException, java.rmi.RemoteException
xid
- the id of the transaction requesting this operationrid
- the unique identifier of the resource
TransactionAbortedException
- if transaction was aborted.
InvalidTransactionException
- if transaction id is invalid.
java.rmi.RemoteException
int queryResourcePrice(int xid, java.lang.String rid) throws TransactionAbortedException, InvalidTransactionException, java.rmi.RemoteException
xid
- the id of the transaction requesting this operationrid
- the unique identifier of the resource
TransactionAbortedException
- if transaction was aborted.
InvalidTransactionException
- if transaction id is invalid.
java.rmi.RemoteException
boolean reserveResource(int xid, java.lang.String rid, java.lang.String custName) throws TransactionAbortedException, InvalidTransactionException, java.rmi.RemoteException
xid
- the id of the transaction requesting this operationrid
- the unique identifier of the resourcecustName
- the unique name of the customer
TransactionAbortedException
- if transaction was aborted.
InvalidTransactionException
- if transaction id is invalid.
java.rmi.RemoteException
boolean shutdown() throws java.rmi.RemoteException
java.rmi.RemoteException
void dieNow() throws java.rmi.RemoteException
java.rmi.RemoteException
void dieBeforePointerSwitch() throws java.rmi.RemoteException
java.rmi.RemoteException
void dieAfterPointerSwitch() throws java.rmi.RemoteException
java.rmi.RemoteException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |