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

## Class GridDhtCacheEntry

- java.lang.Object
- - org.apache.ignite.internal.util.lang.GridMetadataAwareAdapter
  - - org.apache.ignite.internal.processors.cache.GridCacheMapEntry
    - - org.apache.ignite.internal.processors.cache.distributed.GridDistributedCacheEntry
      - - org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheEntry

All Implemented Interfaces:
  GridCacheEntryEx

    public class GridDhtCacheEntry
    extends GridDistributedCacheEntry

Replicated cache entry.

### Nested Class Summary

Nested Classes
`static class` `GridDhtCacheEntry.ReaderId` Reader ID.

### Nested classes/interfaces inherited from class org.apache.ignite.internal.util.lang.GridMetadataAwareAdapter

`GridMetadataAwareAdapter.EntryKey`

### Field Summary

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

`ATOMIC_VER_COMPARATOR, cctx, flags, key, log, logRef, val, ver`

### Constructor Summary

Constructors
Constructor and Description
`GridDhtCacheEntry(GridCacheContext ctx, AffinityTopologyVersion topVer, KeyCacheObject key)`

### Method Summary

All Methods Instance Methods Concrete Methods
`IgniteInternalFuture<Boolean>` `addReader(UUID nodeId, long msgId, AffinityTopologyVersion topVer)`
`protected String` `cacheName()`
`Collection<GridDhtCacheEntry.ReaderId>` `checkReaders()`
`protected Collection<GridDhtCacheEntry.ReaderId>` `checkReadersLocked()`
`boolean` `clearInternal(GridCacheVersion ver, GridCacheObsoleteEntryExtras extras)` Marks entry as obsolete and, if possible or required, removes it from swap storage.
`void` `clearReader(UUID nodeId)`
`void` `clearReaders()` Clears all readers (usually when partition becomes invalid and ready for eviction).
`protected void` `decrementMapPublicSize()` Decrements public size of map.
`protected boolean` `hasReaders()`
`protected void` `incrementMapPublicSize()` Increments public size of map.
`boolean` `isDht()`
`protected GridDhtLocalPartition` `localPartition()`
`GridCacheMvccCandidate` `mappings(GridCacheVersion ver, Collection<ClusterNode> dhtNodeIds, Collection<ClusterNode> nearNodeIds)` Sets mappings into entry.
`int` `memorySize()`
`protected long` `nextPartitionCounter(AffinityTopologyVersion topVer, boolean primary, Long primaryCntr)`
`void` `onMarkedObsolete()` This method should be called each time entry is marked obsolete other than by calling `GridCacheEntryEx.markObsolete(GridCacheVersion)`.
`void` `onUnlock()` Calls `GridDhtLocalPartition.onUnlock()` for this entry's partition.
`int` `partition()`
`boolean` `partitionValid()`
`GridDhtCacheEntry.ReaderId` `readerId(UUID nodeId)`
`Collection<UUID>` `readers()`
`GridDhtCacheEntry.ReaderId[]` `readersLocked()`
`GridCacheMvccCandidate` `removeLock()` Unlocks local lock.
`boolean` `removeLock(GridCacheVersion ver)`
`void` `removeMapping(GridCacheVersion ver, ClusterNode mappedNode)`
`boolean` `removeReader(UUID nodeId, long msgId)`
`boolean` `tmLock(IgniteInternalTx tx, long timeout, GridCacheVersion serOrder, GridCacheVersion serReadVer, boolean read)` This locks is called by transaction manager during prepare step for optimistic transactions.
`String` `toString()`
`IgniteBiTuple<GridCacheVersion,CacheObject>` `versionedValue(AffinityTopologyVersion topVer)`

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

`addLocal, addRemote, addRemoved, checkCallbacks, checkRemoved, checkThreadChain, doneRemote, readyLock, readyNearLock, recheck, remoteMvccSnapshot, removeExplicitNodeLocks, txUnlock`

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

