Class TransactionEventProxyImpl
- java.lang.Object
-
- org.apache.ignite.internal.processors.cache.transactions.TransactionEventProxyImpl
-
- All Implemented Interfaces:
Externalizable,Serializable,AutoCloseable,TransactionProxy,IgniteAsyncSupport,Transaction
public class TransactionEventProxyImpl extends Object implements TransactionProxy, Externalizable
Transaction proxy used at tx events.- See Also:
TransactionStateChangedEvent, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description TransactionEventProxyImpl()Default constructor (required by Externalizable).TransactionEventProxyImpl(GridNearTxLocal tx)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Ends the transaction.voidcommit()Commits this transaction by initiatingtwo-phase-commitprocess.IgniteFuture<Void>commitAsync()Asynchronously commits this transaction by initiatingtwo-phase-commitprocess.TransactionConcurrencyconcurrency()Cache transaction concurrency mode.<R> IgniteFuture<R>future()Gets and resets future for previous asynchronous operation.booleanimplicit()Flag indicating whether transaction was started automatically by the system or not.booleanisAsync()booleanisInvalidate()Get invalidation flag for this transaction.TransactionIsolationisolation()Cache transaction isolation level.booleanisRollbackOnly()If transaction was marked as rollback-only.@Nullable Stringlabel()Returns transaction's label.UUIDnodeId()ID of the node on which this transaction started.voidreadExternal(ObjectInput in)voidresume()Resume a transaction if it was previously suspended.voidrollback()Rolls back this transaction.IgniteFuture<Void>rollbackAsync()Asynchronously rolls back this transaction.booleansetRollbackOnly()Modify the transaction associated with the current thread such that the only possible outcome of the transaction is to roll back the transaction.longstartTime()Start time of this transaction.TransactionStatestate()Gets current transaction state value.voidsuspend()Suspends a transaction.longthreadId()ID of the thread in which this transaction started.longtimeout()Gets timeout value in milliseconds for this transaction.longtimeout(long timeout)Sets transaction timeout value.IgniteAsyncSupportwithAsync()Gets instance of this component with asynchronous mode enabled.voidwriteExternal(ObjectOutput out)IgniteUuidxid()Gets unique identifier for this transaction.
-
-
-
Constructor Detail
-
TransactionEventProxyImpl
public TransactionEventProxyImpl()
Default constructor (required by Externalizable).
-
TransactionEventProxyImpl
public TransactionEventProxyImpl(GridNearTxLocal tx)
- Parameters:
tx- Tx proxy.
-
-
Method Detail
-
xid
public IgniteUuid xid()
Gets unique identifier for this transaction.- Specified by:
xidin interfaceTransaction- Returns:
- Transaction UID.
-
nodeId
public UUID nodeId()
ID of the node on which this transaction started.- Specified by:
nodeIdin interfaceTransaction- Returns:
- Originating node ID.
-
threadId
public long threadId()
ID of the thread in which this transaction started.- Specified by:
threadIdin interfaceTransaction- Returns:
- Thread ID.
-
startTime
public long startTime()
Start time of this transaction.- Specified by:
startTimein interfaceTransaction- Returns:
- Start time of this transaction on this node.
-
isolation
public TransactionIsolation isolation()
Cache transaction isolation level.- Specified by:
isolationin interfaceTransaction- Returns:
- Isolation level.
-
concurrency
public TransactionConcurrency concurrency()
Cache transaction concurrency mode.- Specified by:
concurrencyin interfaceTransaction- Returns:
- Concurrency mode.
-
implicit
public boolean implicit()
Flag indicating whether transaction was started automatically by the system or not. System will start transactions implicitly whenever any cacheput(..)orremove(..)operation is invoked outside of transaction.- Specified by:
implicitin interfaceTransaction- Returns:
Trueif transaction was started implicitly.
-
isInvalidate
public boolean isInvalidate()
Get invalidation flag for this transaction. If set totrue, then remote values will beinvalidated(set tonull) instead of updated.Invalidation messages don't carry new values, so they are a lot lighter than update messages. However, when a value is accessed on a node after it's been invalidated, it must be loaded from persistent store.
- Specified by:
isInvalidatein interfaceTransaction- Returns:
- Invalidation flag.
-
state
public TransactionState state()
Gets current transaction state value.- Specified by:
statein interfaceTransaction- Returns:
- Current transaction state.
-
timeout
public long timeout()
Gets timeout value in milliseconds for this transaction. If transaction times out prior to it's completion,TransactionTimeoutExceptionwill be thrown.- Specified by:
timeoutin interfaceTransaction- Returns:
- Transaction timeout value.
-
timeout
public long timeout(long timeout)
Sets transaction timeout value. This value can be set only before a first operation on transaction has been performed.- Specified by:
timeoutin interfaceTransaction- Parameters:
timeout- Transaction timeout value.- Returns:
- Previous timeout.
-
setRollbackOnly
public boolean setRollbackOnly()
Modify the transaction associated with the current thread such that the only possible outcome of the transaction is to roll back the transaction.- Specified by:
setRollbackOnlyin interfaceTransaction- Returns:
Trueif rollback-only flag was set as a result of this operation,falseif it was already set prior to this call or could not be set because transaction is already finishing up committing or rolling back.
-
isRollbackOnly
public boolean isRollbackOnly()
If transaction was marked as rollback-only.- Specified by:
isRollbackOnlyin interfaceTransaction- Returns:
Trueif transaction can only be rolled back.
-
commit
public void commit() throws IgniteExceptionCommits this transaction by initiatingtwo-phase-commitprocess.- Specified by:
commitin interfaceTransaction- Throws:
IgniteException- If commit failed.TransactionTimeoutException- If transaction is timed out.TransactionRollbackException- If transaction is automatically rolled back.TransactionOptimisticException- If transaction concurrency isTransactionConcurrency.OPTIMISTICand commit is optimistically failed.TransactionHeuristicException- If transaction has entered an unknown state.
-
commitAsync
public IgniteFuture<Void> commitAsync() throws IgniteException
Asynchronously commits this transaction by initiatingtwo-phase-commitprocess.- Specified by:
commitAsyncin interfaceTransaction- Returns:
- a Future representing pending completion of the commit.
- Throws:
IgniteException- If commit failed.TransactionTimeoutException- If transaction is timed out.TransactionRollbackException- If transaction is manually/automatically rolled back.TransactionOptimisticException- If transaction concurrency isTransactionConcurrency.OPTIMISTICand commit is optimistically failed.TransactionHeuristicException- If transaction has entered an unknown state.
-
close
public void close() throws IgniteExceptionEnds the transaction. Transaction will be rolled back if it has not been committed.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceTransaction- Throws:
IgniteException- If transaction could not be gracefully ended.
-
rollback
public void rollback() throws IgniteExceptionRolls back this transaction. Note, that it's allowed to roll back transaction from any thread at any time.- Specified by:
rollbackin interfaceTransaction- Throws:
IgniteException- If rollback failed.
-
rollbackAsync
public IgniteFuture<Void> rollbackAsync() throws IgniteException
Asynchronously rolls back this transaction. Note, that it's allowed to roll back transaction from any thread at any time.- Specified by:
rollbackAsyncin interfaceTransaction- Returns:
- a Future representing pending completion of the rollback.
- Throws:
IgniteException- If rollback failed.
-
resume
public void resume() throws IgniteExceptionResume a transaction if it was previously suspended.- Specified by:
resumein interfaceTransaction- Throws:
IgniteException- If resume failed.
-
suspend
public void suspend() throws IgniteExceptionSuspends a transaction. It could be resumed later.- Specified by:
suspendin interfaceTransaction- Throws:
IgniteException- If suspension failed.
-
label
@Nullable public @Nullable String label()
Returns transaction's label.Use
IgniteTransactions.withLabel(java.lang.String)to assign a label to a newly created transaction.- Specified by:
labelin interfaceTransaction- Returns:
- Label.
-
withAsync
public IgniteAsyncSupport withAsync()
Gets instance of this component with asynchronous mode enabled.- Specified by:
withAsyncin interfaceIgniteAsyncSupport- Returns:
- Instance of this component with asynchronous mode enabled.
-
isAsync
public boolean isAsync()
- Specified by:
isAsyncin interfaceIgniteAsyncSupport- Returns:
Trueif asynchronous mode is enabled.
-
future
public <R> IgniteFuture<R> future()
Gets and resets future for previous asynchronous operation.- Specified by:
futurein interfaceIgniteAsyncSupport- Type Parameters:
R- Type of the future result.- Returns:
- Future for previous asynchronous operation.
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
-