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

## Class GridNearTransactionalCache<K,V>

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.GridCacheAdapter<K,V>
  - - org.apache.ignite.internal.processors.cache.distributed.GridDistributedCacheAdapter<K,V>
    - - org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter<K,V>
      - - org.apache.ignite.internal.processors.cache.distributed.near.GridNearTransactionalCache<K,V>

All Implemented Interfaces:
  Externalizable, Serializable, Iterable<javax.cache.Cache.Entry<K,V>>, IgniteInternalCache<K,V>

    public class GridNearTransactionalCache<K,V>
    extends GridNearCacheAdapter<K,V>

Near cache for transactional cache.

See Also:
  Serialized Form

### Nested Class Summary

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

`GridCacheAdapter.AsyncOp<T>, GridCacheAdapter.CacheExpiryPolicy, GridCacheAdapter.FutureHolder, GridCacheAdapter.InvokeAllTimeStatClosure<T>, GridCacheAdapter.PeekModes, GridCacheAdapter.TopologyVersionAwareJob, GridCacheAdapter.UpdateGetTimeStatClosure<T>, GridCacheAdapter.UpdatePutAndGetTimeStatClosure<T>, GridCacheAdapter.UpdatePutTimeStatClosure<T>, GridCacheAdapter.UpdateRemoveTimeStatClosure<T>, GridCacheAdapter.UpdateTimeStatClosure<T>`

### Field Summary

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

`cacheCfg, CLEAR_ALL_SPLIT_THRESHOLD, ctx, DFLT_START_CACHE_SIZE, keyCheck, lastFut, locNodeId, log, map, MAX_RETRIES, metrics, RET2NULL, txLockMsgLog`

### Constructor Summary

