org.apache.ignite.internal.processors.cache.distributed.dht

## Class GridDhtTxLocal

- java.lang.Object
- - org.apache.ignite.internal.util.lang.GridMetadataAwareAdapter
  - - org.apache.ignite.internal.processors.cache.transactions.IgniteTxAdapter
    - - org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter
      - - org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxLocalAdapter
        - - org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxLocal

All Implemented Interfaces:
  Externalizable, Serializable, AutoCloseable, GridCacheMappedVersion, IgniteInternalTx, IgniteTxLocalEx, GridTimeoutObject

    public class GridDhtTxLocal
    extends GridDhtTxLocalAdapter
    implements GridCacheMappedVersion

Replicated user transaction.

See Also:
  Serialized Form

### Nested Class Summary

### Nested classes/interfaces inherited from class org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter

`IgniteTxLocalAdapter.FinishClosure<T>, IgniteTxLocalAdapter.PLC1<T>, IgniteTxLocalAdapter.PLC2<T>, IgniteTxLocalAdapter.PMC<T>, IgniteTxLocalAdapter.PostLockClosure1<T>, IgniteTxLocalAdapter.PostLockClosure2<T>, IgniteTxLocalAdapter.PostMissClosure<T>`

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

`IgniteInternalTx.FinalizationStatus`

### Field Summary

### Fields inherited from class org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxLocalAdapter

`dhtMap, nearMap`

### Fields inherited from class org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter

`activeCacheIds, commitErr, doneFlag, implicitRes, minVer, needRetVal, readView, txMap, writeView`

### Fields inherited from class org.apache.ignite.internal.processors.cache.transactions.IgniteTxAdapter

`cctx, concurrency, endVer, grpLockKey, implicit, implicitSingle, internal, invalidate, isDone, isolation, loc, log, nodeId, onePhaseCommit, startTime, startVer, storeEnabled, subjId, syncCommit, syncRollback, taskName, taskNameHash, threadId, timeout, transform, txNodes, txSize, writeVer, xidVer`

### Constructor Summary

Constructors
Constructor and Description
`GridDhtTxLocal()` Empty constructor required for `Externalizable`.

`GridDhtTxLocal(GridCacheSharedContext cctx, UUID nearNodeId, GridCacheVersion nearXidVer, IgniteUuid nearFutId, IgniteUuid nearMiniId, long nearThreadId, boolean implicit, boolean implicitSingle, boolean sys, GridIoPolicy plc, TransactionConcurrency concurrency, TransactionIsolation isolation, long timeout, boolean invalidate, boolean storeEnabled, int txSize, IgniteTxKey grpLockKey, boolean partLock, Map<UUID,Collection<UUID>> txNodes, UUID subjId, int taskNameHash)`

### Method Summary

Methods
`protected IgniteInternalFuture<Boolean>` `addReader(long msgId, GridDhtCacheEntry cached, IgniteTxEntry entry, long topVer)` Adds reader to cached entry.
`protected void` `clearPrepareFuture(GridDhtTxPrepareFuture fut)` Removes previously created prepare future from atomic reference.
`IgniteInternalFuture<IgniteInternalTx>` `commitAsync()` Asynchronously commits this transaction by initiating `two-phase-commit` process.
`boolean` `dht()`
`UUID` `eventNodeId()`
`boolean` `finish(boolean commit)` Finishes transaction (either commit or rollback).
`GridCacheVersion` `mappedVersion()` Mapping should occur only if this interface returns a non-null value.
`Collection<UUID>` `masterNodeIds()`
`IgniteUuid` `nearFinishFutureId()`
`void` `nearFinishFutureId(IgniteUuid nearFinFutId)`
`IgniteUuid` `nearFinishMiniId()`
`void` `nearFinishMiniId(IgniteUuid nearFinMiniId)`
`protected IgniteUuid` `nearFutureId()`
`void` `nearFutureId(IgniteUuid nearFutId)`
`protected IgniteUuid` `nearMiniId()`
`protected UUID` `nearNodeId()`
`GridCacheVersion` `nearXidVersion()`
`UUID` `originatingNodeId()` Gets node ID which directly started this transaction.
`UUID` `otherNodeId()` Gets ID of additional node involved.
`IgniteInternalFuture<IgniteInternalTx>` `prepareAsync()` Prepare stage.
`IgniteInternalFuture<IgniteInternalTx>` `prepareAsync(Iterable<IgniteTxEntry> reads, Iterable<IgniteTxEntry> writes, Map<IgniteTxKey,GridCacheVersion> verMap, long msgId, IgniteUuid nearMiniId, Map<UUID,Collection<UUID>> txNodes, boolean last, Collection<UUID> lastBackups, IgniteInClosure<GridNearTxPrepareResponse> completeCb)` Prepares next batch of entries in dht transaction.
`IgniteInternalFuture<IgniteInternalTx>` `rollbackAsync()` Asynchronously rollback this transaction.
`protected void` `sendFinishReply(boolean commit, Throwable err)`
`String` `toString()`
`protected void` `updateExplicitVersion(IgniteTxEntry txEntry, GridCacheEntryEx entry)` Updates explicit version for tx entry based on current entry lock owner.
`protected boolean` `updateNearCache(GridCacheContext cacheCtx, KeyCacheObject key, long topVer)` Checks whether near cache should be updated.

