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

## Class GridNearCacheEntry

- java.lang.Object
- - 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

Direct Known Subclasses:
  GridNearOffHeapCacheEntry

    public class GridNearCacheEntry
    extends GridDistributedCacheEntry

Near cache entry.

### Field Summary

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

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

### Constructor Summary

Constructors
Constructor and Description
`GridNearCacheEntry(GridCacheContext ctx, KeyCacheObject key, int hash, CacheObject val, GridCacheMapEntry next, int hdrId)`

### Method Summary

Methods
`GridCacheMvccCandidate` `addLocal(long threadId, GridCacheVersion ver, long timeout, boolean reenter, boolean tx, boolean implicitSingle)` Add local candidate.
`GridCacheMvccCandidate` `addNearLocal(UUID dhtNodeId, long threadId, GridCacheVersion ver, long timeout, boolean reenter, boolean tx, boolean implicitSingle)` Add near local candidate.
`protected void` `clearIndex(CacheObject val)` Clears index.
`GridCacheMvccCandidate` `dhtNodeId(GridCacheVersion ver, UUID dhtNodeId)`
`GridCacheVersion` `dhtVersion()`
`boolean` `initializeFromDht(AffinityTopologyVersion topVer)`
`boolean` `isNear()`
`boolean` `loadedValue(IgniteInternalTx tx, UUID primaryNodeId, CacheObject val, GridCacheVersion ver, GridCacheVersion dhtVer, GridCacheVersion expVer, long ttl, long expireTime, boolean evt, AffinityTopologyVersion topVer, UUID subjId)`
`int` `memorySize()`
`protected void` `onInvalidate()` Called when entry invalidated.
`int` `partition()`
`protected Object` `readThrough(IgniteInternalTx tx, KeyCacheObject key, boolean reload, UUID subjId, String taskName)`
`void` `recordDhtVersion(GridCacheVersion dhtVer)` This method should be called only when committing optimistic transactions.
`protected void` `recordNodeId(UUID primaryNodeId, AffinityTopologyVersion topVer)`
`GridCacheMvccCandidate` `removeLock()` Unlocks local lock.
`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.
`String` `toString()`
`protected void` `updateIndex(CacheObject val, long expireTime, GridCacheVersion ver, CacheObject old)` Updates cache index.
`void` `updateOrEvict(GridCacheVersion dhtVer, 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)`
`IgniteBiTuple<GridCacheVersion,CacheObject>` `versionedValue()`

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

`addRemote, addRemote, addRemoved, checkCallbacks, checkOwnerChanged, checkRemoved, checkThreadChain, doneRemote, doneRemote, orderCompleted, readyLock, readyNearLock, recheck, refreshRemotes, remoteMvccSnapshot, removeExplicitNodeLocks, removeLock, tmLock, txUnlock`

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

`addMeta, candidate, candidate, checkObsolete, clear, clearReader, clearReaders, context, deleted, deletedUnlocked, deletedUnlocked, detached, equals, evictInBatchInternal, evictInternal, expireTime, expireTimeExtras, expireTimeUnlocked, hashCode, hasLockCandidate, hasLockCandidate, hasLockCandidateUnsafe, hasMeta, hasOffHeapPointer, hasReaders, hasValue, hasValueUnlocked, info, initialValue, initialValue, innerGet, innerReload, innerRemove, innerSet, innerUpdate, innerUpdateLocal, invalidate, invalidate, isDht, isInternal, isLocal, isNew, isNewLocked, isOffHeapValuesOnly, isReplicated, isStartVersion, key, keyValue, localCandidate, localCandidates, localOwner, lockedBy, lockedByAny, lockedByThread, lockedByThread, lockedByThread, lockedByThreadUnsafe, lockedByUnsafe, lockedLocally, lockedLocallyByIdOrThread, lockedLocallyUnsafe, markObsolete, markObsolete0, markObsoleteIfEmpty, markObsoleteVersion, meta, mvccExtras, mvccExtras, obsolete, obsolete, obsoleteOrDeleted, obsoleteVersion, obsoleteVersionExtras, obsoleteVersionExtras, offHeapPointer, offHeapPointer, onMarkedObsolete, onTtlExpired, onUnlock, partitionValid, peek, peek, peekVisibleValue, putMetaIfAbsent, rawExpireTime, rawGet, rawGetOrUnmarshal, rawGetOrUnmarshalUnlocked, rawPut, rawTtl, readExternalMeta, releaseSwap, removeMeta, removeMeta, replaceMeta, saveValueForIndexUnlocked, startVersion, ttl, ttlAndExpireTimeExtras, ttlExtras, txKey, unswap, unswap, update, updateTtl, value, valueBytes, valueBytes, valueBytes0, valueBytesUnlocked, version, versionedEntry, versionedValue, visitable, wrap, wrapEviction, wrapLazyValue, wrapVersioned, writeExternalMeta`

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

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

### Constructor Detail

#### GridNearCacheEntry

    public GridNearCacheEntry(GridCacheContext ctx,
                      KeyCacheObject key,
                      int hash,
                      CacheObject val,
                      GridCacheMapEntry next,
                      int hdrId)

Parameters:
  `ctx` - Cache context.
  `key` - Cache key.
  `hash` - Key hash value.
  `val` - Entry value.
  `next` - Next entry in the linked list.
  `hdrId` - Header id.

### 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 boolean initializeFromDht(AffinityTopologyVersion topVer)
                              throws GridCacheEntryRemovedException

Parameters:
  `topVer` - Topology version.
Returns:
  `True` if this entry was initialized by this call.
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
                     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 GridCacheVersion dhtVersion()
                                throws GridCacheEntryRemovedException

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

#### versionedValue

    @Nullable
    public 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 void recordDhtVersion(GridCacheVersion dhtVer)

This method should be called only when committing optimistic transactions.

Parameters:
  `dhtVer` - DHT version to record.

#### 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
                      IgniteInternalTx tx,
                      UUID primaryNodeId,
                      CacheObject val,
                      GridCacheVersion ver,
                      GridCacheVersion dhtVer,
                      @Nullable
                      GridCacheVersion expVer,
                      long ttl,
                      long expireTime,
                      boolean evt,
                      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.
  `expVer` - Optional version to match.
  `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.

#### updateIndex

    protected void updateIndex(CacheObject val,
                   long expireTime,
                   GridCacheVersion ver,
                   CacheObject old)
                        throws IgniteCheckedException

Updates cache index.

Overrides:
  `updateIndex` in class `GridCacheMapEntry`
Parameters:
  `val` - Value.
  `expireTime` - Expire time.
  `ver` - New entry version.
  `old` - Previous value.
Throws:
  `IgniteCheckedException` - If update failed.

#### clearIndex

    protected void clearIndex(CacheObject val)

Clears index.

Overrides:
  `clearIndex` in class `GridCacheMapEntry`
Parameters:
  `val` - Previous value (if needed for index update).

#### addLocal

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

Add local candidate.

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

#### addNearLocal

    @Nullable
    public GridCacheMvccCandidate addNearLocal(@Nullable
                                               UUID dhtNodeId,
                                               long threadId,
                                               GridCacheVersion ver,
                                               long timeout,
                                               boolean reenter,
                                               boolean tx,
                                               boolean implicitSingle)
                                        throws GridCacheEntryRemovedException

Add near local candidate.

Parameters:
  `dhtNodeId` - DHT node ID.
  `threadId` - Owning thread ID.
  `ver` - Lock version.
  `timeout` - Timeout to acquire lock.
  `reenter` - Reentry flag.
  `tx` - Transaction flag.
  `implicitSingle` - Implicit flag.
Returns:
  New candidate.
Throws:
  `GridCacheEntryRemovedException` - If entry has been removed.

#### dhtNodeId

    @Nullable
    public 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 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`

#### toString

    public String toString()

Overrides:
  `toString` in class `GridDistributedCacheEntry`

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.2.0-incubating
Release Date | : June 16 2015