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

## Class IgniteTxAdapter

- java.lang.Object
- - org.apache.ignite.internal.util.lang.GridMetadataAwareAdapter
  - - org.apache.ignite.internal.processors.cache.transactions.IgniteTxAdapter

All Implemented Interfaces:
  Externalizable, Serializable, AutoCloseable, IgniteInternalTx

Direct Known Subclasses:
  GridDistributedTxRemoteAdapter, IgniteTxLocalAdapter

    public abstract class IgniteTxAdapter
    extends GridMetadataAwareAdapter
    implements IgniteInternalTx, Externalizable

Managed transaction adapter.

See Also:
  Serialized Form

### Nested Class Summary

### Nested classes/interfaces inherited from class org.apache.ignite.internal.util.lang.GridMetadataAwareAdapter

`GridMetadataAwareAdapter.EntryKey`

### Nested classes/interfaces inherited from interface org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx

`IgniteInternalTx.FinalizationStatus`

### Field Summary

Fields
`protected GridCacheSharedContext<?,?>` `cctx` Cache registry.
`protected TransactionConcurrency` `concurrency` Concurrency.
`protected GridCacheVersion` `endVer` End version (a.k.a.
`protected boolean` `implicit` Implicit flag.
`protected boolean` `internal` Internal flag.
`protected boolean` `invalidate` Invalidate flag.
`protected boolean` `isDone` Done marker.
`protected TransactionIsolation` `isolation` Isolation.
`protected boolean` `loc` Local flag.
`protected static IgniteLogger` `log` Logger.
`protected boolean` `needRetVal` Need return value.
`protected UUID` `nodeId` Node ID.
`protected boolean` `onePhaseCommit`
`protected long` `startTime` Transaction start time.
`protected GridCacheVersion` `startVer` Transaction counter value at the start of transaction.
`protected boolean` `storeEnabled` Store used flag.
`protected UUID` `subjId` Subject ID initiated this transaction.
`protected CacheWriteSynchronizationMode` `syncMode`
`protected String` `taskName` Task name.
`protected int` `taskNameHash` Task name hash code.
`protected long` `threadId` Thread ID.
`protected long` `timeout` Transaction timeout.
`protected AffinityTopologyVersion` `topVer` Topology version.
`protected boolean` `transform` If this transaction contains transform entries.
`protected Map<UUID,Collection<UUID>>` `txNodes`
`protected int` `txSize`
`protected GridCacheVersion` `writeVer` Entries write version.
`protected GridCacheVersion` `xidVer` Transaction ID.

### Constructor Summary

Constructors
`protected` `IgniteTxAdapter()` Empty constructor required for `Externalizable`.
`protected` `IgniteTxAdapter(GridCacheSharedContext<?,?> cctx, GridCacheVersion xidVer, boolean implicit, boolean loc, boolean sys, byte plc, TransactionConcurrency concurrency, TransactionIsolation isolation, long timeout, boolean invalidate, boolean storeEnabled, boolean onePhaseCommit, int txSize, UUID subjId, int taskNameHash)`
`protected` `IgniteTxAdapter(GridCacheSharedContext<?,?> cctx, UUID nodeId, GridCacheVersion xidVer, GridCacheVersion startVer, long threadId, boolean sys, byte plc, TransactionConcurrency concurrency, TransactionIsolation isolation, long timeout, int txSize, UUID subjId, int taskNameHash)`

### Method Summary

Methods
`void` `addInvalidPartition(GridCacheContext<?,?> cacheCtx, int part)`
`protected IgniteBiTuple<GridCacheOperation,CacheObject>` `applyTransformClosures(IgniteTxEntry txEntry, boolean metrics, GridCacheReturn ret)`
`protected void` `batchStoreCommit(Iterable<IgniteTxEntry> writeEntries)` Performs batch database operations.
`protected boolean` `checkInternal(IgniteTxKey key)`
`void` `close()` Ends the transaction.
`boolean` `colocated()`
`GridCacheVersion` `commitVersion()`
`void` `commitVersion(GridCacheVersion commitVer)`
`void` `completedVersions(GridCacheVersion base, Collection<GridCacheVersion> committed, Collection<GridCacheVersion> txs)`
`TransactionConcurrency` `concurrency()` Cache transaction concurrency mode.
`protected IgniteBiTuple<GridCacheOperation,GridCacheVersionConflictContext>` `conflictResolve(GridCacheOperation op, IgniteTxEntry txEntry, CacheObject newVal, GridCacheVersion newVer, GridCacheEntryEx old)` Resolve DR conflict.
`IgniteInternalFuture<?>` `currentPrepareFuture()`
`boolean` `dht()`
`boolean` `done()`
`void` `endVersion(GridCacheVersion endVer)`
`boolean` `equals(Object o)`
`void` `errorWhenCommitting()` Changes transaction state from COMMITTING to MARKED_ROLLBACK.
`protected boolean` `evictNearEntry(IgniteTxEntry e, boolean primaryOnly)`
`protected IgniteInternalTx.FinalizationStatus` `finalizationStatus()`
`IgniteInternalFuture<IgniteInternalTx>` `finishFuture()`
`int` `hashCode()`
`boolean` `hasTransforms()`
`boolean` `implicit()` Flag indicating whether transaction was started automatically by the system or not.
`boolean` `implicitSingle()`
`boolean` `internal()`
`void` `invalidate(boolean invalidate)`
`Map<Integer,Set<Integer>>` `invalidPartitions()`
`byte` `ioPolicy()`
`boolean` `isInvalidate()` Get invalidation flag for this transaction.
`protected boolean` `isNearLocallyMapped(IgniteTxEntry e, boolean primaryOnly)`
`TransactionIsolation` `isolation()` Cache transaction isolation level.
`boolean` `isRollbackOnly()` If transaction was marked as rollback-only.
`abstract boolean` `isStarted()`
`boolean` `isSystemInvalidate()`
`protected boolean` `isWriteToStoreFromDhtValid(Collection<CacheStoreManager> stores)`
`boolean` `local()`
`boolean` `localResult()`
`protected IgniteLogger` `log()`
`boolean` `markFinalizing(IgniteInternalTx.FinalizationStatus status)`
`boolean` `markPreparing()`
`boolean` `near()`
`GridCacheVersion` `nearXidVersion()`
`boolean` `needReturnValue()`
`void` `needReturnValue(boolean needRetVal)`
`boolean` `needsCompletedVersions()`
`UUID` `nodeId()` ID of the node on which this transaction started.
`boolean` `onePhaseCommit()`
`void` `onePhaseCommit(boolean onePhaseCommit)`
`void` `onRemap(AffinityTopologyVersion topVer)`
`boolean` `optimistic()`
`Collection<IgniteTxEntry>` `optimisticLockEntries()` Gets a list of entries that needs to be locked on the next step of prepare stage of optimistic transaction.
`UUID` `otherNodeId()` Gets ID of additional node involved.
`GridCacheVersion` `ownedVersion(IgniteTxKey key)` Gets owned version for near remote transaction.
`boolean` `ownsLock(GridCacheEntryEx entry)`
`boolean` `ownsLockUnsafe(GridCacheEntryEx entry)`
`boolean` `pessimistic()`
`TransactionProxy` `proxy()`
`boolean` `readCommitted()`
`void` `readExternal(ObjectInput in)`
`protected Object` `readResolve()` Reconstructs object on unmarshalling.
`long` `remainingTime()` Gets remaining allowed transaction time.
`boolean` `repeatableRead()`
`boolean` `replicated()`
`String` `resolveTaskName()`
`boolean` `serializable()`
`protected void` `sessionEnd(Collection<CacheStoreManager> stores, boolean commit)`
`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.
`int` `size()`
`long` `startTime()` Start time of this transaction.
`TransactionState` `state()` Gets current transaction state value.
`boolean` `state(TransactionState state)`
`protected boolean` `state(TransactionState state, boolean timedOut)`
`boolean` `storeEnabled()`
`void` `storeEnabled(boolean storeEnabled)`
`boolean` `storeUsed()`
`UUID` `subjectId()`
`CacheWriteSynchronizationMode` `syncMode()`
`void` `syncMode(CacheWriteSynchronizationMode syncMode)`
`boolean` `system()` Checks if this is system cache transaction.
`void` `systemInvalidate(boolean sysInvalidate)`
`int` `taskNameHash()` Task name hash in case if transaction was initiated within task execution.
`long` `threadId()` ID of the thread in which this transaction started.
`boolean` `timedOut()`
`long` `timeout()` Gets timeout value in milliseconds for this transaction.
`long` `timeout(long timeout)` Sets transaction timeout value.
`IgniteCheckedException` `timeoutException()`
`AffinityTopologyVersion` `topologyVersion()`
`AffinityTopologyVersion` `topologyVersion(AffinityTopologyVersion topVer)` Attempts to set topology version and returns the current value.
`AffinityTopologyVersion` `topologyVersionSnapshot()`
`String` `toString()`
`Map<UUID,Collection<UUID>>` `transactionNodes()`
`void` `transactionNodes(Map<UUID,Collection<UUID>> txNodes)`
`protected void` `uncommit()` Uncommits transaction by invalidating all of its entries.
`protected boolean` `updateNearCache(GridCacheContext<?,?> cacheCtx, KeyCacheObject key, AffinityTopologyVersion topVer)` Checks whether near cache should be updated.
`boolean` `user()`
`void` `writeExternal(ObjectOutput out)`
`GridCacheVersion` `writeVersion()`
`void` `writeVersion(GridCacheVersion writeVer)` Sets write version.
`IgniteUuid` `xid()` Gets unique identifier for this transaction.
`GridCacheVersion` `xidVersion()`

### Methods inherited from class org.apache.ignite.internal.util.lang.GridMetadataAwareAdapter

`addMeta, addMetaIfAbsent, addMetaIfAbsent, allMeta, clone, copyMeta, copyMeta, hasMeta, hasMeta, meta, putMetaIfAbsent, readExternalMeta, removeAllMeta, removeMeta, removeMeta, replaceMeta, writeExternalMeta`

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

`finalize, getClass, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx

`activeCachesDeploymentEnabled, addMeta, allEntries, alternateVersions, commit, commitAsync, commitError, empty, entry, eventNodeId, hasWriteKey, masterNodeIds, meta, onOwnerChanged, originatingNodeId, peek, prepare, prepareAsync, readEntries, readMap, readSet, removeMeta, rollback, rollbackAsync, seal, txState, writeEntries, writeMap, writeSet`

### Field Detail

#### log

    protected static IgniteLogger log

Logger.

#### xidVer

    @GridToStringInclude
    protected GridCacheVersion xidVer

Transaction ID.

#### writeVer

    @GridToStringInclude
    protected GridCacheVersion writeVer

Entries write version.

#### implicit

    @GridToStringInclude
    protected boolean implicit

Implicit flag.

#### loc

    @GridToStringInclude
    protected boolean loc

Local flag.

#### threadId

    @GridToStringInclude
    protected long threadId

Thread ID.

#### startTime

    @GridToStringInclude
    protected long startTime

Transaction start time.

#### nodeId

    @GridToStringInclude
    protected UUID nodeId

Node ID.

#### startVer

    @GridToStringInclude
    protected GridCacheVersion startVer

Transaction counter value at the start of transaction.

#### cctx

    @GridToStringExclude
    protected GridCacheSharedContext<?,?> cctx

Cache registry.

#### needRetVal

    protected boolean needRetVal

Need return value.

#### endVer

    @GridToStringInclude
    protected GridCacheVersion endVer

End version (a.k.a. `'tnc'` or `'transaction number counter'`) assigned to this transaction at the end of write phase.

#### isolation

    @GridToStringInclude
    protected TransactionIsolation isolation

Isolation.

#### concurrency

    @GridToStringInclude
    protected TransactionConcurrency concurrency

Concurrency.

#### timeout

    @GridToStringInclude
    protected long timeout

Transaction timeout.

#### invalidate

    protected volatile boolean invalidate

Invalidate flag.

#### internal

    protected boolean internal

Internal flag.

#### onePhaseCommit

    protected boolean onePhaseCommit

#### syncMode

    protected CacheWriteSynchronizationMode syncMode

#### transform

    protected boolean transform

If this transaction contains transform entries.

#### isDone

    protected volatile boolean isDone

Done marker.

#### txSize

    protected int txSize

#### topVer

    @GridToStringInclude
    protected volatile AffinityTopologyVersion topVer

Topology version.

#### txNodes

    protected Map<UUID,Collection<UUID>> txNodes

#### subjId

    protected UUID subjId

Subject ID initiated this transaction.

#### taskNameHash

    protected int taskNameHash

Task name hash code.

#### taskName

    protected String taskName

Task name.

#### storeEnabled

    protected boolean storeEnabled

Store used flag.

### Constructor Detail

#### IgniteTxAdapter

    protected IgniteTxAdapter()

Empty constructor required for `Externalizable`.

#### IgniteTxAdapter

    protected IgniteTxAdapter(GridCacheSharedContext<?,?> cctx,
                   GridCacheVersion xidVer,
                   boolean implicit,
                   boolean loc,
                   boolean sys,
                   byte plc,
                   TransactionConcurrency concurrency,
                   TransactionIsolation isolation,
                   long timeout,
                   boolean invalidate,
                   boolean storeEnabled,
                   boolean onePhaseCommit,
                   int txSize,
                   @Nullable
                   UUID subjId,
                   int taskNameHash)

Parameters:
  `cctx` - Cache registry.
  `xidVer` - Transaction ID.
  `implicit` - Implicit flag.
  `loc` - Local flag.
  `sys` - System transaction flag.
  `plc` - IO policy.
  `concurrency` - Concurrency.
  `isolation` - Isolation.
  `timeout` - Timeout.
  `txSize` - Transaction size.

#### IgniteTxAdapter

    protected IgniteTxAdapter(GridCacheSharedContext<?,?> cctx,
                   UUID nodeId,
                   GridCacheVersion xidVer,
                   GridCacheVersion startVer,
                   long threadId,
                   boolean sys,
                   byte plc,
                   TransactionConcurrency concurrency,
                   TransactionIsolation isolation,
                   long timeout,
                   int txSize,
                   @Nullable
                   UUID subjId,
                   int taskNameHash)

Parameters:
  `cctx` - Cache registry.
  `nodeId` - Node ID.
  `xidVer` - Transaction ID.
  `startVer` - Start version mark.
  `threadId` - Thread ID.
  `sys` - System transaction flag.
  `plc` - IO policy.
  `concurrency` - Concurrency.
  `isolation` - Isolation.
  `timeout` - Timeout.
  `txSize` - Transaction size.

### Method Detail

#### localResult

    public boolean localResult()

Specified by:
  `localResult` in interface `IgniteInternalTx`
Returns:
  `True` if transaction started on the node initiated cache operation.

#### updateNearCache

    protected boolean updateNearCache(GridCacheContext<?,?> cacheCtx,
                          KeyCacheObject key,
                          AffinityTopologyVersion topVer)

Checks whether near cache should be updated.

Returns:
  Flag indicating whether near cache should be updated.

#### optimisticLockEntries

    public Collection<IgniteTxEntry> optimisticLockEntries()

Gets a list of entries that needs to be locked on the next step of prepare stage of optimistic transaction.

Specified by:
  `optimisticLockEntries` in interface `IgniteInternalTx`
Returns:
  List of tx entries for optimistic locking.

#### storeEnabled

    public boolean storeEnabled()

Specified by:
  `storeEnabled` in interface `IgniteInternalTx`
Returns:
  `True` if transaction is allowed to use store.

#### storeEnabled

    public void storeEnabled(boolean storeEnabled)

Parameters:
  `storeEnabled` - Store enabled flag.

#### system

    public boolean system()

Checks if this is system cache transaction. System transactions are isolated from user transactions because some of the public API methods may be invoked inside user transactions and internally start system cache transactions.

Specified by:
  `system` in interface `IgniteInternalTx`
Returns:
  `True` if transaction is started for system cache.

#### ioPolicy

    public byte ioPolicy()

Specified by:
  `ioPolicy` in interface `IgniteInternalTx`
Returns:
  Pool where message for the given transaction must be processed.

#### storeUsed

    public boolean storeUsed()

Specified by:
  `storeUsed` in interface `IgniteInternalTx`
Returns:
  `True` if transaction is allowed to use store and transactions spans one or more caches with store enabled.

#### uncommit

    protected void uncommit()

Uncommits transaction by invalidating all of its entries. Courtesy to minimize inconsistency.

#### otherNodeId

    public UUID otherNodeId()

Gets ID of additional node involved. For example, in DHT case, other node is near node ID.

Specified by:
  `otherNodeId` in interface `IgniteInternalTx`
Returns:
  Parent node IDs.

#### subjectId

    public UUID subjectId()

Specified by:
  `subjectId` in interface `IgniteInternalTx`
Returns:
  Subject ID initiated this transaction.

#### taskNameHash

    public int taskNameHash()

Task name hash in case if transaction was initiated within task execution.

Specified by:
  `taskNameHash` in interface `IgniteInternalTx`
Returns:
  Task name hash.

#### topologyVersion

    public AffinityTopologyVersion topologyVersion()

Specified by:
  `topologyVersion` in interface `IgniteInternalTx`
Returns:
  Last recorded topology version.

#### topologyVersionSnapshot

    public final AffinityTopologyVersion topologyVersionSnapshot()

Specified by:
  `topologyVersionSnapshot` in interface `IgniteInternalTx`
Returns:
  Topology version snapshot.

#### topologyVersion

    public final AffinityTopologyVersion topologyVersion(AffinityTopologyVersion topVer)

Attempts to set topology version and returns the current value. If topology version was previously set, then it's value will be returned (but not updated).

Specified by:
  `topologyVersion` in interface `IgniteInternalTx`
Parameters:
  `topVer` - Topology version.
Returns:
  Recorded topology version.

#### onRemap

    public void onRemap(AffinityTopologyVersion topVer)

Specified by:
  `onRemap` in interface `IgniteInternalTx`
Parameters:
  `topVer` - New topology version.

#### hasTransforms

    public boolean hasTransforms()

Specified by:
  `hasTransforms` in interface `IgniteInternalTx`
Returns:
  `True` if transaction has transform entries. This flag will be only set for local transactions.

#### markPreparing

    public boolean markPreparing()

Specified by:
  `markPreparing` in interface `IgniteInternalTx`
Returns:
  `True` if preparing flag was set with this call.

#### markFinalizing

    public boolean markFinalizing(IgniteInternalTx.FinalizationStatus status)

Specified by:
  `markFinalizing` in interface `IgniteInternalTx`
Parameters:
  `status` - Finalization status to set.
Returns:
  `True` if marked.

#### finalizationStatus

    protected IgniteInternalTx.FinalizationStatus finalizationStatus()

Returns:
  Finalization status.

#### isStarted

    public abstract boolean isStarted()

Returns:
  `True` if transaction has at least one key enlisted.

#### size

    public int size()

Specified by:
  `size` in interface `IgniteInternalTx`
Returns:
  Size of the transaction.

#### log

    protected IgniteLogger log()

Returns:
  Logger.

#### near

    public boolean near()

Specified by:
  `near` in interface `IgniteInternalTx`
Returns:
  `True` if near transaction.

#### 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 `IgniteInternalTx`
Returns:
  `True` if transaction was started implicitly.

#### implicitSingle

    public boolean implicitSingle()

Specified by:
  `implicitSingle` in interface `IgniteInternalTx`
Returns:
  Flag indicating whether transaction is implicit with only one key.

#### local

    public boolean local()

Specified by:
  `local` in interface `IgniteInternalTx`
Returns:
  `True` if transaction is local, `false` if it's remote.

#### user

    public final boolean user()

Specified by:
  `user` in interface `IgniteInternalTx`
Returns:
  `True` if transaction is user transaction, which means:
  - Explicit
  - Local
  - Not DHT

#### dht

    public boolean dht()

Specified by:
  `dht` in interface `IgniteInternalTx`
Returns:
  `True` if DHT transaction.

#### colocated

    public boolean colocated()

Specified by:
  `colocated` in interface `IgniteInternalTx`
Returns:
  `True` if dht colocated transaction.

#### replicated

    public boolean replicated()

Specified by:
  `replicated` in interface `IgniteInternalTx`
Returns:
  `True` if transaction is replicated.

#### syncMode

    public CacheWriteSynchronizationMode syncMode()

Specified by:
  `syncMode` in interface `IgniteInternalTx`
Returns:
  Transaction write synchronization mode.

#### syncMode

    public void syncMode(CacheWriteSynchronizationMode syncMode)

Parameters:
  `syncMode` - Write synchronization mode.

#### xid

    public IgniteUuid xid()

Gets unique identifier for this transaction.

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

#### invalidPartitions

    public Map<Integer,Set<Integer>> invalidPartitions()

Specified by:
  `invalidPartitions` in interface `IgniteInternalTx`
Returns:
  Invalid partitions.

#### addInvalidPartition

    public void addInvalidPartition(GridCacheContext<?,?> cacheCtx,
                           int part)

Specified by:
  `addInvalidPartition` in interface `IgniteInternalTx`
Parameters:
  `cacheCtx` - Cache context.
  `part` - Invalid partition.

#### ownedVersion

    public GridCacheVersion ownedVersion(IgniteTxKey key)

Gets owned version for near remote transaction.

Specified by:
  `ownedVersion` in interface `IgniteInternalTx`
Parameters:
  `key` - Key to get version for.
Returns:
  Owned version, if any.

#### startTime

    public long startTime()

Start time of this transaction.

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

#### needReturnValue

    public boolean needReturnValue()

Returns:
  Flag indicating whether transaction needs return value.

#### needReturnValue

    public void needReturnValue(boolean needRetVal)

Parameters:
  `needRetVal` - Need return value flag.

#### remainingTime

    public long remainingTime()

Gets remaining allowed transaction time.

Specified by:
  `remainingTime` in interface `IgniteInternalTx`
Returns:
  Remaining transaction time. `0` if timeout isn't specified. `-1` if time is out.

#### timeoutException

    public final IgniteCheckedException timeoutException()

Returns:
  Transaction timeout exception.

#### xidVersion

    public GridCacheVersion xidVersion()

Specified by:
  `xidVersion` in interface `IgniteInternalTx`
Returns:
  Transaction version.

#### threadId

    public long threadId()

ID of the thread in which this transaction started.

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

#### nodeId

    public UUID nodeId()

ID of the node on which this transaction started.

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

#### isolation

    public TransactionIsolation isolation()

Cache transaction isolation level.

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

#### concurrency

    public TransactionConcurrency concurrency()

Cache transaction concurrency mode.

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

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

#### ownsLock

    public boolean ownsLock(GridCacheEntryEx entry)
                     throws GridCacheEntryRemovedException

Specified by:
  `ownsLock` in interface `IgniteInternalTx`
Parameters:
  `entry` - Entry to check.
Returns:
  `True` if lock is owned.
Throws:
  `GridCacheEntryRemovedException` - If entry has been removed.

#### ownsLockUnsafe

    public boolean ownsLockUnsafe(GridCacheEntryEx entry)

Specified by:
  `ownsLockUnsafe` in interface `IgniteInternalTx`
Parameters:
  `entry` - Entry to check.
Returns:
  `True` if lock is owned.

#### state

    public TransactionState state()

Gets current transaction state value.

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

#### errorWhenCommitting

    public final void errorWhenCommitting()

Changes transaction state from COMMITTING to MARKED_ROLLBACK. Must be called only from thread committing transaction.

Specified by:
  `errorWhenCommitting` in interface `IgniteInternalTx`

#### 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 `IgniteInternalTx`
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()

Description copied from interface: `IgniteInternalTx`
If transaction was marked as rollback-only.

Specified by:
  `isRollbackOnly` in interface `IgniteInternalTx`
Returns:
  `True` if rollback only flag is set.

#### done

    public boolean done()

Specified by:
  `done` in interface `IgniteInternalTx`
Returns:
  `True` if transaction had completed successfully or unsuccessfully.

#### commitVersion

    public GridCacheVersion commitVersion()

Specified by:
  `commitVersion` in interface `IgniteInternalTx`
Returns:
  Commit version.

#### commitVersion

    public void commitVersion(GridCacheVersion commitVer)

Specified by:
  `commitVersion` in interface `IgniteInternalTx`
Parameters:
  `commitVer` - Commit version.

#### close

    public void close()
               throws IgniteCheckedException

Description copied from interface: `IgniteInternalTx`
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 `IgniteInternalTx`
Throws:
  `IgniteCheckedException` - If transaction could not be gracefully ended.

#### needsCompletedVersions

    public boolean needsCompletedVersions()

Specified by:
  `needsCompletedVersions` in interface `IgniteInternalTx`
Returns:
  `True` if transaction needs completed versions for processing.

#### completedVersions

    public void completedVersions(GridCacheVersion base,
                         Collection<GridCacheVersion> committed,
                         Collection<GridCacheVersion> txs)

Specified by:
  `completedVersions` in interface `IgniteInternalTx`
Parameters:
  `base` - Base for committed versions.
  `committed` - Committed transactions relative to base.
  `txs` - Rolled back transactions relative to base.

#### internal

    public boolean internal()

Specified by:
  `internal` in interface `IgniteInternalTx`
Returns:
  `True` if transaction has at least one internal entry.

#### checkInternal

    protected boolean checkInternal(IgniteTxKey key)

Parameters:
  `key` - Key.
Returns:
  `True` if key is internal.

#### onePhaseCommit

    public void onePhaseCommit(boolean onePhaseCommit)

Parameters:
  `onePhaseCommit` - `True` if transaction commit should be performed in short-path way.

#### onePhaseCommit

    public boolean onePhaseCommit()

Specified by:
  `onePhaseCommit` in interface `IgniteInternalTx`
Returns:
  Fast commit flag.

#### optimistic

    public boolean optimistic()

Specified by:
  `optimistic` in interface `IgniteInternalTx`
Returns:
  `True` for OPTIMISTIC transactions.

#### pessimistic

    public boolean pessimistic()

Specified by:
  `pessimistic` in interface `IgniteInternalTx`
Returns:
  `True` for PESSIMISTIC transactions.

#### serializable

    public boolean serializable()

Specified by:
  `serializable` in interface `IgniteInternalTx`
Returns:
  `True` if serializable.

#### repeatableRead

    public boolean repeatableRead()

Specified by:
  `repeatableRead` in interface `IgniteInternalTx`
Returns:
  `True` if repeatable-read.

#### readCommitted

    public boolean readCommitted()

Specified by:
  `readCommitted` in interface `IgniteInternalTx`
Returns:
  `True` if read-committed.

#### state

    public boolean state(TransactionState state)

Specified by:
  `state` in interface `IgniteInternalTx`
Parameters:
  `state` - Transaction state.
Returns:
  `True` if transition was valid, `false` otherwise.

#### finishFuture

    public IgniteInternalFuture<IgniteInternalTx> finishFuture()

Specified by:
  `finishFuture` in interface `IgniteInternalTx`
Returns:
  Future for transaction completion.

#### currentPrepareFuture

    @Nullable
    public IgniteInternalFuture<?> currentPrepareFuture()

Specified by:
  `currentPrepareFuture` in interface `IgniteInternalTx`
Returns:
  Future for transaction prepare if prepare is in progress.

#### state

    protected boolean state(TransactionState state,
                boolean timedOut)

Parameters:
  `state` - State to set.
  `timedOut` - Timeout flag.
Returns:
  `True` if state changed.

#### endVersion

    public void endVersion(GridCacheVersion endVer)

Specified by:
  `endVersion` in interface `IgniteInternalTx`
Parameters:
  `endVer` - End version (a.k.a. `'tnc'` or `'transaction number counter'`) assigned to this transaction at the end of write phase.

#### writeVersion

    public GridCacheVersion writeVersion()

Specified by:
  `writeVersion` in interface `IgniteInternalTx`
Returns:
  Transaction write version. For all transactions except DHT transactions, will be equal to `IgniteInternalTx.xidVersion()`.

#### writeVersion

    public void writeVersion(GridCacheVersion writeVer)

Sets write version.

Specified by:
  `writeVersion` in interface `IgniteInternalTx`
Parameters:
  `writeVer` - Write version.

#### timedOut

    public boolean timedOut()

Specified by:
  `timedOut` in interface `IgniteInternalTx`
Returns:
  `True` if transaction timed out.

#### invalidate

    public void invalidate(boolean invalidate)

Specified by:
  `invalidate` in interface `IgniteInternalTx`
Parameters:
  `invalidate` - Invalidate flag.

#### 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 `IgniteInternalTx`
Returns:
  Invalidation flag.

#### isSystemInvalidate

    public boolean isSystemInvalidate()

Specified by:
  `isSystemInvalidate` in interface `IgniteInternalTx`
Returns:
  System invalidate flag.

#### systemInvalidate

    public void systemInvalidate(boolean sysInvalidate)

Specified by:
  `systemInvalidate` in interface `IgniteInternalTx`
Parameters:
  `sysInvalidate` - System invalidate flag.

#### transactionNodes

    @Nullable
    public Map<UUID,Collection<UUID>> transactionNodes()

Specified by:
  `transactionNodes` in interface `IgniteInternalTx`
Returns:
  Transaction nodes mapping (primary node -> related backup nodes).

#### transactionNodes

    public void transactionNodes(Map<UUID,Collection<UUID>> txNodes)

Parameters:
  `txNodes` - Transaction nodes.

#### nearXidVersion

    @Nullable
    public GridCacheVersion nearXidVersion()

Specified by:
  `nearXidVersion` in interface `IgniteInternalTx`
Returns:
  Near transaction ID.

#### isWriteToStoreFromDhtValid

    protected boolean isWriteToStoreFromDhtValid(Collection<CacheStoreManager> stores)

Parameters:
  `stores` - Store managers.
Returns:
  If `isWriteToStoreFromDht` value same for all stores.

#### sessionEnd

    protected void sessionEnd(Collection<CacheStoreManager> stores,
                  boolean commit)
                       throws IgniteCheckedException

Parameters:
  `stores` - Store managers.
  `commit` - Commit flag.
Throws:
  `IgniteCheckedException` - In case of error.

#### batchStoreCommit

    protected void batchStoreCommit(Iterable<IgniteTxEntry> writeEntries)
                             throws IgniteCheckedException

Performs batch database operations. This commit must be called before cache update. This way if there is a DB failure, cache transaction can still be rolled back.

Parameters:
  `writeEntries` - Transaction write set.
Throws:
  `IgniteCheckedException` - If batch update failed.

#### applyTransformClosures

    protected IgniteBiTuple<GridCacheOperation,CacheObject> applyTransformClosures(IgniteTxEntry txEntry,
                                                                       boolean metrics,
                                                                       @Nullable
                                                                       GridCacheReturn ret)
                                                                            throws GridCacheEntryRemovedException,
                                                                                   IgniteCheckedException

Parameters:
  `txEntry` - Entry to process.
  `metrics` - `True` if metrics should be updated.
  `ret` - Optional return value to initialize.
Returns:
  Tuple containing transformation results.
Throws:
  `IgniteCheckedException` - If failed to get previous value for transform.
  `GridCacheEntryRemovedException` - If entry was concurrently deleted.

#### resolveTaskName

    public String resolveTaskName()

Returns:
  Resolves task name.

#### conflictResolve

    protected IgniteBiTuple<GridCacheOperation,GridCacheVersionConflictContext> conflictResolve(GridCacheOperation op,
                                                                                    IgniteTxEntry txEntry,
                                                                                    CacheObject newVal,
                                                                                    GridCacheVersion newVer,
                                                                                    GridCacheEntryEx old)
                                                                                         throws IgniteCheckedException,
                                                                                                GridCacheEntryRemovedException

Resolve DR conflict.

Parameters:
  `op` - Initially proposed operation.
  `txEntry` - TX entry being updated.
  `newVal` - New value.
  `newVer` - New version.
  `old` - Old entry.
Returns:
  Tuple with adjusted operation type and conflict context.
Throws:
  `IgniteCheckedException` - In case of eny exception.
  `GridCacheEntryRemovedException` - If entry got removed.

#### isNearLocallyMapped

    protected boolean isNearLocallyMapped(IgniteTxEntry e,
                              boolean primaryOnly)

Parameters:
  `e` - Transaction entry.
  `primaryOnly` - Flag to include backups into check or not.
Returns:
  `True` if entry is locally mapped as a primary or back up node.

#### evictNearEntry

    protected boolean evictNearEntry(IgniteTxEntry e,
                         boolean primaryOnly)

Parameters:
  `e` - Entry to evict if it qualifies for eviction.
  `primaryOnly` - Flag to try to evict only on primary node.
Returns:
  `True` if attempt was made to evict the entry.

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

#### readResolve

    protected Object readResolve()
                          throws ObjectStreamException

Reconstructs object on unmarshalling.

Returns:
  Reconstructed object.
Throws:
  `ObjectStreamException` - Thrown in case of unmarshalling error.

#### proxy

    public TransactionProxy proxy()

Specified by:
  `proxy` in interface `IgniteInternalTx`
Returns:
  Public API proxy.

#### equals

    public boolean equals(Object o)

Overrides:
  `equals` in class `Object`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

2017 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.9.0
Release Date | : March 2 2017