### Methods inherited from class org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxLocalAdapter

`addDhtMapping, addEntry, addGroupTxMapping, addInvalidPartition, addNearMapping, mapExplicitLocks, needsCompletedVersions, needsCompletedVersions, pendingVersions, pendingVersions, removeMapping, rollback`

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

`accessPolicy, activeCacheIds, addActiveCache, addEntry, allEntries, alternateVersions, batchStoreCommit, checkValid, commit, commitAfterLock, commitError, commitError, committedVersions, completedBase, completedVersions, empty, enlistWrite, entry, entryEx, entryEx, entryExpireTime, entryTtl, getAllAsync, groupLockAsync, hasWriteKey, implicitSingleResult, implicitSingleResult, init, initResult, invokeAsync, isStarted, loadMissing, minVersion, needReturnValue, needReturnValue, onOwnerChanged, partitionLock, peek, postLockWrite, prepare, putAllAsync, putAllDrAsync, readEntries, readMap, readSet, removeAllAsync, removeAllDrAsync, removed, rolledbackVersions, seal, sendTransformedValues, tmCommit, userCommit, userPrepare, userRollback, writeEntries, writeMap, writeSet`

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

`applyTransformClosures, awaitCompletion, awaitSignal, checkInternal, close, colocated, commitVersion, commitVersion, concurrency, conflictResolve, done, endTime, endVersion, endVersion, enforceSerializable, equals, evictNearEntry, finalizationStatus, finishFuture, groupLock, groupLockEntry, groupLockKey, hashCode, hasTransforms, implicit, implicitSingle, initCommitVersion, internal, invalidate, invalidPartitions, ioPolicy, isInvalidate, isNearLocallyMapped, isolation, isRollbackOnly, isSystemInvalidate, local, localResult, lock, lockTimeout, log, markFinalizing, markPreparing, near, nodeId, onePhaseCommit, onePhaseCommit, onTimeout, optimistic, optimisticLockEntries, ownedVersion, ownsLock, ownsLockUnsafe, pessimistic, proxy, readCommitted, readExternal, readResolve, remainingTime, repeatableRead, replicated, resolveTaskName, serializable, setRollbackOnly, signalAll, size, startTime, startVersion, state, state, store, storeEnabled, storeEnabled, storeUsed, subjectId, syncCommit, syncCommit, syncRollback, syncRollback, system, systemInvalidate, taskNameHash, threadId, timedOut, timeout, timeout, timeoutId, topologyVersion, topologyVersion, transactionNodes, transactionNodes, uncommit, unlock, user, writeExternal, writeVersion, writeVersion, xid, xidVersion`

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

