|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecttp.impl.CSEP545ServiceObject
tp.impl.MyRM
public class MyRM
Your Resource Manager. Rudimentary implementation is provided for your convenience.
CSEP545ServiceObject.main(String[]).
-x or --selfdestruct numio:
Set the self destruction timer on this RM. If this argument is given,
the RM MUST call System.exit() immediately after numio disk operations.
(default: 0. no self destruction)-t or --timeout s:
Set deadlock detection timeout to s seconds.
(default: LM.DEFAULT_DEADLOCK_TIMEOUT)
CSEP545ServiceObject| 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 | |
|---|---|
MyRM()
|
|
| Method Summary | |
|---|---|
void |
abort(Transaction xid)
abort transaction |
boolean |
add(Transaction xid,
RID i,
int count,
int price)
add qty items described by resource. |
void |
commit(Transaction xid)
commit transaction |
boolean |
delete(Transaction xid,
RID rid)
Drop resource from this RM. |
boolean |
delete(Transaction xid,
RID i,
int count)
Remove exactly qty unreserved resource from this RM. |
String |
getName()
get the name of this RM |
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. |
Customer[] |
listCustomers(Transaction context)
list of customers who reserve resources managed by this RM |
String[] |
listResources(Transaction context,
RID.Type type)
list of resources |
int |
query(Transaction xid,
RID rid)
query: equivalent to queryCars, queryFlights, queryRooms |
int |
queryPrice(Transaction xid,
RID i)
query: equivalent to queryCarsPrice, queryFlightsPrice, queryRoomsPrice |
String |
queryReserved(Transaction context,
Customer customer)
Get the bill for the customer
return a string representation of reservations |
int |
queryReservedPrice(Transaction context,
Customer customer)
Get the total amount of money the customer owes
in this RM. |
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()
Refresh all remote references used by this service. |
boolean |
reserve(Transaction context,
Customer c,
RID i)
reserve a resource i on behalf of customer c |
void |
selfDestruct(int diskWritesToWait)
Exit (simulate a failure) after a specified number of disk writes. |
void |
shutdown()
Gracefully shutdown target service. |
protected void |
startUp()
IMPLEMENT THIS METHOD If you use extra threads in your service, start them in this method. |
void |
unreserve(Transaction context,
Customer c)
drop all reserved resources for customer customer |
| Methods inherited from class tp.impl.CSEP545ServiceObject |
|---|
getDataRoot, getServiceID, kill, lookupRemote, lookupRemote, lookupRemote, lookupRemote, main |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MyRM()
| Method Detail |
|---|
public void commit(Transaction xid)
throws InvalidTransactionException,
TransactionAbortedException,
RemoteException
RM
commit in interface RMxid - transaction identifier
InvalidTransactionException
TransactionAbortedException
RemoteException
public void abort(Transaction xid)
throws RemoteException
RM
abort in interface RMxid - transaction identifier
RemoteException
public boolean add(Transaction xid,
RID i,
int count,
int price)
throws TransactionAbortedException,
InvalidTransactionException,
RemoteException
RMqty items described by resource.
If resource does not exist in the RM, create a new one.
add in interface RMxid - transaction identifieri - resource identifiercount - quantity (seats, cars, rooms)price - price per unit
true on success. false otherwise
TransactionAbortedException
InvalidTransactionException
RemoteExceptionWC.addSeats(Transaction, String, int, int),
WC.addCars(Transaction, String, int, int),
WC.addRooms(Transaction, String, int, int)
public boolean delete(Transaction xid,
RID rid)
throws TransactionAbortedException,
InvalidTransactionException,
RemoteException
RMresource from this RM.
All reservations on resource must be dropped as well.
delete in interface RMxid - transaction identifierrid - resource identifier
TransactionAbortedException
InvalidTransactionException
RemoteExceptionWC.deleteFlight(Transaction, String)
public boolean delete(Transaction xid,
RID i,
int count)
throws TransactionAbortedException,
InvalidTransactionException,
RemoteException
RMqty unreserved resource from this RM.
delete in interface RMxid - transaction identifieri - resource identifiercount - number of resource to remove. -1 removes all remaining
true on successful deletion.
If there is no such resource, return true.
false otherwise.
If there are not enough qty to remove, return false.
TransactionAbortedException
InvalidTransactionException
RemoteExceptionWC.deleteSeats(Transaction, String, int),
WC.deleteCars(Transaction, String, int),
WC.deleteRooms(Transaction, String, int)
public int query(Transaction xid,
RID rid)
throws TransactionAbortedException,
InvalidTransactionException,
RemoteException
RM
query in interface RMxid - transaction identifierrid - resource identifier
TransactionAbortedException
InvalidTransactionException
RemoteExceptionWC.queryCar(Transaction, String),
WC.queryRoom(Transaction, String),
WC.queryFlight(Transaction, String)
public int queryPrice(Transaction xid,
RID i)
throws TransactionAbortedException,
InvalidTransactionException,
RemoteException
RM
queryPrice in interface RMxid - transaction identifieri - resource identifier
resource
TransactionAbortedException
InvalidTransactionException
RemoteExceptionWC.queryCarPrice(Transaction, String),
WC.queryRoomPrice(Transaction, String),
WC.queryFlightPrice(Transaction, String)
public String queryReserved(Transaction context,
Customer customer)
throws TransactionAbortedException,
InvalidTransactionException,
RemoteException
RMcustomer
return a string representation of reservations
queryReserved in interface RMcontext - the transaction IDcustomer - the customer ID
TransactionAbortedException
InvalidTransactionException
RemoteExceptionWC.queryItinerary(Transaction, Customer)
public int queryReservedPrice(Transaction context,
Customer customer)
throws TransactionAbortedException,
InvalidTransactionException,
RemoteException
RMcustomer owes
in this RM.
queryReservedPrice in interface RMcontext - the transaction IDcustomer - the customer ID
TransactionAbortedException
InvalidTransactionException
RemoteExceptionWC.queryItineraryPrice(Transaction, Customer)
public boolean reserve(Transaction context,
Customer c,
RID i)
throws TransactionAbortedException,
InvalidTransactionException,
RemoteException
RMi on behalf of customer c
reserve in interface RMcontext - the transaction IDc - the customer IDi - resource to reserve
true on successful reservation. false otherwise.
TransactionAbortedException
InvalidTransactionException
RemoteExceptionWC.reserveItinerary(Customer, String[], String, boolean, boolean)
public void unreserve(Transaction context,
Customer c)
throws TransactionAbortedException,
InvalidTransactionException,
RemoteException
RMcustomer
unreserve in interface RMcontext - the transaction IDc - the customer ID
TransactionAbortedException
InvalidTransactionException
RemoteExceptionWC.cancelItinerary(Customer)
public String[] listResources(Transaction context,
RID.Type type)
throws TransactionAbortedException,
InvalidTransactionException,
RemoteException
RM
listResources in interface RMtype - listing resource type
resource name ',' available quantity ',' price
TransactionAbortedException
InvalidTransactionException
RemoteExceptionWC.listCars(Transaction),
WC.listFlights(Transaction),
WC.listRooms(Transaction)
public Customer[] listCustomers(Transaction context)
throws TransactionAbortedException,
InvalidTransactionException,
RemoteException
RM
listCustomers in interface RMcontext - the transaction ID
TransactionAbortedException
InvalidTransactionException
RemoteExceptionWC.listCustomers(Transaction)
public void shutdown()
throws RemoteException
CSEP545ServiceRegistry.unbind(String)
shutdown in interface CSEP545Serviceshutdown in class CSEP545ServiceObjectRemoteExceptionRegistry.unbind(String)
public void selfDestruct(int diskWritesToWait)
throws RemoteException
RM
selfDestruct in interface RMdiskWritesToWait - number of disk writes to wait until terminate
RemoteException
public String getName()
throws RemoteException
RM
getName in interface RMRemoteException
protected void init(String[] args)
throws Exception
CSEP545ServiceObject
init in class CSEP545ServiceObjectargs - command line arguments except common arguments
ExceptionselfDestruct(int) here
protected void initStorage()
throws Exception
CSEP545ServiceObjectRM
and commit log file for TM
initStorage in class CSEP545ServiceObjectException
protected void recovery()
throws Exception
CSEP545ServiceObject
recovery in class CSEP545ServiceObjectException
protected void startUp()
throws Exception
CSEP545ServiceObject
startUp in class CSEP545ServiceObjectException
protected void readyToServe()
throws Exception
CSEP545ServiceObject
readyToServe in class CSEP545ServiceObjectException
public void refresh()
throws RemoteException,
NotBoundException
CSEP545Service
refresh in interface CSEP545ServiceRemoteException
NotBoundException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||