Constructors
Constructor and Description
`GridNearTransactionalCache()` Empty constructor required for `Externalizable`.
`GridNearTransactionalCache(GridCacheContext<K,V> ctx)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `clearLocks(UUID nodeId, GridDhtUnlockRequest req)`
`GridDhtCache<K,V>` `dht()`
`void` `dht(GridDhtCache<K,V> dht)`
`protected boolean` `evictNearEntry(GridCacheEntryEx e, GridCacheVersion obsoleteVer, AffinityTopologyVersion topVer)`
`IgniteInternalFuture<Map<K,V>>` `getAllAsync(@Nullable Collection<? extends K> keys, boolean forcePrimary, boolean skipTx, @Nullable UUID subjId, String taskName, boolean deserializeBinary, boolean recovery, boolean readRepair, boolean skipVals, boolean needVer)`
`protected boolean` `isNearLocallyMapped(GridCacheEntryEx e, AffinityTopologyVersion topVer)`
`protected IgniteInternalFuture<Boolean>` `lockAllAsync(Collection<KeyCacheObject> keys, long timeout, IgniteTxLocalEx tx, boolean isInvalidate, boolean isRead, boolean retval, TransactionIsolation isolation, long createTtl, long accessTtl)`
`void` `onDeferredDelete(GridCacheEntryEx entry, GridCacheVersion ver)`
`void` `removeLocks(GridCacheVersion ver, Collection<KeyCacheObject> keys)` Removes locks regardless of whether they are owned or not for given version and keys.
`void` `start()` Starts this cache.
`@Nullable GridNearTxRemote` `startRemoteTx(UUID nodeId, GridDhtLockRequest req)`
`String` `toString()`
`void` `unlockAll(Collection<? extends K> keys)` Unlocks given keys only if current thread owns the locks.

### Methods inherited from class org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter

`clearLocally, clearLocallyAll, entryEx, entryExx, entrySet, evict, evictAll, forceKeyCheck, igfsDataSpaceUsed, isAllLockedNearOnly, isIgfsDataCache, isLocked, isLockedNearOnly, isNear, loadAsync, localLoad, localLoadCache, localLoadCacheAsync, nearEntries, nearSize, offHeapAllocatedSize, offHeapEntriesCount, onIgfsDataSizeChanged, onReconnected, peekExx, preloader, primarySize, primarySizeLong, processGetResponse, size, sizeLong, splitClearLocally`

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

`localSizeLong, localSizeLong, lockAllAsync, removeAll, removeAllAsync, removeVersionedEntry, txLockAsync`

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

`active, active, affinity, allEntries, asyncOp, asyncOpAcquire, asyncOpRelease, awaitLastFut, cache, checkCurrentTx, checkJta, clear, clear, clearAll, clearAllAsync, clearAsync, clearAsync, clearLocally, clearLocally, clusterMetrics, clusterMetrics, clusterMxBean, configuration, containsKey, containsKeyAsync, containsKeys, containsKeysAsync, context, decrementSize, entries, entryEx, entryEx, entrySet, expiry, expiryPolicy, forSubjectId, get, get, getAll, getAll, getAllAsync, getAllAsync, getAllAsync0, getAllOutTx, getAllOutTxAsync, getAndPut, getAndPut, getAndPut0, getAndPutAsync, getAndPutAsync, getAndPutAsync0, getAndPutIfAbsent, getAndPutIfAbsentAsync, getAndRemove, getAndRemove0, getAndRemoveAsync, getAndRemoveAsync0, getAndReplace, getAndReplaceAsync, getAsync, getAsync, getEntries, getEntriesAsync, getEntry, getEntryAsync, getForcePrimary, getForcePrimaryAsync, igniteIterator, igniteIterator, incrementSize, init, invoke, invoke, invokeAll, invokeAll, invokeAllAsync, invokeAllAsync, invokeAsync, isColocated, isDht, isDhtAtomic, isEmpty, isLocal, isLockedByThread, iterator, iterator, keepBinary, keySet, loadAll, localEntries, localMetrics, localMxBean, localPeek, localPreloadPartition, localSize, lock, lockAll, lockAsync, log, lostPartitions, map, metrics0, name, onKernalStart, onKernalStop, onUndeploy, parsePeekModes, peekEx, peekEx, preloadPartition, preloadPartitionAsync, printMemoryStats, put, put, put0, putAll, putAll0, putAllAsync, putAllAsync0, putAllConflict, putAllConflictAsync, putAsync, putAsync, putAsync0, putIfAbsent, putIfAbsentAsync, readExternal, readResolve, rebalance, remove, remove, remove, remove0, removeAll, removeAll0, removeAllAsync, removeAllAsync0, removeAllConflict, removeAllConflictAsync, removeAsync, removeAsync, removeAsync, removeAsync0, removeEntry, removeIfObsolete, removeMetrics, repairableGet, repairableGetAll, repairableGetAllAsync, repairableGetAsync, repairAsync, repairAsync, replace, replace, replaceAsync, replaceAsync, saveFuture, scanIterator, setSkipStore, size, sizeAsync, sizeLong, sizeLong, sizeLongAsync, sizeLongAsync, skipStore, startInfo, stop, stopInfo, tx, txStart, txStart, txStartEx, unlock, validateCacheKey, validateCacheKeys, withAllowAtomicOpsInTx, withExpiryPolicy, withNoRetries, writeExternal`

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

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

### Methods inherited from interface java.lang.Iterable

`forEach, spliterator`

### Constructor Detail

#### GridNearTransactionalCache

    public GridNearTransactionalCache()

Empty constructor required for `Externalizable`.

#### GridNearTransactionalCache

    public GridNearTransactionalCache(GridCacheContext<K,V> ctx)

Parameters:
  `ctx` - Context.

### Method Detail

#### start

    public void start()
               throws IgniteCheckedException

Starts this cache. Child classes should override this method to provide custom start-up behavior.

Overrides:
  `start` in class `GridNearCacheAdapter<K,V>`
Throws:
  `IgniteCheckedException` - If start failed.

#### dht

    public void dht(GridDhtCache<K,V> dht)

Parameters:
  `dht` - DHT cache.

#### dht

    public GridDhtCache<K,V> dht()

Specified by:
  `dht` in class `GridNearCacheAdapter<K,V>`
Returns:
  DHT cache.

#### getAllAsync

    public IgniteInternalFuture<Map<K,V>> getAllAsync(@Nullable
                                                      @Nullable Collection<? extends K> keys,
                                                      boolean forcePrimary,
                                                      boolean skipTx,
                                                      @Nullable
                                                      @Nullable UUID subjId,
                                                      String taskName,
                                                      boolean deserializeBinary,
                                                      boolean recovery,
                                                      boolean readRepair,
                                                      boolean skipVals,
                                                      boolean needVer)

Overrides:
  `getAllAsync` in class `GridCacheAdapter<K,V>`
Parameters:
  `keys` - Keys.
  `forcePrimary` - Force primary.
  `skipTx` - Skip tx.
  `subjId` - Subj Id.
  `taskName` - Task name.
  `deserializeBinary` - Deserialize binary.
  `recovery` - Recovery mode flag.
  `skipVals` - Skip values.
  `needVer` - Need version.
Returns:
  Future for the get operation.
See Also:
  `GridCacheAdapter.getAllAsync(Collection)`

#### clearLocks

    public void clearLocks(UUID nodeId,
                           GridDhtUnlockRequest req)

Parameters:
  `nodeId` - Node ID.
  `req` - Request.

#### startRemoteTx

    @Nullable
    public @Nullable GridNearTxRemote startRemoteTx(UUID nodeId,
                                                              GridDhtLockRequest req)
                                                       throws IgniteCheckedException,
                                                              GridDistributedLockCancelledException

Parameters:
  `nodeId` - Primary node ID.
  `req` - Request.
Returns:
  Remote transaction.
Throws:
  `IgniteCheckedException` - If failed.
  `GridDistributedLockCancelledException` - If lock has been cancelled.

#### lockAllAsync

    protected IgniteInternalFuture<Boolean> lockAllAsync(Collection<KeyCacheObject> keys,
                                                         long timeout,
                                                         IgniteTxLocalEx tx,
                                                         boolean isInvalidate,
                                                         boolean isRead,
                                                         boolean retval,
                                                         TransactionIsolation isolation,
                                                         long createTtl,
                                                         long accessTtl)

Specified by:
  `lockAllAsync` in class `GridDistributedCacheAdapter<K,V>`
Parameters:
  `keys` - Keys to lock.
  `timeout` - Timeout.
  `tx` - Transaction
  `isInvalidate` - Invalidation flag.
  `isRead` - Indicates whether value is read or written.
  `retval` - Flag to return value.
  `isolation` - Transaction isolation.
  `createTtl` - TTL for create operation.
  `accessTtl` - TTL for read operation.
Returns:
  Future for locks.

#### isNearLocallyMapped

    protected boolean isNearLocallyMapped(GridCacheEntryEx e,
                                          AffinityTopologyVersion topVer)

Parameters:
  `e` - Transaction entry.
  `topVer` - Topology version.
Returns:
  `True` if entry is locally mapped as a primary or back up node.

#### evictNearEntry

    protected boolean evictNearEntry(GridCacheEntryEx e,
                                     GridCacheVersion obsoleteVer,
                                     AffinityTopologyVersion topVer)

Parameters:
  `e` - Entry to evict if it qualifies for eviction.
  `obsoleteVer` - Obsolete version.
  `topVer` - Topology version.
Returns:
  `True` if attempt was made to evict the entry.

#### unlockAll

    public void unlockAll(Collection<? extends K> keys)

Unlocks given keys only if current thread owns the locks. Only the keys that have been locked by calling thread and pass through the filter (if any) will be unlocked. If none of the key locks is owned by current thread, then this method will do nothing.

## Transactions

Locks are not transactional and should not be used from within transactions. If you do need explicit locking within transaction, then you should use `TransactionConcurrency.PESSIMISTIC` concurrency control for transaction which will acquire explicit locks for relevant cache operations.

Parameters:
  `keys` - Keys to unlock.

#### removeLocks

    public void removeLocks(GridCacheVersion ver,
                            Collection<KeyCacheObject> keys)

Removes locks regardless of whether they are owned or not for given version and keys.

Parameters:
  `ver` - Lock version.
  `keys` - Keys.

#### onDeferredDelete

    public void onDeferredDelete(GridCacheEntryEx entry,
                                 GridCacheVersion ver)

Specified by:
  `onDeferredDelete` in class `GridCacheAdapter<K,V>`
Parameters:
  `entry` - Entry.
  `ver` - Version.

#### toString

    public String toString()

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

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.8.0
Release Date | : February 27 2020