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

## Class TransactionProxyImpl<K,V>

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

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

    public class TransactionProxyImpl<K,V>
    extends Object
    implements TransactionProxy, Externalizable

Cache transaction proxy.

See Also:
  Serialized Form

### Constructor Summary

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

### Method Summary

Methods
`void` `close()` Ends the transaction.
`void` `commit()` Commits this transaction by initiating `two-phase-commit` process.
`TransactionConcurrency` `concurrency()` Cache transaction concurrency mode.
`<R> IgniteFuture<R>` `future()` Gets and resets future for previous asynchronous operation.
`boolean` `implicit()` Flag indicating whether transaction was started automatically by the system or not.
`boolean` `isAsync()`
`boolean` `isInvalidate()` Get invalidation flag for this transaction.
`TransactionIsolation` `isolation()` Cache transaction isolation level.
`boolean` `isRollbackOnly()` If transaction was marked as rollback-only.
`UUID` `nodeId()` ID of the node on which this transaction started.
`void` `readExternal(ObjectInput in)`
`void` `rollback()` Rolls back this transaction.
`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.
`long` `startTime()` Start time of this transaction.
`TransactionState` `state()` Gets current transaction state value.
`long` `threadId()` ID of the thread in which this transaction started.
`long` `timeout()` Gets timeout value in milliseconds for this transaction.
`long` `timeout(long timeout)` Sets transaction timeout value.
`String` `toString()`
`IgniteInternalTx` `tx()`
`IgniteAsyncSupport` `withAsync()` Gets instance of this component with asynchronous mode enabled.
`void` `writeExternal(ObjectOutput out)`
`IgniteUuid` `xid()` Gets unique identifier for this transaction.

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

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

### Constructor Detail

#### TransactionProxyImpl

    public TransactionProxyImpl()

Empty constructor required for `Externalizable`.

#### TransactionProxyImpl

    public TransactionProxyImpl(IgniteInternalTx tx,
                        GridCacheSharedContext<K,V> cctx,
                        boolean async)

Parameters:
  `tx` - Transaction.
  `cctx` - Shared context.
  `async` - Async flag.

### Method Detail

#### tx

    public IgniteInternalTx tx()

Returns:
  Transaction.

#### xid

    public IgniteUuid xid()

Gets unique identifier for this transaction.

Specified by:
  `xid` in interface `Transaction`
Returns:
  Transaction UID.

#### nodeId

    public UUID nodeId()

ID of the node on which this transaction started.

Specified by:
  `nodeId` in interface `Transaction`
Returns:
  Originating node ID.

#### threadId

    public long threadId()

ID of the thread in which this transaction started.

Specified by:
  `threadId` in interface `Transaction`
Returns:
  Thread ID.

#### startTime

    public long startTime()

Start time of this transaction.

Specified by:
  `startTime` in interface `Transaction`
Returns:
  Start time of this transaction on this node.

#### isolation

    public TransactionIsolation isolation()

Cache transaction isolation level.

Specified by:
  `isolation` in interface `Transaction`
Returns:
  Isolation level.

#### concurrency

    public TransactionConcurrency concurrency()

Cache transaction concurrency mode.

Specified by:
  `concurrency` in interface `Transaction`
Returns:
  Concurrency mode.

#### isInvalidate

    public boolean isInvalidate()

Get invalidation flag for this transaction. If set to `true`, then remote values will be `invalidated` (set to `null`) 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:
  `isInvalidate` in interface `Transaction`
Returns:
  Invalidation flag.

#### implicit

    public boolean implicit()

Flag indicating whether transaction was started automatically by the system or not. System will start transactions implicitly whenever any cache `put(..)` or `remove(..)` operation is invoked outside of transaction.

Specified by:
  `implicit` in interface `Transaction`
Returns:
  `True` if transaction was started implicitly.

#### timeout

    public long timeout()

Gets timeout value in milliseconds for this transaction. If transaction times out prior to it's completion, `IgniteTxTimeoutCheckedException` will be thrown.

Specified by:
  `timeout` in interface `Transaction`
Returns:
  Transaction timeout value.

#### state

    public TransactionState state()

Gets current transaction state value.

Specified by:
  `state` in interface `Transaction`
Returns:
  Current transaction state.

#### 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`
Parameters:
  `timeout` - Transaction timeout value.
Returns:
  Previous timeout.

#### withAsync

    public IgniteAsyncSupport withAsync()

Gets instance of this component with asynchronous mode enabled.

Specified by:
  `withAsync` in interface `IgniteAsyncSupport`
Returns:
  Instance of this component with asynchronous mode enabled.

#### isAsync

    public boolean isAsync()

Specified by:
  `isAsync` in interface `IgniteAsyncSupport`
Returns:
  `True` if asynchronous mode is enabled.

#### future

    public <R> IgniteFuture<R> future()

Gets and resets future for previous asynchronous operation.

Specified by:
  `future` in interface `IgniteAsyncSupport`
Returns:
  Future for previous asynchronous operation.

#### 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`
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.

#### isRollbackOnly

    public boolean isRollbackOnly()

If transaction was marked as rollback-only.

Specified by:
  `isRollbackOnly` in interface `Transaction`
Returns:
  `True` if transaction can only be rolled back.

#### commit

    public void commit()

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

Specified by:
  `commit` in interface `Transaction`

#### close

    public void close()

Ends the transaction. Transaction will be rolled back if it has not been committed.

Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `Transaction`

#### rollback

    public void rollback()

Rolls back this transaction.

Specified by:
  `rollback` in interface `Transaction`

#### writeExternal

    public void writeExternal(ObjectOutput out)
                       throws IOException

Specified by:
  `writeExternal` in interface `Externalizable`
Throws:
  `IOException`

#### readExternal

    public void readExternal(ObjectInput in)
                      throws IOException,
                             ClassNotFoundException

Specified by:
  `readExternal` in interface `Externalizable`
Throws:
  `IOException`
  `ClassNotFoundException`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.1.0-incubating
Release Date | : May 20 2015