|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.j_spaces.core.client.LocalTransactionManager
public class LocalTransactionManager
A Local Transaction Manager acts as a Transaction Manager for transactions that span a single space instance. It has several advantages over a standard distributed transaction manager:
JavaSpace space = ... // get instance to a GigaSpaces space instance
TransactionManager tm = LocalTransactionManager.getInstance((IJSpace) space);
Transaction tr = ... // obtain transaction through TransactionFactory
space.write(entry, tr, Lease.FOREVER);
...
tr.commit();
tr = ... // obtain transaction through TransactionFactory
space.take(entry, tr, JavaSpace.NO_WAIT);
...
tr.commit();
It is important to note that all operations inside a local transaction must
be directed to the same space instance - the space instance that was given to
the LocalTransactionManager.getInstance( space ).
TransactionManager
.
The Jini Transaction manager is mainly used with partitioned space.
TransactionManager tm = (TransactionManager)LookupFinder.find(
null, // service name
new Class[] { net.jini.core.transaction.server.TransactionManager.class },
null, // service attributes
"localhost", // unicast lookup host
null, // lookup groups
10*1000 // timeout 10 seconds
);
Transaction.Created tCreated =TransactionFactory.create(trManager, 1000 * 60);
Transaction tr = tCreated.transaction;
See http://www.gigaspaces.com/wiki/display/GS/Jini+Transaction+Manager for more information.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface net.jini.core.transaction.server.TransactionManager |
---|
TransactionManager.Created |
Field Summary |
---|
Fields inherited from interface net.jini.core.transaction.server.TransactionConstants |
---|
ABORTED, ACTIVE, COMMITTED, NOTCHANGED, PREPARED, VOTING |
Constructor Summary | |
---|---|
LocalTransactionManager(IJSpace spaceProxy)
Deprecated. Use getInstance(com.j_spaces.map.IMap) instead |
Method Summary | |
---|---|
void |
abort(long id)
|
void |
abort(long id,
long waitFor)
|
long |
checkActiveAndGetTimeLimt(long xtnId)
This API is called from the proxy when a transaction is used in order to verify if the transaction is alive. |
long |
checkActiveAndGetTimeLimt(Object xtnId)
This API is called from the proxy when a transaction is used in order to verify if the transaction is alive. |
void |
commit(long xtnID)
|
void |
commit(long xtnID,
long waitFor)
|
TransactionManager.Created |
create(long lease)
|
void |
destroy()
Destroy the LocalTransactionManager instance, including its context to the space. |
boolean |
equals(Object o)
Equality between two LocalTransactionManager instances. |
static TransactionManager |
getInstance(IJSpace space)
Returns single instance of LocalTransactionManager per space. |
static TransactionManager |
getInstance(IMap map)
Returns single instance of LocalTransactionManager per map. |
String |
getManagerID()
Gets the Manager Id. |
IJSpace |
getProxy()
|
int |
getState(long id)
|
int |
getState(Object id)
Get the transaction state. |
int |
hashCode()
|
boolean |
isActiveTransaction(Object id)
|
void |
join(long id,
TransactionParticipant part,
long crashCount)
|
Xid[] |
recover()
Create Xids array of all the prepared transactions. |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
@Deprecated public LocalTransactionManager(IJSpace spaceProxy) throws RemoteException
getInstance(com.j_spaces.map.IMap)
instead
spaceProxy
- The space proxy.
RemoteException
- Failed to initialize LocalTransactionManager.Method Detail |
---|
public static TransactionManager getInstance(IMap map) throws RemoteException
<b>Usage:</b>
TransactionManager localTxnManager = LocalTransactionManager( (IMap)map );
Transaction.Created tCreated = TransactionFactory.create(localTxnManager, 60000);
Transaction tr = tCreated.transaction;
map
- The IMap implementation.
RemoteException
- Failed to initialize LocalTransactionManager, or if the passed
space proxy is null.TransactionManager
public static TransactionManager getInstance(IJSpace space) throws RemoteException
<b>Usage:</b>
TransactionManager localTxnManager = LocalTransactionManager( (IJSpace)space );
Transaction.Created tCreated = TransactionFactory.create(localTxnManager, 60000);
Transaction tr = tCreated.transaction;
space
- The space proxy.
RemoteException
- Failed to initialize LocalTransactionManager, or if the passed
space proxy is null.TransactionManager
public void abort(long id) throws UnknownTransactionException, CannotAbortException, RemoteException
abort
in interface TransactionManager
UnknownTransactionException
CannotAbortException
RemoteException
public void abort(long id, long waitFor) throws UnknownTransactionException, CannotAbortException, TimeoutExpiredException, RemoteException
abort
in interface TransactionManager
UnknownTransactionException
CannotAbortException
TimeoutExpiredException
RemoteException
public void commit(long xtnID) throws UnknownTransactionException, CannotCommitException, RemoteException
commit
in interface TransactionManager
UnknownTransactionException
CannotCommitException
RemoteException
public void commit(long xtnID, long waitFor) throws UnknownTransactionException, CannotCommitException, TimeoutExpiredException, RemoteException
commit
in interface TransactionManager
UnknownTransactionException
CannotCommitException
TimeoutExpiredException
RemoteException
public TransactionManager.Created create(long lease)
create
in interface TransactionManager
public int getState(Object id) throws UnknownTransactionException
id
- transaction id
UnknownTransactionException
- if the transaction
is unknown to the transaction manager, either
because the transaction ID is incorrect or because the
transaction is complete and its state has been
discarded by the manager.TransactionConstants
public int getState(long id) throws UnknownTransactionException
getState
in interface TransactionManager
UnknownTransactionException
public void join(long id, TransactionParticipant part, long crashCount)
join
in interface TransactionManager
public boolean equals(Object o)
equals
in class Object
o
- the target manager to compare
public int hashCode()
hashCode
in class Object
getManagerID()
public String getManagerID()
public IJSpace getProxy()
public long checkActiveAndGetTimeLimt(Object xtnId) throws TransactionException
xtnId
- transaction id to check
TransactionException
- throw incase the transaction isn't activepublic long checkActiveAndGetTimeLimt(long xtnId) throws TransactionException
xtnId
- transaction id to check
TransactionException
- throw incase the transaction isn't activepublic boolean isActiveTransaction(Object id)
id
- transaction id to check
public Xid[] recover() throws RemoteException
RemoteException
- if a communication error occurspublic void destroy()
getInstance(..)
will return a
new instance. Once this method has been called, the instance may reject
all other (in-progress and subsequent) calls to its API.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |