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

## Interface IgniteInternalTx

All Known Subinterfaces:
  IgniteTxLocalEx, IgniteTxRemoteEx

All Known Implementing Classes:
  GridDhtTxLocal, GridDhtTxLocalAdapter, GridDhtTxRemote, GridDistributedTxRemoteAdapter, GridNearTxLocal, GridNearTxRemote, IgniteTxAdapter, IgniteTxLocalAdapter

    public interface IgniteInternalTx

Transaction managed by cache (`'Ex'` stands for external).

### Nested Class Summary

Nested Classes
`static class` `IgniteInternalTx.FinalizationStatus`

### Method Summary

All Methods Instance Methods Abstract Methods
`boolean` `activeCachesDeploymentEnabled()`
`void` `addInvalidPartition(GridCacheContext<?,?> cacheCtx, int part)`
`<T> T` `addMeta(int key, T val)` Adds a new metadata.
`Collection<IgniteTxEntry>` `allEntries()`
`Collection<GridCacheVersion>` `alternateVersions()`
`boolean` `colocated()`
`IgniteInternalFuture<IgniteInternalTx>` `commitAsync()` Asynchronously commits this transaction by initiating `two-phase-commit` process.
`void` `commitError(Throwable e)`
`GridCacheVersion` `commitVersion()`
`void` `commitVersion(GridCacheVersion commitVer)`
`void` `completedVersions(GridCacheVersion base, Collection<GridCacheVersion> committed, Collection<GridCacheVersion> rolledback)`
`TransactionConcurrency` `concurrency()` Cache transaction concurrency mode.
`IgniteInternalFuture<?>` `currentPrepareFuture()`
`boolean` `dht()`
`boolean` `done()`
`boolean` `empty()`
`void` `endVersion(GridCacheVersion endVer)`
`IgniteTxEntry` `entry(IgniteTxKey key)`
`void` `errorWhenCommitting()` Changes transaction state from COMMITTING to MARKED_ROLLBACK.
`UUID` `eventNodeId()`
`IgniteInternalFuture<IgniteInternalTx>` `finishFuture()`
`boolean` `hasWriteKey(IgniteTxKey key)`
`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.
`TransactionIsolation` `isolation()` Cache transaction isolation level.
`boolean` `isRollbackOnly()` If transaction was marked as rollback-only.
`boolean` `isSystemInvalidate()`
`boolean` `local()`
`boolean` `localResult()`
`boolean` `markFinalizing(IgniteInternalTx.FinalizationStatus status)`
`Collection<UUID>` `masterNodeIds()`
`<T> T` `meta(int key)` Gets metadata by key.
`boolean` `near()`
`GridCacheVersion` `nearXidVersion()`
`boolean` `needsCompletedVersions()`
`UUID` `nodeId()` ID of the node on which this transaction started.
`boolean` `onePhaseCommit()`
`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.
`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` `originatingNodeId()` Gets node ID which directly started this 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)`
`GridTuple<CacheObject>` `peek(GridCacheContext ctx, boolean failFast, KeyCacheObject key)`
`boolean` `pessimistic()`
`boolean` `readCommitted()`
`Collection<IgniteTxEntry>` `readEntries()`
`Map<IgniteTxKey,IgniteTxEntry>` `readMap()`
`Set<IgniteTxKey>` `readSet()`
`long` `remainingTime()` Gets allowed remaining time for this transaction.
`<T> T` `removeMeta(int key)` Removes metadata by key.
`boolean` `repeatableRead()`
`IgniteInternalFuture<IgniteInternalTx>` `rollbackAsync()` Asynchronously rollback this transaction.
`IgniteInternalFuture<?>` `salvageTx()`
`void` `seal()` Seals transaction for updates.
`boolean` `serializable()`
`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)`
`boolean` `storeEnabled()`
`boolean` `storeWriteThrough()`
`UUID` `subjectId()`
`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.
`AffinityTopologyVersion` `topologyVersion()`
`AffinityTopologyVersion` `topologyVersion(AffinityTopologyVersion topVer)` Attempts to set topology version and returns the current value.
`AffinityTopologyVersion` `topologyVersionSnapshot()`
`Map<UUID,Collection<UUID>>` `transactionNodes()`
`IgniteTxState` `txState()`
`boolean` `user()`
`Collection<IgniteTxEntry>` `writeEntries()`
`Map<IgniteTxKey,IgniteTxEntry>` `writeMap()`
`Set<IgniteTxKey>` `writeSet()`
`GridCacheVersion` `writeVersion()`
`void` `writeVersion(GridCacheVersion ver)` Sets write version.
`IgniteUuid` `xid()` Gets unique identifier for this transaction.
`GridCacheVersion` `xidVersion()`

