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

## Class GridDhtTxLocalAdapter<K,V>

- java.lang.Object
- - org.apache.ignite.internal.util.lang.GridMetadataAwareAdapter
  - - org.apache.ignite.internal.processors.cache.transactions.IgniteTxAdapter<K,V>
    - - org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter<K,V>
      - - org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxLocalAdapter<K,V>

All Implemented Interfaces:
  Externalizable, Serializable, AutoCloseable, IgniteInternalTx<K,V>, IgniteTxLocalEx<K,V>, GridTimeoutObject

Direct Known Subclasses:
  GridDhtTxLocal, GridNearTxLocal

    public abstract class GridDhtTxLocalAdapter<K,V>
    extends IgniteTxLocalAdapter<K,V>

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
`protected Map<UUID,GridDistributedTxMapping<K,V>>` `dhtMap` DHT mappings.
`protected Map<UUID,GridDistributedTxMapping<K,V>>` `nearMap` Near mappings.

### 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
`protected` `GridDhtTxLocalAdapter()` Empty constructor required for `Externalizable`.
`protected` `GridDhtTxLocalAdapter(GridCacheSharedContext<K,V> cctx, GridCacheVersion xidVer, boolean implicit, boolean implicitSingle, boolean sys, TransactionConcurrency concurrency, TransactionIsolation isolation, long timeout, boolean invalidate, boolean storeEnabled, int txSize, IgniteTxKey grpLockKey, boolean partLock, UUID subjId, int taskNameHash)`

### Method Summary

Methods
`void` `addDhtMapping(Map<UUID,GridDistributedTxMapping<K,V>> mappings)`
`IgniteInternalFuture<Boolean>` `addEntry(long msgId, IgniteTxEntry<K,V> e)`
`protected void` `addGroupTxMapping(Collection<IgniteTxKey<K>> keys)` Adds key mapping to transaction.
`void` `addInvalidPartition(GridCacheContext<K,V> ctx, int part)`
`void` `addNearMapping(Map<UUID,GridDistributedTxMapping<K,V>> mappings)`
`protected abstract IgniteInternalFuture<Boolean>` `addReader(long msgId, GridDhtCacheEntry<K,V> cached, IgniteTxEntry<K,V> entry, long topVer)` Adds reader to cached entry.
`protected abstract void` `clearPrepareFuture(GridDhtTxPrepareFuture<K,V> fut)` Removes previously created prepare future from atomic reference.
`boolean` `finish(boolean commit)` Finishes transaction (either commit or rollback).
`protected void` `mapExplicitLocks()` Map explicit locks.
`protected abstract IgniteUuid` `nearFutureId()`
`protected abstract IgniteUuid` `nearMiniId()`
`protected abstract UUID` `nearNodeId()`
`boolean` `needsCompletedVersions()`
`void` `needsCompletedVersions(boolean needsCompletedVers)`
`Collection<GridCacheVersion>` `pendingVersions()`
`void` `pendingVersions(Collection<GridCacheVersion> pendingVers)`
`boolean` `removeMapping(UUID nodeId)`
`void` `rollback()` Rolls back this transaction.
`protected abstract void` `sendFinishReply(boolean commit, Throwable err)`
`String` `toString()`

### 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, entryTtl, eventNodeId, getAllAsync, groupLockAsync, hasWriteKey, implicitSingleResult, implicitSingleResult, init, invokeAsync, isStarted, loadMissing, masterNodeIds, minVersion, needReturnValue, needReturnValue, onOwnerChanged, originatingNodeId, partitionLock, peek, postLockWrite, prepare, putAllAsync, putAllDrAsync, readEntries, readMap, readSet, removeAllAsync, removeAllDrAsync, removed, rolledbackVersions, seal, sendTransformedValues, tmCommit, updateExplicitVersion, 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, dht, 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, lock, lockTimeout, log, markFinalizing, markPreparing, near, nearXidVersion, nodeId, onePhaseCommit, onePhaseCommit, onTimeout, optimistic, optimisticLockEntries, otherNodeId, 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, updateNearCache, 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, 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, commitAsync, commitVersion, commitVersion, concurrency, dht, done, endVersion, endVersion, enforceSerializable, finishFuture, groupLock, groupLockKey, hasTransforms, implicit, implicitSingle, internal, invalidate, invalidPartitions, ioPolicy, isInvalidate, isolation, isRollbackOnly, isSystemInvalidate, local, markFinalizing, markPreparing, meta, near, nearXidVersion, nodeId, onePhaseCommit, optimistic, optimisticLockEntries, otherNodeId, ownedVersion, ownsLock, ownsLockUnsafe, pessimistic, prepareAsync, proxy, readCommitted, remainingTime, removeMeta, repeatableRead, replicated, rollbackAsync, 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`

### Field Detail

#### nearMap

    protected Map<UUID,GridDistributedTxMapping<K,V>> nearMap

Near mappings.

#### dhtMap

    protected Map<UUID,GridDistributedTxMapping<K,V>> dhtMap

DHT mappings.

### Constructor Detail

