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

## Class GridDistributedTxRemoteAdapter

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

All Implemented Interfaces:
  Externalizable, Serializable, AutoCloseable, IgniteInternalTx, IgniteTxRemoteEx, GridTimeoutObject

Direct Known Subclasses:
  GridDhtTxRemote, GridNearTxRemote

    public class GridDistributedTxRemoteAdapter
    extends IgniteTxAdapter
    implements IgniteTxRemoteEx

Transaction created by system implicitly on remote nodes.

See Also:
  Serialized Form

### Nested Class Summary

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

`IgniteInternalTx.FinalizationStatus`

### Field Summary

Fields
`protected Map<IgniteTxKey,IgniteTxEntry>` `readMap` Read set.
`protected Map<IgniteTxKey,IgniteTxEntry>` `writeMap` Write map.

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

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

### Constructor Summary

Constructors
Constructor and Description
`GridDistributedTxRemoteAdapter()` Empty constructor required for `Externalizable`.
`GridDistributedTxRemoteAdapter(GridCacheSharedContext<?,?> ctx, UUID nodeId, long rmtThreadId, GridCacheVersion xidVer, GridCacheVersion commitVer, boolean sys, byte plc, TransactionConcurrency concurrency, TransactionIsolation isolation, boolean invalidate, long timeout, int txSize, UUID subjId, int taskNameHash)`

### Method Summary

Methods
`Collection<Integer>` `activeCacheIds()`
`protected void` `addExplicit(IgniteTxEntry e)` Adds explicit version if there is one.
`Collection<IgniteTxEntry>` `allEntries()`
`Collection<GridCacheVersion>` `alternateVersions()`
`void` `clearEntry(IgniteTxKey key)` Clears entry from transaction as it never happened.
`void` `commit()` Commits this transaction by initiating `two-phase-commit` process.
`IgniteInternalFuture<IgniteInternalTx>` `commitAsync()` Asynchronously commits this transaction by initiating `two-phase-commit` process.
`void` `doneRemote(GridCacheVersion baseVer, Collection<GridCacheVersion> committedVers, Collection<GridCacheVersion> rolledbackVers, Collection<GridCacheVersion> pendingVers)`
`boolean` `empty()`
`IgniteTxEntry` `entry(IgniteTxKey key)`
`UUID` `eventNodeId()`
`void` `forceCommit()` Forces commit for this tx.
`boolean` `hasWriteKey(IgniteTxKey key)`
`void` `invalidate(boolean invalidate)`
`boolean` `isStarted()`
`Collection<UUID>` `masterNodeIds()`
`boolean` `onOwnerChanged(GridCacheEntryEx entry, GridCacheMvccCandidate owner)` Callback invoked whenever there is a lock that has been acquired by this transaction for any of the participating entries.
`UUID` `originatingNodeId()` Gets node ID which directly started this transaction.
`GridTuple<CacheObject>` `peek(GridCacheContext cacheCtx, boolean failFast, KeyCacheObject key, CacheEntryPredicate[] filter)`
`void` `prepare()` Prepare phase.
`IgniteInternalFuture<IgniteInternalTx>` `prepareAsync()` Prepare stage.
`Collection<IgniteTxEntry>` `readEntries()`
`Map<IgniteTxKey,IgniteTxEntry>` `readMap()`
`Set<IgniteTxKey>` `readSet()`
`long` `remoteThreadId()`
`boolean` `removed(IgniteTxKey key)` Checks whether given key has been removed within transaction.
`void` `rollback()` Rolls back this transaction.
`IgniteInternalFuture<IgniteInternalTx>` `rollbackAsync()` Asynchronously rollback this transaction.
`void` `seal()` Seals transaction for updates.
`boolean` `setWriteValue(IgniteTxEntry e)`
`String` `toString()`
`Collection<IgniteTxEntry>` `writeEntries()`
`Map<IgniteTxKey,IgniteTxEntry>` `writeMap()`
`Set<IgniteTxKey>` `writeSet()`

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

