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

## Class GridNearCacheEntry

- 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.near.GridNearCacheEntry

All Implemented Interfaces:
  GridCacheEntryEx

    public class GridNearCacheEntry
    extends GridDistributedCacheEntry

Near cache entry.

### Nested Class Summary

### 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, DFLT_LOCK_TIMEOUT_ENV, ENTRY_LOCK_TIMEOUT_ENV, flags, key, log, logRef, val, ver`

### Constructor Summary

Constructors
Constructor and Description
`GridNearCacheEntry(GridCacheContext ctx, KeyCacheObject key)`

### Method Summary

All Methods Instance Methods Concrete Methods
`GridCacheMvccCandidate` `addLocal(long threadId, GridCacheVersion ver, AffinityTopologyVersion topVer, long timeout, boolean reenter, boolean tx, boolean implicitSingle, boolean read)` Add local candidate.
`@Nullable GridCacheMvccCandidate` `dhtNodeId(GridCacheVersion ver, UUID dhtNodeId)`
`@Nullable GridCacheVersion` `dhtVersion()`
`protected boolean` `evictionDisabled()`
`void` `initializeFromDht(AffinityTopologyVersion topVer)`
`boolean` `isNear()`
`boolean` `loadedValue(@Nullable IgniteInternalTx tx, UUID primaryNodeId, CacheObject val, GridCacheVersion ver, GridCacheVersion dhtVer, long ttl, long expireTime, boolean evt, boolean keepBinary, AffinityTopologyVersion topVer, UUID subjId)`
`protected WALPointer` `logTxUpdate(IgniteInternalTx tx, CacheObject val, long expireTime, long updCntr)`
`protected void` `logUpdate(GridCacheOperation op, CacheObject val, GridCacheVersion ver, long expireTime, long updCntr)`
`int` `memorySize()`
`protected void` `onInvalidate()` Called when entry invalidated.
`void` `onMarkedObsolete()` This method should be called each time entry is marked obsolete other than by calling `GridCacheEntryEx.markObsolete(GridCacheVersion)`.
`int` `partition()`
`protected Object` `readThrough(IgniteInternalTx tx, KeyCacheObject key, boolean reload, UUID subjId, String taskName)`
`boolean` `recordDhtVersion(GridCacheVersion dhtVer)`
`protected void` `recordNodeId(UUID primaryNodeId, AffinityTopologyVersion topVer)`
`@Nullable GridCacheMvccCandidate` `removeLock()` Unlocks local lock.
`protected void` `removeValue()` Removes value from offheap.
`boolean` `resetFromPrimary(CacheObject val, GridCacheVersion ver, GridCacheVersion dhtVer, UUID primaryNodeId, AffinityTopologyVersion topVer)` This method should be called only when lock is owned on this entry.
`protected boolean` `storeValue(CacheObject val, long expireTime, GridCacheVersion ver)` Stores value in offheap.
`String` `toString()`
`@Nullable CacheDataRow` `unswap(CacheDataRow row, boolean checkExpire)` Unswaps an entry.
`void` `updateOrEvict(GridCacheVersion dhtVer, @Nullable CacheObject val, long expireTime, long ttl, UUID primaryNodeId, AffinityTopologyVersion topVer)` This method should be called only when lock is owned on this entry.
`boolean` `valid(AffinityTopologyVersion topVer)`
`@Nullable IgniteBiTuple<GridCacheVersion,CacheObject>` `versionedValue()`

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

`addRemote, addRemoved, checkCallbacks, checkRemoved, checkThreadChain, doneRemote, readyLock, readyNearLock, recheck, remoteMvccSnapshot, removeExplicitNodeLocks, removeLock, tmLock`

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

`allVersionsInfo, candidate, candidate, checkObsolete, checkOwnerChanged, checkOwnerChanged, checkSerializableReadVersion, clear, clearReader, clearReaders, clearReserveForLoad, context, decrementMapPublicSize, deleted, deletedUnlocked, deletedUnlocked, detached, equals, evictInternal, expireTime, expireTimeExtras, expireTimeUnlocked, hashCode, hasLockCandidate, hasLockCandidate, hasLockCandidateUnsafe, hasReaders, hasValue, hasValueUnlocked, incrementMapPublicSize, info, initialValue, innerGet, innerGetAndReserveForLoad, innerGetVersioned, innerReload, innerRemove, innerSet, innerUpdate, innerUpdateLocal, invalidate, isDht, isInternal, isLocal, isMvcc, isNew, isNewLocked, isReplicated, isStartVersion, key, keyValue, localCandidate, localCandidates, localOwner, localPartition, lockedBy, lockedByAny, lockedByCurrentThread, lockedByThread, lockedByThread, lockedByThread, lockedByThreadUnsafe, lockedByUnsafe, lockedLocally, lockedLocallyByIdOrThread, lockedLocallyUnsafe, lockEntry, logMvccUpdate, markObsolete, markObsolete0, markObsoleteIfEmpty, markObsoleteVersion, mvccAllLocal, mvccExtras, mvccExtras, mvccLock, mvccPeek, mvccPreloadEntry, mvccRemove, mvccSet, mvccUpdateRowsWithPreloadInfo, nextPartitionCounter, nextPartitionCounter, obsolete, obsolete, obsoleteOrDeleted, obsoleteVersion, obsoleteVersionExtras, onTtlExpired, onUnlock, onUpdateFinished, partitionValid, peek, peek, peekVisibleValue, rawExpireTime, rawGet, rawPut, rawTtl, storeValue, toStringWithTryLock, touch, tryLockEntry, ttl, ttlAndExpireTimeExtras, ttlExtras, txKey, txUnlock, unlockEntry, unswap, unswap, unswap, update, updateIndex, updatePlatformCache, updateTtl, 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, removeAllMeta, removeMeta, removeMeta, replaceMeta`