#### GridDhtTxLocalAdapter

    protected GridDhtTxLocalAdapter()

Empty constructor required for `Externalizable`.

#### GridDhtTxLocalAdapter

    protected GridDhtTxLocalAdapter(GridCacheSharedContext<K,V> cctx,
                         GridCacheVersion xidVer,
                         boolean implicit,
                         boolean implicitSingle,
                         boolean sys,
                         TransactionConcurrency concurrency,
                         TransactionIsolation isolation,
                         long timeout,
                         boolean invalidate,
                         boolean storeEnabled,
                         int txSize,
                         @Nullable
                         IgniteTxKey grpLockKey,
                         boolean partLock,
                         @Nullable
                         UUID subjId,
                         int taskNameHash)

Parameters:
  `xidVer` - Transaction version.
  `implicit` - Implicit flag.
  `implicitSingle` - Implicit-with-single-key flag.
  `cctx` - Cache context.
  `sys` - System flag.
  `concurrency` - Concurrency.
  `isolation` - Isolation.
  `timeout` - Timeout.
  `txSize` - Expected transaction size.
  `grpLockKey` - Group lock key if this is a group-lock transaction.
  `partLock` - If this is a group-lock transaction and the whole partition should be locked.

### Method Detail

#### nearNodeId

    protected abstract UUID nearNodeId()

Returns:
  Near node id.

#### nearFutureId

    protected abstract IgniteUuid nearFutureId()

Returns:
  Near future ID.

#### nearMiniId

    protected abstract IgniteUuid nearMiniId()

Returns:
  Near future mini ID.

#### addReader

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

Adds reader to cached entry.

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.

#### sendFinishReply

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

Parameters:
  `commit` - Commit flag.
  `err` - Error, if any.

#### needsCompletedVersions

    public void needsCompletedVersions(boolean needsCompletedVers)

Parameters:
  `needsCompletedVers` - `True` if needs completed versions.

#### needsCompletedVersions

    public boolean needsCompletedVersions()

Specified by:
  `needsCompletedVersions` in interface `IgniteInternalTx<K,V>`
Overrides:
  `needsCompletedVersions` in class `IgniteTxAdapter<K,V>`
Returns:
  `True` if transaction needs completed versions for processing.

#### pendingVersions

    public Collection<GridCacheVersion> pendingVersions()

Returns:
  Versions for all pending locks that were in queue before tx locks were released.

#### pendingVersions

    public void pendingVersions(Collection<GridCacheVersion> pendingVers)

Parameters:
  `pendingVers` - Versions for all pending locks that were in queue before tx locsk were released.

#### mapExplicitLocks

    protected void mapExplicitLocks()

Map explicit locks.

#### addDhtMapping

    public void addDhtMapping(Map<UUID,GridDistributedTxMapping<K,V>> mappings)

Parameters:
  `mappings` - Mappings to add.

#### addNearMapping

    public void addNearMapping(Map<UUID,GridDistributedTxMapping<K,V>> mappings)

Parameters:
  `mappings` - Mappings to add.

#### removeMapping

    public boolean removeMapping(UUID nodeId)

Parameters:
  `nodeId` - Node ID.
Returns:
  `True` if mapping was removed.

#### addInvalidPartition

    public void addInvalidPartition(GridCacheContext<K,V> ctx,
                           int part)

Specified by:
  `addInvalidPartition` in interface `IgniteInternalTx<K,V>`
Overrides:
  `addInvalidPartition` in class `IgniteTxAdapter<K,V>`
Parameters:
  `ctx` - Cache context.
  `part` - Invalid partition.

#### addEntry

    @Nullable
    public IgniteInternalFuture<Boolean> addEntry(long msgId,
                                                  IgniteTxEntry<K,V> e)
                                           throws IgniteCheckedException

Parameters:
  `msgId` - Message ID.
  `e` - Entry to add.
Returns:
  Future for active transactions for the time when reader was added.
Throws:
  `IgniteCheckedException` - If failed.

#### addGroupTxMapping

    protected void addGroupTxMapping(Collection<IgniteTxKey<K>> keys)

Adds key mapping to transaction.

Overrides:
  `addGroupTxMapping` in class `IgniteTxLocalAdapter<K,V>`
Parameters:
  `keys` - Keys to add.

#### finish

    public boolean finish(boolean commit)
                   throws IgniteCheckedException

Finishes transaction (either commit or rollback).

Parameters:
  `commit` - `True` if commit, `false` if rollback.
Returns:
  `True` if state has been changed.
Throws:
  `IgniteCheckedException` - If finish failed.

#### clearPrepareFuture

    protected abstract void clearPrepareFuture(GridDhtTxPrepareFuture<K,V> fut)

Removes previously created prepare future from atomic reference.

Parameters:
  `fut` - Expected future.

#### rollback

    public void rollback()
                  throws IgniteCheckedException

Rolls back this transaction.

Throws:
  `IgniteCheckedException` - If rollback failed.

#### toString

    public String toString()

Overrides:
  `toString` in class `IgniteTxLocalAdapter<K,V>`

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.0.0-RC1
Release Date | : February 17 2015