`allVersionsInfo, candidate, candidate, checkObsolete, checkOwnerChanged, checkSerializableReadVersion, clear, clearReserveForLoad, context, deleted, deletedUnlocked, deletedUnlocked, detached, equals, evictInternal, evictionDisabled, expireTime, expireTimeExtras, expireTimeUnlocked, hashCode, hasLockCandidate, hasLockCandidate, hasLockCandidateUnsafe, hasValue, hasValueUnlocked, info, initialValue, innerGet, innerGetAndReserveForLoad, innerGetVersioned, innerReload, innerRemove, innerSet, innerUpdate, innerUpdateLocal, invalidate, isInternal, isLocal, isMvcc, isNear, isNew, isNewLocked, isReplicated, isStartVersion, key, keyValue, localCandidate, localCandidates, localOwner, lockedBy, lockedByAny, lockedByCurrentThread, lockedByThread, lockedByThread, lockedByThread, lockedByThreadUnsafe, lockedByUnsafe, lockedLocally, lockedLocallyByIdOrThread, lockedLocallyUnsafe, lockEntry, logMvccUpdate, logTxUpdate, logUpdate, markObsolete, markObsolete0, markObsoleteIfEmpty, markObsoleteVersion, mvccAllLocal, mvccExtras, mvccExtras, mvccLock, mvccRemove, mvccSet, mvccUpdateRowsWithPreloadInfo, obsolete, obsolete, obsoleteOrDeleted, obsoleteVersion, obsoleteVersionExtras, onInvalidate, onTtlExpired, onUpdateFinished, peek, peek, peekVisibleValue, rawExpireTime, rawGet, rawPut, rawTtl, readThrough, recordNodeId, removeValue, storeValue, storeValue, touch, ttl, ttlAndExpireTimeExtras, ttlExtras, txKey, unlockEntry, unswap, unswap, unswap, unswap, update, updateIndex, updateTtl, valid, value, valueBytes, valueBytes, valueBytes0, version, versionedEntry, versionedValue, visitable, wrap, wrapEviction, wrapLazyValue, wrapVersioned`

### Methods inherited from class org.apache.ignite.internal.util.lang.GridMetadataAwareAdapter