`addMeta, addMetaIfAbsent, addMetaIfAbsent, allMeta, clone, copyMeta, copyMeta, hasMeta, hasMeta, meta, putMetaIfAbsent, readExternalMeta, 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.IgniteTxLocalEx

`groupLockEntry`

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

`addMeta, close, colocated, commitVersion, commitVersion, concurrency, done, endVersion, endVersion, enforceSerializable, finishFuture, groupLock, groupLockKey, hasTransforms, implicit, implicitSingle, internal, invalidate, invalidPartitions, ioPolicy, isInvalidate, isolation, isRollbackOnly, isSystemInvalidate, local, localResult, markFinalizing, markPreparing, meta, near, nodeId, onePhaseCommit, optimistic, optimisticLockEntries, ownedVersion, ownsLock, ownsLockUnsafe, pessimistic, proxy, readCommitted, remainingTime, removeMeta, repeatableRead, replicated, serializable, setRollbackOnly, size, startTime, startVersion, state, state, storeEnabled, storeUsed, subjectId, syncCommit, syncRollback, system, systemInvalidate, taskNameHash, threadId, timedOut, timeout, timeout, topologyVersion, topologyVersion, transactionNodes, user, writeVersion, writeVersion, xid, xidVersion`

### Methods inherited from interface org.apache.ignite.internal.processors.timeout.GridTimeoutObject

`endTime, onTimeout, timeoutId`

### Constructor Detail

#### GridDhtTxLocal

    public GridDhtTxLocal()

Empty constructor required for `Externalizable`.

#### GridDhtTxLocal

    public GridDhtTxLocal(GridCacheSharedContext cctx,
                  UUID nearNodeId,
                  GridCacheVersion nearXidVer,
                  IgniteUuid nearFutId,
                  IgniteUuid nearMiniId,
                  long nearThreadId,
                  boolean implicit,
                  boolean implicitSingle,
                  boolean sys,
                  GridIoPolicy plc,
                  TransactionConcurrency concurrency,
                  TransactionIsolation isolation,
                  long timeout,
                  boolean invalidate,
                  boolean storeEnabled,
                  int txSize,
                  @Nullable
                  IgniteTxKey grpLockKey,
                  boolean partLock,
                  Map<UUID,Collection<UUID>> txNodes,
                  UUID subjId,
                  int taskNameHash)

Parameters:
  `nearNodeId` - Near node ID that initiated transaction.
  `nearXidVer` - Near transaction ID.
  `nearFutId` - Near future ID.
  `nearMiniId` - Near mini future ID.
  `nearThreadId` - Near thread ID.
  `implicit` - Implicit flag.
  `implicitSingle` - Implicit-with-single-key flag.
  `cctx` - Cache context.
  `concurrency` - Concurrency.
  `isolation` - Isolation.
  `timeout` - Timeout.
  `storeEnabled` - Store enabled flag.
  `txSize` - Expected transaction size.
  `grpLockKey` - Group lock key if this is a group-lock transaction.
  `partLock` - `True` if this is a group-lock transaction and whole partition should be locked.
  `txNodes` - Transaction nodes mapping.

### Method Detail

#### eventNodeId

    public UUID eventNodeId()

Specified by:
  `eventNodeId` in interface `IgniteInternalTx`
Overrides:
  `eventNodeId` in class `IgniteTxLocalAdapter`
Returns:
  Event node ID.

#### masterNodeIds

    public Collection<UUID> masterNodeIds()

Specified by:
  `masterNodeIds` in interface `IgniteInternalTx`
Overrides:
  `masterNodeIds` in class `IgniteTxLocalAdapter`
Returns:
  Master node IDs.

#### 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`
Overrides:
  `otherNodeId` in class `IgniteTxAdapter`
Returns:
  Parent node IDs.

#### originatingNodeId

    public UUID originatingNodeId()

Gets node ID which directly started this transaction. In case of DHT local transaction it will be near node ID, in case of DHT remote transaction it will be primary node ID, in case of replicated remote transaction it will be starter node ID.

Specified by:
  `originatingNodeId` in interface `IgniteInternalTx`
Overrides:
  `originatingNodeId` in class `IgniteTxLocalAdapter`
Returns:
  Originating node ID.

#### nearNodeId

    protected UUID nearNodeId()

Specified by:
  `nearNodeId` in class `GridDhtTxLocalAdapter`
Returns:
  Near node id.

#### nearXidVersion

    public GridCacheVersion nearXidVersion()

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

#### mappedVersion

    public GridCacheVersion mappedVersion()

Mapping should occur only if this interface returns a non-null value.

Specified by:
  `mappedVersion` in interface `GridCacheMappedVersion`
Returns:
  Mapped version.

#### nearFutureId

    protected IgniteUuid nearFutureId()

Specified by:
  `nearFutureId` in class `GridDhtTxLocalAdapter`
Returns:
  Near future ID.

#### nearFutureId

    public void nearFutureId(IgniteUuid nearFutId)

Parameters:
  `nearFutId` - Near future ID.

#### nearMiniId

    protected IgniteUuid nearMiniId()

Specified by:
  `nearMiniId` in class `GridDhtTxLocalAdapter`
Returns:
  Near future mini ID.

#### dht

    public boolean dht()

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

#### updateNearCache

    protected boolean updateNearCache(GridCacheContext cacheCtx,
                          KeyCacheObject key,
                          long topVer)

Checks whether near cache should be updated.

Overrides:
  `updateNearCache` in class `IgniteTxAdapter`
Returns:
  Flag indicating whether near cache should be updated.

#### nearFinishFutureId

    public IgniteUuid nearFinishFutureId()