### Method Detail

#### localResult

    boolean localResult()

Returns:
  `True` if transaction started on the node initiated cache operation.

#### xid

    IgniteUuid xid()

Gets unique identifier for this transaction.

Returns:
  Transaction UID.

#### nodeId

    UUID nodeId()

ID of the node on which this transaction started.

Returns:
  Originating node ID.

#### threadId

    long threadId()

ID of the thread in which this transaction started.

Returns:
  Thread ID.

#### startTime

    long startTime()

Start time of this transaction.

Returns:
  Start time of this transaction on this node.

#### isolation

    TransactionIsolation isolation()

Cache transaction isolation level.

Returns:
  Isolation level.

#### concurrency

    TransactionConcurrency concurrency()

Cache transaction concurrency mode.

Returns:
  Concurrency mode.

#### implicit

    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.

Returns:
  `True` if transaction was started implicitly.

#### isInvalidate

    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.

Returns:
  Invalidation flag.

#### state

    TransactionState state()

Gets current transaction state value.

Returns:
  Current transaction state.

#### timeout

    long timeout()

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

Returns:
  Transaction timeout value.

#### timeout

    long timeout(long timeout)

Sets transaction timeout value. This value can be set only before a first operation on transaction has been performed.

Parameters:
  `timeout` - Transaction timeout value.
Returns:
  Previous timeout.

#### errorWhenCommitting

    void errorWhenCommitting()

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

#### setRollbackOnly

    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.

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

    boolean isRollbackOnly()

If transaction was marked as rollback-only.

Returns:
  `True` if transaction can only be rolled back.

#### removeMeta

    @Nullable
    <T> T removeMeta(int key)

Removes metadata by key.

Type Parameters:
  `T` - Type of the value.
Parameters:
  `key` - Key of the metadata to remove.
Returns:
  Value of removed metadata or `null`.

#### meta

    @Nullable
    <T> T meta(int key)

Gets metadata by key.

Type Parameters:
  `T` - Type of the value.
Parameters:
  `key` - Metadata key.
Returns:
  Metadata value or `null`.

#### addMeta

    @Nullable
    <T> T addMeta(int key,
                            T val)

Adds a new metadata.

Type Parameters:
  `T` - Type of the value.
Parameters:
  `key` - Metadata key.
  `val` - Metadata value.
Returns:
  Metadata previously associated with given name, or `null` if there was none.

#### size

    int size()

Returns:
  Size of the transaction.

#### storeEnabled

    boolean storeEnabled()

Returns:
  `True` if transaction is allowed to use store.

#### storeWriteThrough

    boolean storeWriteThrough()

Returns:
  `True` if transaction is allowed to use store and transactions spans one or more caches with store enabled.

#### system

    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.

Returns:
  `True` if transaction is started for system cache.

#### ioPolicy

    byte ioPolicy()

Returns:
  Pool where message for the given transaction must be processed.

#### topologyVersion

    AffinityTopologyVersion topologyVersion()

Returns:
  Last recorded topology version.

#### topologyVersionSnapshot

    AffinityTopologyVersion topologyVersionSnapshot()

Returns:
  Topology version snapshot.

#### implicitSingle

    boolean implicitSingle()

Returns:
  Flag indicating whether transaction is implicit with only one key.

#### txState

    IgniteTxState txState()

Returns:
  Transaction state.

#### activeCachesDeploymentEnabled

    boolean activeCachesDeploymentEnabled()

Returns:
  `true` or `false` if the deployment is enabled or disabled for all active caches involved in this transaction.