### 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, initialValue, meta, putMetaIfAbsent, removeMeta, removeMeta, replaceMeta`

### Constructor Detail

#### GridNearCacheEntry

    public GridNearCacheEntry(GridCacheContext ctx,
                              KeyCacheObject key)

Parameters:
  `ctx` - Cache context.
  `key` - Cache key.

### Method Detail

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

#### isNear

    public boolean isNear()

Specified by:
  `isNear` in interface `GridCacheEntryEx`
Overrides:
  `isNear` in class `GridCacheMapEntry`
Returns:
  `True` if near.

#### valid

    public boolean valid(AffinityTopologyVersion topVer)

Specified by:
  `valid` in interface `GridCacheEntryEx`
Overrides:
  `valid` in class `GridCacheMapEntry`
Parameters:
  `topVer` - Topology version where validation should be performed. When negative the latest available topology should be used.
Returns:
  Checks if value is valid.

#### initializeFromDht

    public void initializeFromDht(AffinityTopologyVersion topVer)
                           throws GridCacheEntryRemovedException

Parameters:
  `topVer` - Topology version.
Throws:
  `GridCacheEntryRemovedException` - If this entry is obsolete.

#### resetFromPrimary

    public boolean resetFromPrimary(CacheObject val,
                                    GridCacheVersion ver,
                                    GridCacheVersion dhtVer,
                                    UUID primaryNodeId,
                                    AffinityTopologyVersion topVer)
                             throws GridCacheEntryRemovedException

This method should be called only when lock is owned on this entry.

Parameters:
  `val` - Value.
  `ver` - Version.
  `dhtVer` - DHT version.
  `primaryNodeId` - Primary node ID.
  `topVer` - Topology version.
Returns:
  `True` if reset was done.
Throws:
  `GridCacheEntryRemovedException` - If obsolete.

#### updateOrEvict

    public void updateOrEvict(GridCacheVersion dhtVer,
                              @Nullable
                              @Nullable CacheObject val,
                              long expireTime,
                              long ttl,
                              UUID primaryNodeId,
                              AffinityTopologyVersion topVer)

This method should be called only when lock is owned on this entry.

Parameters:
  `dhtVer` - DHT version.
  `val` - Value associated with version.
  `expireTime` - Expire time.
  `ttl` - Time to live.
  `primaryNodeId` - Primary node ID.
  `topVer` - Topology version.

#### dhtVersion

    @Nullable
    public @Nullable GridCacheVersion dhtVersion()
                                                    throws GridCacheEntryRemovedException

Returns:
  DHT version for this entry.
Throws:
  `GridCacheEntryRemovedException` - If obsolete.

#### versionedValue

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

Returns:
  Tuple with version and value of this entry.
Throws:
  `GridCacheEntryRemovedException` - If entry has been removed.

#### recordNodeId

    protected void recordNodeId(UUID primaryNodeId,
                                AffinityTopologyVersion topVer)

Overrides:
  `recordNodeId` in class `GridCacheMapEntry`
Parameters:
  `primaryNodeId` - Node ID.

#### recordDhtVersion

    public final boolean recordDhtVersion(GridCacheVersion dhtVer)

Parameters:
  `dhtVer` - DHT version to record.
Returns:
  `False` if given version is lower then existing version.

#### readThrough

    protected Object readThrough(IgniteInternalTx tx,
                                 KeyCacheObject key,
                                 boolean reload,
                                 UUID subjId,
                                 String taskName)
                          throws IgniteCheckedException

Overrides:
  `readThrough` in class `GridCacheMapEntry`
Parameters:
  `tx` - Transaction.
  `key` - Key.
  `reload` - flag.
  `subjId` - Subject ID.
  `taskName` - Task name.
Returns:
  Read value.
Throws:
  `IgniteCheckedException` - If failed.

