org.apache.ignite.internal.processors.cache.transactions

## Class TransactionProxyRollbackOnlyImpl<K,V>

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl<K,V>
  - - org.apache.ignite.internal.processors.cache.transactions.TransactionProxyRollbackOnlyImpl<K,V>

All Implemented Interfaces:
  Externalizable, Serializable, AutoCloseable, TransactionProxy, IgniteAsyncSupport, Transaction

    public class TransactionProxyRollbackOnlyImpl<K,V>
    extends TransactionProxyImpl<K,V>

Cache transaction proxy which supports only rollback or close operations and getters.

See Also:
  Serialized Form

### Constructor Summary

Constructors
Constructor and Description
`TransactionProxyRollbackOnlyImpl()` Empty constructor required for `Externalizable`.
`TransactionProxyRollbackOnlyImpl(GridNearTxLocal tx, GridCacheSharedContext<K,V> cctx, boolean async)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `commit()` Commits this transaction by initiating `two-phase-commit` process.
`IgniteFuture<Void>` `commitAsync()` Asynchronously commits this transaction by initiating `two-phase-commit` process.
`void` `resume()` Resume a transaction if it was previously suspended.
`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.
`void` `suspend()` Suspends a transaction.
`long` `timeout(long timeout)` Sets transaction timeout value.

### Methods inherited from class org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl

`close, concurrency, future, implicit, isAsync, isInvalidate, isolation, isRollbackOnly, label, nodeId, readExternal, rollback, rollbackAsync, startTime, state, threadId, timeout, toString, tx, withAsync, writeExternal, xid`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### TransactionProxyRollbackOnlyImpl

    public TransactionProxyRollbackOnlyImpl()

Empty constructor required for `Externalizable`.

#### TransactionProxyRollbackOnlyImpl

    public TransactionProxyRollbackOnlyImpl(GridNearTxLocal tx,
                                            GridCacheSharedContext<K,V> cctx,
                                            boolean async)

Parameters:
  `tx` - Tx.
  `cctx` - Cctx.
  `async` - Async.

### Method Detail

#### 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:
  `setRollbackOnly` in interface `Transaction`
Overrides:
  `setRollbackOnly` in class `TransactionProxyImpl<K,V>`
Returns:
  `True` if rollback-only flag was set as a result of this operation, `false` if it was already set prior to this call or could not be set because transaction is already finishing up committing or rolling back.

#### commit

    public void commit()

Commits this transaction by initiating `two-phase-commit` process.

Specified by:
  `commit` in interface `Transaction`
Overrides:
  `commit` in class `TransactionProxyImpl<K,V>`

#### commitAsync

    public IgniteFuture<Void> commitAsync()
                                   throws IgniteException

Asynchronously commits this transaction by initiating `two-phase-commit` process.

Specified by:
  `commitAsync` in interface `Transaction`
Overrides:
  `commitAsync` in class `TransactionProxyImpl<K,V>`
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 is `TransactionConcurrency.OPTIMISTIC` and commit is optimistically failed.
  `TransactionHeuristicException` - If transaction has entered an unknown state.

#### suspend

    public void suspend()
                 throws IgniteException

Suspends a transaction. It could be resumed later. Supported only for optimistic transactions.

Specified by:
  `suspend` in interface `Transaction`
Overrides:
  `suspend` in class `TransactionProxyImpl<K,V>`
Throws:
  `IgniteException` - If suspension failed.

#### resume

    public void resume()
                throws IgniteException

Resume a transaction if it was previously suspended. Supported only for optimistic transactions.

Specified by:
  `resume` in interface `Transaction`
Overrides:
  `resume` in class `TransactionProxyImpl<K,V>`
Throws:
  `IgniteException` - If resume failed.

#### 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:
  `timeout` in interface `Transaction`
Overrides:
  `timeout` in class `TransactionProxyImpl<K,V>`
Parameters:
  `timeout` - Transaction timeout value.
Returns:
  Previous timeout.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.13.0
Release Date | : April 20 2022