Returns:
  Near future ID.

#### nearFinishFutureId

    public void nearFinishFutureId(IgniteUuid nearFinFutId)

Parameters:
  `nearFinFutId` - Near future ID.

#### nearFinishMiniId

    public IgniteUuid nearFinishMiniId()

Returns:
  Near future mini ID.

#### nearFinishMiniId

    public void nearFinishMiniId(IgniteUuid nearFinMiniId)

Parameters:
  `nearFinMiniId` - Near future mini ID.

#### addReader

    @Nullable
    protected IgniteInternalFuture<Boolean> addReader(long msgId,
                                                   GridDhtCacheEntry cached,
                                                   IgniteTxEntry entry,
                                                   long topVer)

Adds reader to cached entry.

Specified by:
  `addReader` in class `GridDhtTxLocalAdapter`
Parameters:
  `msgId` - Message ID.
  `cached` - Cached entry.
  `entry` - Transaction entry.
  `topVer` - Topology version.
Returns:
  `True` if reader was added as a result of this call.

#### updateExplicitVersion

    protected void updateExplicitVersion(IgniteTxEntry txEntry,
                             GridCacheEntryEx entry)
                                  throws GridCacheEntryRemovedException

Updates explicit version for tx entry based on current entry lock owner.

Overrides:
  `updateExplicitVersion` in class `IgniteTxLocalAdapter`
Parameters:
  `txEntry` - Tx entry to update.
  `entry` - Entry.
Throws:
  `GridCacheEntryRemovedException` - If entry was concurrently removed.

#### prepareAsync

    public IgniteInternalFuture<IgniteInternalTx> prepareAsync()

Prepare stage.

Specified by:
  `prepareAsync` in interface `IgniteInternalTx`
Returns:
  Future for prepare step.

#### prepareAsync

    public IgniteInternalFuture<IgniteInternalTx> prepareAsync(@Nullable
                                                      Iterable<IgniteTxEntry> reads,
                                                      @Nullable
                                                      Iterable<IgniteTxEntry> writes,
                                                      Map<IgniteTxKey,GridCacheVersion> verMap,
                                                      long msgId,
                                                      IgniteUuid nearMiniId,
                                                      Map<UUID,Collection<UUID>> txNodes,
                                                      boolean last,
                                                      Collection<UUID> lastBackups,
                                                      IgniteInClosure<GridNearTxPrepareResponse> completeCb)

Prepares next batch of entries in dht transaction.

Parameters:
  `reads` - Read entries.
  `writes` - Write entries.
  `verMap` - Version map.
  `msgId` - Message ID.
  `nearMiniId` - Near mini future ID.
  `txNodes` - Transaction nodes mapping.
  `last` - `True` if this is last prepare request.
  `lastBackups` - IDs of backup nodes receiving last prepare request.
Returns:
  Future that will be completed when locks are acquired.

#### commitAsync

    public IgniteInternalFuture<IgniteInternalTx> commitAsync()

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

Specified by:
  `commitAsync` in interface `IgniteInternalTx`
Returns:
  Future for commit operation.

#### clearPrepareFuture

    protected void clearPrepareFuture(GridDhtTxPrepareFuture fut)

Removes previously created prepare future from atomic reference.

Specified by:
  `clearPrepareFuture` in class `GridDhtTxLocalAdapter`
Parameters:
  `fut` - Expected future.

#### rollbackAsync

    public IgniteInternalFuture<IgniteInternalTx> rollbackAsync()

Asynchronously rollback this transaction.

Specified by:
  `rollbackAsync` in interface `IgniteInternalTx`
Returns:
  Rollback future.

#### finish

    public boolean finish(boolean commit)
                   throws IgniteCheckedException

Finishes transaction (either commit or rollback).

Specified by:
  `finish` in interface `IgniteTxLocalEx`
Overrides:
  `finish` in class `GridDhtTxLocalAdapter`
Parameters:
  `commit` - `True` if commit, `false` if rollback.
Returns:
  `True` if state has been changed.
Throws:
  `IgniteCheckedException` - If finish failed.

#### sendFinishReply

    protected void sendFinishReply(boolean commit,
                       @Nullable
                       Throwable err)

Specified by:
  `sendFinishReply` in class `GridDhtTxLocalAdapter`
Parameters:
  `commit` - Commit flag.
  `err` - Error, if any.

#### toString

    public String toString()

Overrides:
  `toString` in class `GridDhtTxLocalAdapter`

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.0.0-RC3
Release Date | : March 24 2015