#### loadedValue

    public boolean loadedValue(@Nullable
                               @Nullable IgniteInternalTx tx,
                               UUID primaryNodeId,
                               CacheObject val,
                               GridCacheVersion ver,
                               GridCacheVersion dhtVer,
                               long ttl,
                               long expireTime,
                               boolean evt,
                               boolean keepBinary,
                               AffinityTopologyVersion topVer,
                               UUID subjId)
                        throws IgniteCheckedException,
                               GridCacheEntryRemovedException

Parameters:
  `tx` - Transaction.
  `primaryNodeId` - Primary node ID.
  `val` - New value.
  `ver` - Version to use.
  `dhtVer` - DHT version received from remote node.
  `ttl` - Time to live.
  `expireTime` - Expiration time.
  `evt` - Event flag.
  `topVer` - Topology version.
  `subjId` - Subject ID.
Returns:
  `True` if initial value was set.
Throws:
  `IgniteCheckedException` - In case of error.
  `GridCacheEntryRemovedException` - If entry was removed.

#### storeValue

    protected boolean storeValue(CacheObject val,
                                 long expireTime,
                                 GridCacheVersion ver)

Stores value in offheap.

Overrides:
  `storeValue` in class `GridCacheMapEntry`
Parameters:
  `val` - Value.
  `expireTime` - Expire time.
  `ver` - New entry version.

#### removeValue

    protected void removeValue()

Removes value from offheap.

Overrides:
  `removeValue` in class `GridCacheMapEntry`

#### logUpdate

    protected void logUpdate(GridCacheOperation op,
                             CacheObject val,
                             GridCacheVersion ver,
                             long expireTime,
                             long updCntr)
                      throws IgniteCheckedException

Overrides:
  `logUpdate` in class `GridCacheMapEntry`
Parameters:
  `op` - Update operation.
  `val` - Write value.
  `ver` - Write version.
  `expireTime` - Expire time.
  `updCntr` - Update counter.
Throws:
  `IgniteCheckedException`

#### logTxUpdate

    protected WALPointer logTxUpdate(IgniteInternalTx tx,
                                     CacheObject val,
                                     long expireTime,
                                     long updCntr)
                              throws IgniteCheckedException

Overrides:
  `logTxUpdate` in class `GridCacheMapEntry`
Parameters:
  `tx` - Transaction.
  `val` - Value.
  `expireTime` - Expire time (or 0 if not applicable).
  `updCntr` - Update counter.
Throws:
  `IgniteCheckedException` - In case of log failure.

#### unswap

    @Nullable
    public @Nullable CacheDataRow unswap(CacheDataRow row,
                                                   boolean checkExpire)

Unswaps an entry.

Overrides:
  `unswap` in class `GridCacheMapEntry`
Parameters:
  `row` - Already extracted cache data.
  `checkExpire` - If `true` checks for expiration, as result entry can be obsoleted or marked deleted.
Returns:
  Value.

#### addLocal

    public GridCacheMvccCandidate addLocal(long threadId,
                                           GridCacheVersion ver,
                                           AffinityTopologyVersion topVer,
                                           long timeout,
                                           boolean reenter,
                                           boolean tx,
                                           boolean implicitSingle,
                                           boolean read)
                                    throws GridCacheEntryRemovedException

Add local candidate.

Overrides:
  `addLocal` in class `GridDistributedCacheEntry`
Parameters:
  `threadId` - Owning thread ID.
  `ver` - Lock version.
  `topVer` - Topology version.
  `timeout` - Timeout to acquire lock.
  `reenter` - Reentry flag.
  `tx` - Transaction flag.
  `implicitSingle` - Implicit flag.
  `read` - Read lock flag.
Returns:
  New candidate.
Throws:
  `GridCacheEntryRemovedException` - If entry has been removed.

#### dhtNodeId

    @Nullable
    public @Nullable GridCacheMvccCandidate dhtNodeId(GridCacheVersion ver,
                                                                UUID dhtNodeId)
                                                         throws GridCacheEntryRemovedException

Parameters:
  `ver` - Version to set DHT node ID for.
  `dhtNodeId` - DHT node ID.
Returns:
  `true` if candidate was found.
Throws:
  `GridCacheEntryRemovedException` - If entry is removed.

#### removeLock

    @Nullable
    public @Nullable GridCacheMvccCandidate removeLock()

Unlocks local lock.

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

#### onInvalidate

    protected void onInvalidate()

Called when entry invalidated.

Overrides:
  `onInvalidate` in class `GridCacheMapEntry`

#### evictionDisabled

    protected boolean evictionDisabled()

Overrides:
  `evictionDisabled` in class `GridCacheMapEntry`
Returns:
  `True` if this entry should not be evicted from cache.

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

#### toString

    public String toString()

Overrides:
  `toString` in class `GridDistributedCacheEntry`

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.10.0
Release Date | : March 10 2021