#### topologyVersion

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

Parameters:
  `topVer` - Topology version.
Returns:
  Recorded topology version.

#### empty

    boolean empty()

Returns:
  `True` if transaction is empty.

#### markFinalizing

    boolean markFinalizing(IgniteInternalTx.FinalizationStatus status)

Parameters:
  `status` - Finalization status to set.
Returns:
  `True` if could mark was set.

#### addInvalidPartition

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

Parameters:
  `cacheCtx` - Cache context.
  `part` - Invalid partition.

#### invalidPartitions

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

Returns:
  Invalid partitions.

#### ownedVersion

    @Nullable
    GridCacheVersion ownedVersion(IgniteTxKey key)

Gets owned version for near remote transaction.

Parameters:
  `key` - Key to get version for.
Returns:
  Owned version, if any.

#### otherNodeId

    @Nullable
    UUID otherNodeId()

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

Returns:
  Parent node IDs.

#### eventNodeId

    UUID eventNodeId()

Returns:
  Event node ID.

#### originatingNodeId

    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.

Returns:
  Originating node ID.

#### masterNodeIds

    Collection<UUID> masterNodeIds()

Returns:
  Master node IDs.

#### nearXidVersion

    @Nullable
    GridCacheVersion nearXidVersion()

Returns:
  Near transaction ID.

#### transactionNodes

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

Returns:
  Transaction nodes mapping (primary node -> related backup nodes).

#### ownsLock

    boolean ownsLock(GridCacheEntryEx entry)
              throws GridCacheEntryRemovedException

Parameters:
  `entry` - Entry to check.
Returns:
  `True` if lock is owned.
Throws:
  `GridCacheEntryRemovedException` - If entry has been removed.

#### ownsLockUnsafe

    boolean ownsLockUnsafe(GridCacheEntryEx entry)

Parameters:
  `entry` - Entry to check.
Returns:
  `True` if lock is owned.

#### near

    boolean near()

Returns:
  `True` if near transaction.

#### dht

    boolean dht()

Returns:
  `True` if DHT transaction.

#### colocated

    boolean colocated()

Returns:
  `True` if dht colocated transaction.

#### local

    boolean local()

Returns:
  `True` if transaction is local, `false` if it's remote.

#### subjectId

    UUID subjectId()

Returns:
  Subject ID initiated this transaction.

#### taskNameHash

    int taskNameHash()

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

Returns:
  Task name hash.

#### user

    boolean user()

Returns:
  `True` if transaction is user transaction, which means:
  - Explicit
  - Local
  - Not DHT

#### hasWriteKey

    boolean hasWriteKey(IgniteTxKey key)

Parameters:
  `key` - Key to check.
Returns:
  `True` if key is present.

#### readSet

    Set<IgniteTxKey> readSet()

Returns:
  Read set.

#### writeSet

    Set<IgniteTxKey> writeSet()

Returns:
  Write set.

#### allEntries

    Collection<IgniteTxEntry> allEntries()

Returns:
  All transaction entries.

#### writeEntries

    Collection<IgniteTxEntry> writeEntries()

Returns:
  Write entries.

#### readEntries

    Collection<IgniteTxEntry> readEntries()

Returns:
  Read entries.

#### writeMap

    Map<IgniteTxKey,IgniteTxEntry> writeMap()

Returns:
  Transaction write map.

#### readMap

    Map<IgniteTxKey,IgniteTxEntry> readMap()

Returns:
  Transaction read map.

#### optimisticLockEntries

    Collection<IgniteTxEntry> optimisticLockEntries()

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

Returns:
  List of tx entries for optimistic locking.

#### seal

    void seal()

Seals transaction for updates.

#### entry

    @Nullable
    IgniteTxEntry entry(IgniteTxKey key)

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

#### peek

    @Nullable
    GridTuple<CacheObject> peek(GridCacheContext ctx,
                                          boolean failFast,
                                          KeyCacheObject key)
                                   throws GridCacheFilterFailedException

Parameters:
  `ctx` - Cache context.
  `failFast` - Fail-fast flag.
  `key` - Key to look up.
