|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.j_spaces.core.client.LocalTransactionManager
com.gigaspaces.client.transaction.local.LocalTransactionManagerImpl
public class LocalTransactionManagerImpl
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 | |
---|---|
LocalTransactionManagerImpl()
Do not use, externliazable only. |
|
LocalTransactionManagerImpl(IJSpace spaceProxy)
Deprecated. Use getInstance(IJSpace) or getInstance(IMap) instead |
Method Summary | |
---|---|
void |
abort(long id)
|
void |
abort(long id,
long waitFor)
|
void |
abort(Object xid)
Internal only - used by XA. |
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)
|
void |
commit(Object xid)
Internal only - used by XA. |
TransactionManager.Created |
create(long lease)
|
TransactionManager.Created |
create(Object xid,
long lease)
Creates transaction - for internal and XA use. |
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)
|
int |
prepare(Object xid)
Prepare transaction - for internal and XA use. |
void |
readExternal(ObjectInput in)
|
Xid[] |
recover()
Create Xids array of all the prepared transactions. |
void |
writeExternal(ObjectOutput out)
|
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LocalTransactionManagerImpl()
@Deprecated public LocalTransactionManagerImpl(IJSpace spaceProxy) throws RemoteException
getInstance(IJSpace)
or getInstance(IMap)
instead
spaceProxy
- The space proxy.
RemoteException
- Failed to initialize LocalTransactionManager.Method Detail |
---|
public void writeExternal(ObjectOutput out) throws IOException
IOException
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
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(Object xid) throws UnknownTransactionException, CannotAbortException, RemoteException
xid
- XA transaction id
UnknownTransactionException
CannotAbortException
RemoteException
public void abort(long id) throws UnknownTransactionException, CannotAbortException, RemoteException
UnknownTransactionException
CannotAbortException
RemoteException
public void abort(long id, long waitFor) throws UnknownTransactionException, CannotAbortException, TimeoutExpiredException, RemoteException
UnknownTransactionException
CannotAbortException
TimeoutExpiredException
RemoteException
public void commit(Object xid) throws UnknownTransactionException, CannotCommitException, RemoteException
xid
- XA transaction id
UnknownTransactionException
CannotCommitException
RemoteException
public void commit(long xtnID) throws UnknownTransactionException, CannotCommitException, RemoteException
UnknownTransactionException
CannotCommitException
RemoteException
public void commit(long xtnID, long waitFor) throws UnknownTransactionException, CannotCommitException, TimeoutExpiredException, RemoteException
UnknownTransactionException
CannotCommitException
TimeoutExpiredException
RemoteException
public int prepare(Object xid) throws UnknownTransactionException, CannotCommitException, RemoteException
xid
- transaction id
UnknownTransactionException
CannotCommitException
RemoteException
- if a communication error occurspublic TransactionManager.Created create(Object xid, long lease)
public TransactionManager.Created create(long lease)
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
UnknownTransactionException
public void join(long id, TransactionParticipant part, long crashCount)
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 |