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

## Class IgniteTxStateImpl

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalStateAdapter
  - - org.apache.ignite.internal.processors.cache.transactions.IgniteTxStateImpl

All Implemented Interfaces:
  IgniteTxLocalState, IgniteTxState

    public class IgniteTxStateImpl
    extends IgniteTxLocalStateAdapter

### Field Summary

Fields
`protected Boolean` `mvccEnabled`
`protected IgniteTxMap` `readView` Read view on transaction map.
`protected Boolean` `recovery`
`protected Map<IgniteTxKey,IgniteTxEntry>` `txMap` Per-transaction read map.
`protected IgniteTxMap` `writeView` Write view on transaction map.

### Constructor Summary

Constructors
Constructor and Description
`IgniteTxStateImpl()`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addActiveCache(GridCacheContext cacheCtx, boolean recovery, IgniteTxAdapter tx)`
`void` `addEntry(IgniteTxEntry entry)`
`Collection<IgniteTxEntry>` `allEntries()`
`Collection<IgniteTxEntry>` `allEntriesCopy()`
`void` `awaitLastFuture(GridCacheSharedContext cctx)`
`@Nullable GridIntList` `cacheIds()` Gets caches ids affected with current tx.
`boolean` `empty()`
`IgniteTxEntry` `entry(IgniteTxKey key)`
`@Nullable Integer` `firstCacheId()`
`boolean` `hasInterceptor(GridCacheSharedContext cctx)`
`boolean` `hasWriteKey(IgniteTxKey key)`
`boolean` `implicitSingle()`
`boolean` `init(int txSize)`
`boolean` `initialized()`
`boolean` `mvccEnabled()`
`void` `onTxEnd(GridCacheSharedContext cctx, IgniteInternalTx tx, boolean commit)`
`Collection<IgniteTxEntry>` `readEntries()`
`Map<IgniteTxKey,IgniteTxEntry>` `readMap()`
`Set<IgniteTxKey>` `readSet()`
`boolean` `recovery()`
`void` `removeEntry(IgniteTxKey key)`
`void` `seal()`
`@Nullable GridCacheContext` `singleCacheContext(GridCacheSharedContext cctx)`
`IgniteTxEntry` `singleWrite()`
`Collection<CacheStoreManager>` `stores(GridCacheSharedContext cctx)`
`boolean` `storeWriteThrough(GridCacheSharedContext cctx)`
`CacheWriteSynchronizationMode` `syncMode(GridCacheSharedContext cctx)`
`GridDhtTopologyFuture` `topologyReadLock(GridCacheSharedContext cctx, GridFutureAdapter<?> fut)`
`void` `topologyReadUnlock(GridCacheSharedContext cctx)`
`String` `toString()`
`void` `unwindEvicts(GridCacheSharedContext cctx)` Unwind evicts for caches involved in this transaction.
`boolean` `useMvccCaching(int cacheId)`
`IgniteCheckedException` `validateTopology(GridCacheSharedContext cctx, boolean read, GridDhtTopologyFuture topFut)`
`Collection<IgniteTxEntry>` `writeEntries()`
`Map<IgniteTxKey,IgniteTxEntry>` `writeMap()`
`Set<IgniteTxKey>` `writeSet()`

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

`onTxEnd, touchedPartitions, touchPartition`

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

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### txMap

    @GridToStringExclude
    protected Map<IgniteTxKey,IgniteTxEntry> txMap

Per-transaction read map.

#### readView

    @GridToStringExclude
    protected IgniteTxMap readView

Read view on transaction map.

#### writeView

    @GridToStringExclude
    protected IgniteTxMap writeView

Write view on transaction map.

#### recovery

    @GridToStringInclude
    protected Boolean recovery

#### mvccEnabled

    @GridToStringInclude
    protected Boolean mvccEnabled

### Constructor Detail

#### IgniteTxStateImpl

    public IgniteTxStateImpl()

### Method Detail

#### implicitSingle

    public boolean implicitSingle()

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

#### firstCacheId

    @Nullable
    public @Nullable Integer firstCacheId()

Returns:
  First tx cache id.

#### cacheIds

    @Nullable
    public @Nullable GridIntList cacheIds()

Gets caches ids affected with current tx.

Returns:
  tx cache ids.

#### unwindEvicts

    public void unwindEvicts(GridCacheSharedContext cctx)

Unwind evicts for caches involved in this transaction.

Parameters:
  `cctx` - Grid cache shared context.

#### singleCacheContext

    @Nullable
    public @Nullable GridCacheContext singleCacheContext(GridCacheSharedContext cctx)

Parameters:
  `cctx` - Context.
Returns:
  cctx Non-null cache context if tx has only one active cache.

#### awaitLastFuture

    public void awaitLastFuture(GridCacheSharedContext cctx)

Parameters:
  `cctx` - Awaits for previous async operations on active caches to be completed.

#### validateTopology

    public IgniteCheckedException validateTopology(GridCacheSharedContext cctx,
                                                   boolean read,
                                                   GridDhtTopologyFuture topFut)

Parameters:
  `cctx` - Context.
  `read` - `True` if validating for a read operation, `false` for write.
  `topFut` - Topology future.
Returns:
  Error if validation failed.

#### recovery

    public boolean recovery()

Returns:
  Recovery mode flag.

#### syncMode

    public CacheWriteSynchronizationMode syncMode(GridCacheSharedContext cctx)

Parameters:
  `cctx` - Context.
Returns:
  Write synchronization mode.

#### addActiveCache

    public void addActiveCache(GridCacheContext cacheCtx,
                               boolean recovery,
                               IgniteTxAdapter tx)
                        throws IgniteCheckedException

Parameters:
  `cacheCtx` - Context.
  `tx` - Transaction.
Throws:
  `IgniteCheckedException` - If cache check failed.

#### topologyReadLock

    public GridDhtTopologyFuture topologyReadLock(GridCacheSharedContext cctx,
                                                  GridFutureAdapter<?> fut)

Parameters:
  `cctx` - Context.
  `fut` - Future to finish with error if some cache is stopping.
Returns:
  Topology future.

#### topologyReadUnlock

    public void topologyReadUnlock(GridCacheSharedContext cctx)

Parameters:
  `cctx` - Context.

#### storeWriteThrough

    public boolean storeWriteThrough(GridCacheSharedContext cctx)

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

#### hasInterceptor

    public boolean hasInterceptor(GridCacheSharedContext cctx)

Parameters:
  `cctx` - Context.
Returns:
  `True` if transaction spans one or more caches with configured interceptor.

#### stores

    public Collection<CacheStoreManager> stores(GridCacheSharedContext cctx)

Parameters:
  `cctx` - Context.
Returns:
  Configured stores for active caches.

#### onTxEnd

    public void onTxEnd(GridCacheSharedContext cctx,
                        IgniteInternalTx tx,
                        boolean commit)

Parameters:
  `cctx` - Context.
  `tx` - Transaction.
  `commit` - Commit flag.

#### init

    public boolean init(int txSize)

Parameters:
  `txSize` - Transaction size.
Returns:
  `True` if transaction was successfully started.

#### initialized

    public boolean initialized()

Returns:
  `True` if init method was called.

#### allEntries

    public Collection<IgniteTxEntry> allEntries()

Returns:
  All entries.

#### allEntriesCopy

    public Collection<IgniteTxEntry> allEntriesCopy()

Returns:
  All entries. Returned collection is copy of internal collection.

#### entry

    public IgniteTxEntry entry(IgniteTxKey key)

Parameters:
  `key` - Key.
Returns:
  Entry.

#### hasWriteKey

    public boolean hasWriteKey(IgniteTxKey key)

Parameters:
  `key` - Key.
Returns:
  `True` if tx has write key.

#### readSet

    public Set<IgniteTxKey> readSet()

Returns:
  Read entries keys.

#### writeSet

    public Set<IgniteTxKey> writeSet()

Returns:
  Write entries keys.

#### writeEntries

    public Collection<IgniteTxEntry> writeEntries()

Returns:
  Write entries.

#### readEntries

    public Collection<IgniteTxEntry> readEntries()

Returns:
  Read entries.

#### writeMap

    public Map<IgniteTxKey,IgniteTxEntry> writeMap()

Returns:
  Write entries map.

#### readMap

    public Map<IgniteTxKey,IgniteTxEntry> readMap()

Returns:
  Read entries map.

#### empty

    public boolean empty()

Returns:
  `True` if transaction is empty.

#### addEntry

    public void addEntry(IgniteTxEntry entry)

Parameters:
  `entry` - Entry.

#### removeEntry

    public void removeEntry(IgniteTxKey key)

Parameters:
  `key` - Key.

#### seal

    public void seal()

#### singleWrite

    public IgniteTxEntry singleWrite()

Returns:
  Non-null entry if tx has only one write entry.

#### mvccEnabled

    public boolean mvccEnabled()

Returns:
  `True` if MVCC mode is enabled for transaction.

#### useMvccCaching

    public boolean useMvccCaching(int cacheId)

Parameters:
  `cacheId` - Cache id.
Returns:
  `True` if it is need to store in the heap updates made by the current TX for the given cache. These updates will be used for CQ and DR. See `MvccCachingManager`.

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.14.0
Release Date | : September 29 2022