`addInvalidPartition, applyTransformClosures, awaitCompletion, awaitSignal, checkInternal, close, colocated, commitVersion, commitVersion, completedVersions, concurrency, conflictResolve, currentPrepareFuture, dht, done, endTime, endVersion, endVersion, enforceSerializable, equals, evictNearEntry, finalizationStatus, finishFuture, hashCode, hasTransforms, implicit, implicitSingle, initCommitVersion, internal, invalidPartitions, ioPolicy, isInvalidate, isNearLocallyMapped, isolation, isRollbackOnly, isSystemInvalidate, local, localResult, lock, lockTimeout, log, markFinalizing, markPreparing, near, nearXidVersion, needsCompletedVersions, nodeId, onePhaseCommit, onePhaseCommit, onRemap, onTimeout, optimistic, optimisticLockEntries, otherNodeId, ownedVersion, ownsLock, ownsLockUnsafe, pessimistic, proxy, readCommitted, readExternal, readResolve, remainingTime, repeatableRead, replicated, resolveTaskName, serializable, setRollbackOnly, signalAll, size, startTime, startVersion, state, state, storeEnabled, storeEnabled, stores, storeUsed, subjectId, syncCommit, syncCommit, syncRollback, syncRollback, system, systemInvalidate, taskNameHash, threadId, timedOut, timeout, timeout, timeoutId, topologyVersion, topologyVersion, topologyVersionSnapshot, 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, 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.IgniteInternalTx

`addInvalidPartition, addMeta, close, colocated, commitVersion, commitVersion, completedVersions, concurrency, currentPrepareFuture, dht, done, endVersion, endVersion, enforceSerializable, finishFuture, hasTransforms, implicit, implicitSingle, internal, invalidPartitions, ioPolicy, isInvalidate, isolation, isRollbackOnly, isSystemInvalidate, local, localResult, markFinalizing, markPreparing, meta, near, nearXidVersion, needsCompletedVersions, nodeId, onePhaseCommit, onRemap, optimistic, optimisticLockEntries, otherNodeId, 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, topologyVersionSnapshot, transactionNodes, user, writeVersion, writeVersion, xid, xidVersion`

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

`endTime, onTimeout, timeoutId`

### Field Detail

#### readMap

    @GridToStringInclude
    protected Map<IgniteTxKey,IgniteTxEntry> readMap

Read set.

#### writeMap

    @GridToStringInclude
    protected Map<IgniteTxKey,IgniteTxEntry> writeMap

Write map.

### Constructor Detail

#### GridDistributedTxRemoteAdapter

    public GridDistributedTxRemoteAdapter()

Empty constructor required for `Externalizable`.

#### GridDistributedTxRemoteAdapter

    public GridDistributedTxRemoteAdapter(GridCacheSharedContext<?,?> ctx,
                                  UUID nodeId,
                                  long rmtThreadId,
                                  GridCacheVersion xidVer,
                                  GridCacheVersion commitVer,
                                  boolean sys,
                                  byte plc,
                                  TransactionConcurrency concurrency,
                                  TransactionIsolation isolation,
                                  boolean invalidate,
                                  long timeout,
                                  int txSize,
                                  @Nullable
                                  UUID subjId,
                                  int taskNameHash)

Parameters:
  `ctx` - Cache registry.
  `nodeId` - Node ID.
  `rmtThreadId` - Remote thread ID.
  `xidVer` - XID version.
  `commitVer` - Commit version.
  `sys` - System flag.
  `plc` - IO policy.
  `concurrency` - Concurrency level (should be pessimistic).
  `isolation` - Transaction isolation.
  `invalidate` - Invalidate flag.
  `timeout` - Timeout.
  `txSize` - Expected transaction size.
  `subjId` - Subject ID.
  `taskNameHash` - Task name hash code.

### Method Detail

#### eventNodeId

    public UUID eventNodeId()

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

#### masterNodeIds

    public Collection<UUID> masterNodeIds()

Specified by:
  `masterNodeIds` in interface `IgniteInternalTx`
Returns:
  Master 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.

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

#### activeCacheIds

    public Collection<Integer> activeCacheIds()

Specified by:
  `activeCacheIds` in interface `IgniteInternalTx`
Returns:
  Collection of cache IDs involved in this transaction.

#### empty

    public boolean empty()

Specified by:
  `empty` in interface `IgniteInternalTx`
Returns:
  Checks if transaction has no entries.

#### removed

    public boolean removed(IgniteTxKey key)

Checks whether given key has been removed within transaction.

Specified by:
  `removed` in interface `IgniteInternalTx`
Parameters:
  `key` - Key to check.
Returns:
  `True` if key has been removed.

#### invalidate

    public void invalidate(boolean invalidate)

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

#### writeMap

    public Map<IgniteTxKey,IgniteTxEntry> writeMap()

Specified by:
  `writeMap` in interface `IgniteInternalTx`
Returns:
  Transaction write map.

#### readMap

    public Map<IgniteTxKey,IgniteTxEntry> readMap()

Specified by:
  `readMap` in interface `IgniteInternalTx`
Returns:
  Transaction read map.

#### seal

    public void seal()

Seals transaction for updates.

Specified by:
  `seal` in interface `IgniteInternalTx`

#### peek

    public GridTuple<CacheObject> peek(GridCacheContext cacheCtx,
                              boolean failFast,
                              KeyCacheObject key,
                              CacheEntryPredicate[] filter)
                                throws GridCacheFilterFailedException

Specified by:
  `peek` in interface `IgniteInternalTx`
Parameters:
  `cacheCtx` - Cache context.
  `failFast` - Fail-fast flag.
  `key` - Key to look up.
  `filter` - Filter to check.
Returns:
  Current value for the key within transaction.
Throws:
  `GridCacheFilterFailedException` - If filter failed and failFast is `true`.

#### entry

    public IgniteTxEntry entry(IgniteTxKey key)

Specified by:
  `entry` in interface `IgniteInternalTx`
Parameters:
  `key` - Key for the entry.
Returns:
  Entry for the key (either from write set or read set).

#### clearEntry

    public void clearEntry(IgniteTxKey key)

Clears entry from transaction as it never happened.

Parameters:
  `key` - key to be removed.

#### doneRemote

    public void doneRemote(GridCacheVersion baseVer,
                  Collection<GridCacheVersion> committedVers,
                  Collection<GridCacheVersion> rolledbackVers,
                  Collection<GridCacheVersion> pendingVers)

Specified by:
  `doneRemote` in interface `IgniteTxRemoteEx`
Parameters:
  `baseVer` - Base version.
  `committedVers` - Committed versions.
  `rolledbackVers` - Rolled back versions.
  `pendingVers` - Pending versions.

#### onOwnerChanged

    public boolean onOwnerChanged(GridCacheEntryEx entry,
                         GridCacheMvccCandidate owner)

Callback invoked whenever there is a lock that has been acquired by this transaction for any of the participating entries.

Specified by:
  `onOwnerChanged` in interface `IgniteInternalTx`
Parameters:
  `entry` - Cache entry.
  `owner` - Lock candidate that won ownership of the lock.
Returns:
  `True` if transaction cared about notification.

#### isStarted

    public boolean isStarted()

Specified by:
  `isStarted` in class `IgniteTxAdapter`
Returns:
  `True` if transaction has at least one key enlisted.

#### remoteThreadId

    public long remoteThreadId()

Specified by:
  `remoteThreadId` in interface `IgniteTxRemoteEx`
Returns:
  Remote node thread ID.

#### setWriteValue

    public boolean setWriteValue(IgniteTxEntry e)

Specified by:
  `setWriteValue` in interface `IgniteTxRemoteEx`
Parameters:
  `e` - Transaction entry to set.
Returns:
  `True` if value was set.

#### hasWriteKey

    public boolean hasWriteKey(IgniteTxKey key)

Specified by:
  `hasWriteKey` in interface `IgniteInternalTx`
Parameters:
  `key` - Key to check.
Returns:
  `True` if key is present.

#### prepareAsync

    public IgniteInternalFuture<IgniteInternalTx> prepareAsync()

Prepare stage.

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

#### readSet

    public Set<IgniteTxKey> readSet()

Specified by:
  `readSet` in interface `IgniteInternalTx`
Returns:
  Read set.

#### writeSet

    public Set<IgniteTxKey> writeSet()

Specified by:
  `writeSet` in interface `IgniteInternalTx`
Returns:
  Write set.

#### allEntries

    public Collection<IgniteTxEntry> allEntries()

Specified by:
  `allEntries` in interface `IgniteInternalTx`
Returns:
  All transaction entries.

#### writeEntries

    public Collection<IgniteTxEntry> writeEntries()

Specified by:
  `writeEntries` in interface `IgniteInternalTx`
Returns:
  Write entries.

#### readEntries

    public Collection<IgniteTxEntry> readEntries()

Specified by:
  `readEntries` in interface `IgniteInternalTx`
Returns:
  Read entries.

#### prepare

    public void prepare()
                 throws IgniteCheckedException

Prepare phase.

Specified by:
  `prepare` in interface `IgniteInternalTx`
Throws:
  `IgniteCheckedException` - If prepare failed.

#### commit

    public void commit()
                throws IgniteCheckedException

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

Specified by:
  `commit` in interface `IgniteInternalTx`
Throws:
  `IgniteCheckedException` - If commit failed.

#### forceCommit

    public void forceCommit()
                     throws IgniteCheckedException

Forces commit for this tx.

Throws:
  `IgniteCheckedException` - If commit failed.

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

#### rollback

    public void rollback()

Rolls back this transaction.

Specified by:
  `rollback` in interface `IgniteInternalTx`

#### rollbackAsync

    public IgniteInternalFuture<IgniteInternalTx> rollbackAsync()

Asynchronously rollback this transaction.

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

#### alternateVersions

    public Collection<GridCacheVersion> alternateVersions()

Specified by:
  `alternateVersions` in interface `IgniteInternalTx`
Returns:
  Alternate transaction versions.

#### addExplicit

    protected void addExplicit(IgniteTxEntry e)

Adds explicit version if there is one.

Parameters:
  `e` - Transaction entry.

#### toString

    public String toString()

Overrides:
  `toString` in class `IgniteTxAdapter`

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.3.0-incubating
Release Date | : July 10 2015