tppt.xopen
Class TransactionRecord
java.lang.Object
|
+--tppt.xopen.TransactionRecord
- public class TransactionRecord
- extends java.lang.Object
TransactionRecord
is the data structure used to store the
registered ResourceManager instances for specific Transaction Id.
It then used the HashMap
to map the resource manager id to
the corresponding ResourceManaer.
Each global transaction can contain a number of cohorts(ResourceManager),
and each cohorts should registered properly to the Transaction Manager so that
TransactionManager knew which cohorts to be commit or abort when some transaction
needs to global commit or abort.
Therefore, in your TransactionManager class, you should use TransactionRecord
to register/unregister the ResourceManager for specified transaction.
- Version:
- 2.0
- Author:
- Jodie Wu
- See Also:
HashMap
,
ResourceManager
Field Summary |
private java.util.HashMap |
map
store the ResourceManager id as key and the instance as value |
private int |
tid
Transaction id |
Constructor Summary |
TransactionRecord(int id)
Construct the TransactionRecord with the trainsaction id |
Method Summary |
java.util.Iterator |
getAllRMs()
Obtains all the Registered ResourceManager for this transaction id. |
boolean |
regsiterRM(ResourceManager rm)
Register the ResourceManager. |
boolean |
unregisterRM(int rid)
Unregister the ResourceManager |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
tid
private int tid
- Transaction id
map
private java.util.HashMap map
- store the ResourceManager id as key and the instance as value
TransactionRecord
public TransactionRecord(int id)
- Construct the TransactionRecord with the trainsaction id
- Parameters:
id
- Transaction Id
regsiterRM
public boolean regsiterRM(ResourceManager rm)
- Register the ResourceManager.
- Parameters:
rm
- ResourceManager to be registered- Returns:
- true if register sucessfully; false if the key already exists in the map.
unregisterRM
public boolean unregisterRM(int rid)
- Unregister the ResourceManager
- Parameters:
rid
- ResourceManager to be unregistered.- Returns:
- true if unregister sucessfully; false if the key does not exists.
getAllRMs
public java.util.Iterator getAllRMs()
- Obtains all the Registered ResourceManager for this transaction id.
- Returns:
- A Iterator object that contains all the registered ResourceManager.