`addMeta, addMetaIfAbsent, addMetaIfAbsent, allMeta, clone, copyMeta, copyMeta, hasMeta, hasMeta, meta, putMetaIfAbsent, readExternalMeta, removeAllMeta, 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.GridCacheEntryEx

`addMeta, hasMeta, initialValue, meta, putMetaIfAbsent, removeMeta, removeMeta, replaceMeta`

### Constructor Detail

#### GridDhtCacheEntry

    public GridDhtCacheEntry(GridCacheContext ctx,
                             AffinityTopologyVersion topVer,
                             KeyCacheObject key)

Parameters:
  `ctx` - Cache context.
  `topVer` - Topology version at the time of creation (if negative, then latest topology is assumed).
  `key` - Cache key.

### Method Detail

#### nextPartitionCounter

    protected long nextPartitionCounter(AffinityTopologyVersion topVer,
                                        boolean primary,
                                        @Nullable
                                        Long primaryCntr)

Overrides:
  `nextPartitionCounter` in class `GridCacheMapEntry`
Parameters:
  `topVer` - Topology version for current operation.
  `primary` - Primary node update flag.
  `primaryCntr` - Counter assigned on primary node.
Returns:
  Update counter.

#### memorySize

    public int memorySize()
                   throws IgniteCheckedException

Specified by:
  `memorySize` in interface `GridCacheEntryEx`
Overrides:
  `memorySize` in class `GridCacheMapEntry`
Returns:
  Memory size.
Throws:
  `IgniteCheckedException` - If failed.

#### partition

    public int partition()

Specified by:
  `partition` in interface `GridCacheEntryEx`
Overrides:
  `partition` in class `GridCacheMapEntry`
Returns:
  Partition ID.

#### localPartition

    protected GridDhtLocalPartition localPartition()

Overrides:
  `localPartition` in class `GridCacheMapEntry`
Returns:
  Local partition that owns this entry.

#### isDht

    public boolean isDht()

Specified by:
  `isDht` in interface `GridCacheEntryEx`
Overrides:
  `isDht` in class `GridCacheMapEntry`
Returns:
  `True` if DHT.

#### partitionValid

    public boolean partitionValid()

Specified by:
  `partitionValid` in interface `GridCacheEntryEx`
Overrides:
  `partitionValid` in class `GridCacheMapEntry`
Returns:
  `True` if partition is in valid.

#### onMarkedObsolete

    public void onMarkedObsolete()

This method should be called each time entry is marked obsolete other than by calling `GridCacheEntryEx.markObsolete(GridCacheVersion)`.

Specified by:
  `onMarkedObsolete` in interface `GridCacheEntryEx`
Overrides:
  `onMarkedObsolete` in class `GridCacheMapEntry`

#### tmLock

    public boolean tmLock(IgniteInternalTx tx,
                          long timeout,
                          @Nullable
                          GridCacheVersion serOrder,
                          GridCacheVersion serReadVer,
                          boolean read)
                   throws GridCacheEntryRemovedException,
                          GridDistributedLockCancelledException

This locks is called by transaction manager during prepare step for optimistic transactions.

Specified by:
  `tmLock` in interface `GridCacheEntryEx`
Overrides:
  `tmLock` in class `GridDistributedCacheEntry`
Parameters:
  `tx` - Cache transaction.
  `timeout` - Timeout for lock acquisition.
  `serOrder` - Version for serializable transactions ordering.
  `serReadVer` - Optional read entry version for optimistic serializable transaction.
  `read` - Read lock flag.
Returns:
  `True` if lock was acquired, `false` otherwise.
Throws:
  `GridCacheEntryRemovedException` - If this entry is obsolete.
  `GridDistributedLockCancelledException` - If lock has been cancelled.

#### removeLock

    public GridCacheMvccCandidate removeLock()

Unlocks local lock.

Overrides:
  `removeLock` in class `GridDistributedCacheEntry`
Returns:
  Removed candidate, or `null` if thread still holds the lock.

#### removeLock

    public boolean removeLock(GridCacheVersion ver)
                       throws GridCacheEntryRemovedException

Specified by:
  `removeLock` in interface `GridCacheEntryEx`
Overrides:
  `removeLock` in class `GridDistributedCacheEntry`
Parameters:
  `ver` - Removes lock.
Returns:
  `True` If lock has been removed.
Throws:
  `GridCacheEntryRemovedException` - If this entry has been removed from cache.

#### onUnlock

    public void onUnlock()

Calls `GridDhtLocalPartition.onUnlock()` for this entry's partition.

Specified by:
  `onUnlock` in interface `GridCacheEntryEx`
Overrides:
  `onUnlock` in class `GridCacheMapEntry`

#### versionedValue

    @Nullable
    public IgniteBiTuple<GridCacheVersion,CacheObject> versionedValue(AffinityTopologyVersion topVer)
                                                                         throws GridCacheEntryRemovedException

Parameters:
  `topVer` - Topology version.
Returns:
  Tuple with version and value of this entry, or `null` if entry is new.
Throws:
  `GridCacheEntryRemovedException` - If entry has been removed.

#### readers

    public Collection<UUID> readers()
                             throws GridCacheEntryRemovedException

Returns:
  Readers.
Throws:
  `GridCacheEntryRemovedException` - If removed.

#### readerId

    @Nullable
    public GridDhtCacheEntry.ReaderId readerId(UUID nodeId)

Parameters:
  `nodeId` - Node ID.
Returns:
  reader ID.

#### addReader

    @Nullable
    public IgniteInternalFuture<Boolean> addReader(UUID nodeId,
                                                             long msgId,
                                                             AffinityTopologyVersion topVer)
                                                      throws GridCacheEntryRemovedException

Parameters:
  `nodeId` - Reader to add.
  `msgId` - Message ID.
  `topVer` - Topology version.
Returns:
  Future for all relevant transactions that were active at the time of adding reader, or `null` if reader was added
Throws:
  `GridCacheEntryRemovedException` - If entry was removed.

#### removeReader

    public boolean removeReader(UUID nodeId,
                                long msgId)
                         throws GridCacheEntryRemovedException

Parameters:
  `nodeId` - Reader to remove.
  `msgId` - Message ID.
Returns:
  `True` if reader was removed as a result of this operation.
Throws:
  `GridCacheEntryRemovedException` - If entry was removed.

#### clearReaders

    public void clearReaders()

Clears all readers (usually when partition becomes invalid and ready for eviction).

Overrides:
  `clearReaders` in class `GridCacheMapEntry`

#### clearReader

    public void clearReader(UUID nodeId)
                     throws GridCacheEntryRemovedException

Overrides:
  `clearReader` in class `GridCacheMapEntry`
Parameters:
  `nodeId` - Node ID to clear.
Throws:
  `GridCacheEntryRemovedException` - If removed.

#### clearInternal

    public boolean clearInternal(GridCacheVersion ver,
                                 GridCacheObsoleteEntryExtras extras)
                          throws IgniteCheckedException

Marks entry as obsolete and, if possible or required, removes it from swap storage.

Parameters:
  `ver` - Obsolete version.
Returns:
  `True` if entry was not being used, passed the filter and could be removed.
Throws:
  `IgniteCheckedException` - If failed to remove from swap.

#### checkReaders

    public Collection<GridDhtCacheEntry.ReaderId> checkReaders()
                                                        throws GridCacheEntryRemovedException

Returns:
  Collection of readers after check.
Throws:
  `GridCacheEntryRemovedException` - If removed.

#### readersLocked

    @Nullable
    public GridDhtCacheEntry.ReaderId[] readersLocked()

Returns:
  Readers.

#### checkReadersLocked

    protected Collection<GridDhtCacheEntry.ReaderId> checkReadersLocked()
                                                                 throws GridCacheEntryRemovedException

Returns:
  Collection of readers after check.
Throws:
  `GridCacheEntryRemovedException` - If removed.

#### hasReaders

    protected boolean hasReaders()
                          throws GridCacheEntryRemovedException

Overrides:
  `hasReaders` in class `GridCacheMapEntry`
Returns:
  `true` if entry has readers. It makes sense only for dht entry.
Throws:
  `GridCacheEntryRemovedException` - If removed.

#### mappings

    @Nullable
    public GridCacheMvccCandidate mappings(GridCacheVersion ver,
                                                     Collection<ClusterNode> dhtNodeIds,
                                                     Collection<ClusterNode> nearNodeIds)
                                              throws GridCacheEntryRemovedException

Sets mappings into entry.

Parameters:
  `ver` - Version.
Returns:
  Candidate, if one existed for the version, or `null` if candidate was not found.
Throws:
  `GridCacheEntryRemovedException` - If removed.

#### removeMapping

    public void removeMapping(GridCacheVersion ver,
                              ClusterNode mappedNode)

Parameters:
  `ver` - Version.
  `mappedNode` - Mapped node to remove.

#### cacheName

    protected final String cacheName()

Returns:
  Cache name.

#### toString

    public String toString()

Overrides:
  `toString` in class `GridDistributedCacheEntry`

#### incrementMapPublicSize

    protected void incrementMapPublicSize()

Increments public size of map.

Overrides:
  `incrementMapPublicSize` in class `GridCacheMapEntry`

#### decrementMapPublicSize

    protected void decrementMapPublicSize()

Decrements public size of map.

Overrides:
  `decrementMapPublicSize` in class `GridCacheMapEntry`

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.7.6
Release Date | : September 11 2019