public class ServerTransaction extends Object implements ManagedTransaction, Serializable, Externalizable, ISwapExternalizable
Transaction
interface, for use with transaction participants
that implement the default transaction semantics.Transaction
,
NestableServerTransaction
,
TransactionManager
,
TransactionFactory
,
Serialized FormTransaction.Created
Modifier and Type | Field and Description |
---|---|
static long |
EMBEDDED_CRASH_COUNT |
long |
id
The transaction id.
|
ExtendedTransactionManager |
mgr
The transaction manager.
|
Constructor and Description |
---|
ServerTransaction()
Do not use, required for externalizable
|
ServerTransaction(TransactionManager mgr,
long id) |
ServerTransaction(TransactionManager mgr,
long id,
long lease)
Simple constructor.
|
ServerTransaction(TransactionManager mgr,
long id,
TransactionParticipantDataImpl metaData) |
Modifier and Type | Method and Description |
---|---|
void |
abort()
Abort the transaction.
|
void |
abort(long waitFor)
Abort the transaction, waiting for participants to be notified of the decision.
|
void |
commit()
Commit the transaction.
|
void |
commit(long waitFor)
Commit the transaction, waiting for participants to be notified of the decision.
|
static ServerTransaction |
create(TransactionManager mgr,
long id,
long lease) |
ServerTransaction |
createCopy() |
protected ServerTransaction |
createInstance()
Creates an instance of this class for cloning using the
createCopy()
method. |
boolean |
equals(Object other)
Two instances are equal if they have the same transaction manager and the same transaction
id.
|
long |
getLease() |
TransactionParticipantDataImpl |
getMetaData() |
int |
getState()
Returns the current state of the transaction.
|
int |
hashCode() |
protected void |
initEmbedded() |
boolean |
isEmbeddedMgrInProxy()
is the xtn manager an embedded proxy-side one ?
|
boolean |
isEmbeddedMgrProxySideInstance() |
boolean |
isNested()
Return true if the transaction has a parent, false if the transaction is top level.
|
boolean |
isXid() |
void |
join(TransactionParticipant part,
long crashCount)
Join the transaction.
|
void |
join(TransactionParticipant part,
long crashCount,
int partitionId,
String clusterName) |
protected void |
join(TransactionParticipant part,
long crashCount,
int partitionId,
String clusterName,
Object proxy) |
void |
joinIfNeededAndEmbedded(TransactionParticipant participant)
Deprecated.
|
boolean |
joinIfNeededAndEmbedded(TransactionParticipant participant,
int partitionId,
String clusterName,
Object proxy) |
boolean |
needParticipantsJoin()
returns true if this the txn participants need to join it in contrary to a xtn which the
participants are known prior to txn propagation
|
void |
readExternal(ObjectInput in) |
void |
readFromSwap(ObjectInput in) |
void |
setEmbeddedMgrProxySideInstance(boolean value) |
void |
setLease(long lease) |
void |
setMetaData(TransactionParticipantDataImpl metaData) |
String |
toString() |
void |
writeExternal(ObjectOutput out) |
void |
writeToSwap(ObjectOutput out) |
public ExtendedTransactionManager mgr
public long id
public static final long EMBEDDED_CRASH_COUNT
public ServerTransaction()
public ServerTransaction(TransactionManager mgr, long id, long lease)
TransactionFactory
.mgr
- the manager for this transactionid
- the transaction idlease
- the lease of the transaction.public ServerTransaction(TransactionManager mgr, long id)
public ServerTransaction(TransactionManager mgr, long id, TransactionParticipantDataImpl metaData)
public static ServerTransaction create(TransactionManager mgr, long id, long lease) throws RemoteException
RemoteException
protected void initEmbedded() throws RemoteException
RemoteException
public long getLease()
public void setLease(long lease)
public boolean equals(Object other)
public void commit() throws UnknownTransactionException, CannotCommitException, RemoteException
Transaction
NOTCHANGED
or the COMMITTED
state, without waiting for the
transaction manager to notify all participants of the decision. If the transaction must be
aborted (because one or more participants are unable to prepare),
CannotCommitException
is thrown without waiting for the transaction manager to
notify all participants of the decision.commit
in interface Transaction
UnknownTransactionException
- if the transaction is unknown to the manager. This may be
because the transaction ID was incorrect, or because the
transaction has proceeded to cleanup due to an earlier
commit or abort, and has been forgotten.CannotCommitException
- if the transaction reaches the ABORTED state, or is known
to have previously reached that state due to an earlier
commit or abort.RemoteException
- if a communication error occurs.public void commit(long waitFor) throws UnknownTransactionException, CannotCommitException, TimeoutExpiredException, RemoteException
Transaction
NOTCHANGED
or the
COMMITTED
state, and the transaction manager has notified all participants of
the decision, before the specified timeout expires. If the transaction must be aborted
(because one or more participants are unable to prepare), CannotCommitException
is thrown if the transaction manager is able to notify all participants of the decision
before the specified timeout expires. If the transaction manager reaches a decision, but is
unable to notify all participants of that decision before the specified timeout expires, then
TimeoutExpiredException
is thrown. If the specified timeout expires before the
transaction manager reaches a decision, TimeoutExpiredException
is not thrown
until the manager reaches a decision.commit
in interface Transaction
waitFor
- timeout to wait, from the start of the call until all participants have been
notified of the transaction manager's decisionUnknownTransactionException
- if the transaction is unknown to the manager. This may be
because the transaction ID was incorrect, or because the
transaction has proceeded to cleanup due to an earlier
commit or abort, and has been forgotten.CannotCommitException
- if the transaction reaches the ABORTED state, or is known
to have previously reached that state due to an earlier
commit or abort.TimeoutExpiredException
- if the timeout expires before all participants have been
notified.RemoteException
- if a communication error occurs.public void abort() throws UnknownTransactionException, CannotAbortException, RemoteException
Transaction
abort
in interface Transaction
UnknownTransactionException
- if the transaction is unknown to the manager. This may be
because the transaction ID was incorrect, or because the
transaction has proceeded to cleanup due to an earlier
commit or abort, and has been forgotten.CannotAbortException
- if the transaction is known to have previously reached
the COMMITTED state due to an earlier commit.RemoteException
- if a communication error occurs.public void abort(long waitFor) throws UnknownTransactionException, CannotAbortException, TimeoutExpiredException, RemoteException
Transaction
TimeoutExpiredException
is thrown.abort
in interface Transaction
waitFor
- timeout to wait, from the start of the call until all participants have been
notified of the transaction manager's decision.UnknownTransactionException
- if the transaction is unknown to the manager. This may be
because the transaction ID was incorrect, or because the
transaction has proceeded to cleanup due to an earlier
commit or abort, and has been forgotten.CannotAbortException
- if the transaction is known to have previously reached
the COMMITTED state due to an earlier commit.TimeoutExpiredException
- if the timeout expires before all participants have been
notified.RemoteException
- if a communication error occurs.public void join(TransactionParticipant part, long crashCount) throws UnknownTransactionException, CannotJoinException, CrashCountException, RemoteException
crashCount
marks the state of the storage used by the
participant for transactions. If the participant attempts to join a transaction more than
once, the crash counts must be the same. Each system crash or other event that destroys the
state of the participant's unprepared transaction storage must cause the crash count to
increase by at least one.part
- the participant joining the transactioncrashCount
- the participant's current crash countUnknownTransactionException
- 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.CannotJoinException
- if the transaction is known to the manager but is no
longer active.CrashCountException
- if the crash count provided for the participant differs
from the crash count in a previous invocation of the same
pairing of participant and transactionRemoteException
- if there is a communication errorprotected void join(TransactionParticipant part, long crashCount, int partitionId, String clusterName, Object proxy) throws UnknownTransactionException, CannotJoinException, CrashCountException, RemoteException
public void join(TransactionParticipant part, long crashCount, int partitionId, String clusterName) throws UnknownTransactionException, CannotJoinException, CrashCountException, RemoteException
public int getState() throws UnknownTransactionException, RemoteException
TransactionConstants
values.int
representing the state of the transactionUnknownTransactionException
- 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.RemoteException
- if there is a communication errorTransactionConstants
public boolean isNested()
public TransactionParticipantDataImpl getMetaData()
public void setMetaData(TransactionParticipantDataImpl metaData)
metaData
- the metaData to setpublic boolean isEmbeddedMgrInProxy()
ManagedTransaction
isEmbeddedMgrInProxy
in interface ManagedTransaction
public boolean isEmbeddedMgrProxySideInstance()
public void setEmbeddedMgrProxySideInstance(boolean value)
public boolean needParticipantsJoin() throws RemoteException
needParticipantsJoin
in interface ManagedTransaction
RemoteException
public boolean isXid()
protected ServerTransaction createInstance()
createCopy()
method.public ServerTransaction createCopy()
@Deprecated public void joinIfNeededAndEmbedded(TransactionParticipant participant) throws UnknownTransactionException, CannotJoinException, CrashCountException, RemoteException
public boolean joinIfNeededAndEmbedded(TransactionParticipant participant, int partitionId, String clusterName, Object proxy) throws UnknownTransactionException, CannotJoinException, CrashCountException, RemoteException
public void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
IOException
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
IOException
ClassNotFoundException
public void writeToSwap(ObjectOutput out) throws IOException
writeToSwap
in interface ISwapExternalizable
IOException
public void readFromSwap(ObjectInput in) throws IOException, ClassNotFoundException
readFromSwap
in interface ISwapExternalizable
IOException
ClassNotFoundException
Copyright © GigaSpaces.