public class ServerTransaction extends Object implements Transaction, Serializable
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 |
---|---|
long |
id
The transaction id.
|
TransactionManager |
mgr
The transaction manager.
|
Constructor and Description |
---|
ServerTransaction(AtomicSerial.GetArg arg) |
ServerTransaction(TransactionManager mgr,
long id)
Simple constructor.
|
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.
|
boolean |
equals(Object other)
Two instances are equal if they have the same transaction manager
and the same transaction id.
|
int |
getState()
Returns the current state of the transaction.
|
int |
hashCode() |
boolean |
isNested()
Return true if the transaction has a parent, false if the transaction
is top level.
|
void |
join(TransactionParticipant part,
long crashCount)
Join the transaction.
|
String |
toString() |
public final TransactionManager mgr
public final long id
public ServerTransaction(AtomicSerial.GetArg arg) throws IOException
IOException
public ServerTransaction(TransactionManager mgr, long id)
TransactionFactory
.mgr
- the manager for this transactionid
- the transaction idpublic 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 errorpublic 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()
Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.