Returns:
  Current value for the key within transaction.
Throws:
  `GridCacheFilterFailedException` - If filter failed and failFast is `true`.

#### xidVersion

    GridCacheVersion xidVersion()

Returns:
  Transaction version.

#### commitVersion

    GridCacheVersion commitVersion()

Returns:
  Version created at commit time.

#### commitVersion

    void commitVersion(GridCacheVersion commitVer)

Parameters:
  `commitVer` - Commit version.

#### salvageTx

    @Nullable
    IgniteInternalFuture<?> salvageTx()

Returns:
  Future.

#### endVersion

    void endVersion(GridCacheVersion endVer)

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

#### writeVersion

    GridCacheVersion writeVersion()

Returns:
  Transaction write version. For all transactions except DHT transactions, will be equal to `xidVersion()`.

#### writeVersion

    void writeVersion(GridCacheVersion ver)

Sets write version.

Parameters:
  `ver` - Write version.

#### finishFuture

    IgniteInternalFuture<IgniteInternalTx> finishFuture()

Returns:
  Future for transaction completion.

#### currentPrepareFuture

    @Nullable
    IgniteInternalFuture<?> currentPrepareFuture()

Returns:
  Future for transaction prepare if prepare is in progress.

#### state

    boolean state(TransactionState state)

Parameters:
  `state` - Transaction state.
Returns:
  `True` if transition was valid, `false` otherwise.

#### invalidate

    void invalidate(boolean invalidate)

Parameters:
  `invalidate` - Invalidate flag.

#### systemInvalidate

    void systemInvalidate(boolean sysInvalidate)

Parameters:
  `sysInvalidate` - System invalidate flag.

#### isSystemInvalidate

    boolean isSystemInvalidate()

Returns:
  System invalidate flag.

#### rollbackAsync

    IgniteInternalFuture<IgniteInternalTx> rollbackAsync()

Asynchronously rollback this transaction.

Returns:
  Rollback future.

#### commitAsync

    IgniteInternalFuture<IgniteInternalTx> commitAsync()

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

Returns:
  Future for commit operation.

#### onOwnerChanged

    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.

Parameters:
  `entry` - Cache entry.
  `owner` - Lock candidate that won ownership of the lock.
Returns:
  `True` if transaction cared about notification.

#### timedOut

    boolean timedOut()

Returns:
  `True` if transaction timed out.

#### done

    boolean done()

Returns:
  `True` if transaction had completed successfully or unsuccessfully.

#### optimistic

    boolean optimistic()

Returns:
  `True` for OPTIMISTIC transactions.

#### pessimistic

    boolean pessimistic()

Returns:
  `True` for PESSIMISTIC transactions.

#### readCommitted

    boolean readCommitted()

Returns:
  `True` if read-committed.

#### repeatableRead

    boolean repeatableRead()

Returns:
  `True` if repeatable-read.

#### serializable

    boolean serializable()

Returns:
  `True` if serializable.

#### remainingTime

    long remainingTime()
                throws IgniteTxTimeoutCheckedException

Gets allowed remaining time for this transaction.

Returns:
  Remaining time.
Throws:
  `IgniteTxTimeoutCheckedException` - If transaction timed out.

#### alternateVersions

    Collection<GridCacheVersion> alternateVersions()

Returns:
  Alternate transaction versions.

#### needsCompletedVersions

    boolean needsCompletedVersions()

Returns:
  `True` if transaction needs completed versions for processing.

#### completedVersions

    void completedVersions(GridCacheVersion base,
                           Collection<GridCacheVersion> committed,
                           Collection<GridCacheVersion> rolledback)

Parameters:
  `base` - Base for committed versions.
  `committed` - Committed transactions relative to base.
  `rolledback` - Rolled back transactions relative to base.

#### internal

    boolean internal()

Returns:
  `True` if transaction has at least one internal entry.

#### onePhaseCommit

    boolean onePhaseCommit()

Returns:
  `True` if transaction is a one-phase-commit transaction.

#### commitError

    void commitError(Throwable e)

Parameters:
  `e` - Commit error.

2018 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.5.0
Release Date | : May 23 2018