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

Direct Known Subclasses:
  GridDhtAtomicCacheEntry, GridDhtColocatedCacheEntry, GridDhtOffHeapCacheEntry

    public class GridDhtCacheEntry
    extends GridDistributedCacheEntry

Replicated 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, flags, key, log, logRef, startVer, val, ver`

### Constructor Summary

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

### Method Summary

Methods
`GridCacheMvccCandidate` `addDhtLocal(UUID nearNodeId, GridCacheVersion nearVer, AffinityTopologyVersion topVer, long threadId, GridCacheVersion ver, long timeout, boolean reenter, boolean tx, boolean implicitSingle)` Add local candidate.
`IgniteInternalFuture<Boolean>` `addReader(UUID nodeId, long msgId, AffinityTopologyVersion topVer)`
`protected String` `cacheName()`
`Collection<org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheEntry.ReaderId>` `checkReaders()`
`protected Collection<org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheEntry.ReaderId>` `checkReadersLocked()`
`boolean` `clearInternal(GridCacheVersion ver, boolean swap)` 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 boolean` `hasReaders()`
`boolean` `isDht()`
`GridCacheMvccCandidate` `localCandidateByNearVersion(GridCacheVersion nearVer, boolean rmv)`
`GridCacheMvccCandidate` `mappings(GridCacheVersion ver, Collection<ClusterNode> dhtNodeIds, Collection<ClusterNode> nearNodeIds)` Sets mappings into entry.
`int` `memorySize()`
`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()`
`org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheEntry.ReaderId` `readerId(UUID nodeId)`
`Collection<UUID>` `readers()`
`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)` 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, addRemote, addRemoved, checkCallbacks, checkOwnerChanged, checkRemoved, checkThreadChain, doneRemote, doneRemote, orderCompleted, readyLock, readyNearLock, recheck, refreshRemotes, remoteMvccSnapshot, removeExplicitNodeLocks, txUnlock`

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

`candidate, candidate, checkObsolete, clear, clearIndex, context, deleted, deletedUnlocked, deletedUnlocked, detached, equals, evictInBatchInternal, evictInternal, expireTime, expireTimeExtras, expireTimeUnlocked, hashCode, hasLockCandidate, hasLockCandidate, hasLockCandidateUnsafe, hasOffHeapPointer, hasValue, hasValueUnlocked, info, initialValue, initialValue, innerGet, innerReload, innerRemove, innerSet, innerUpdate, innerUpdateLocal, invalidate, invalidate, isInternal, isLocal, isNear, isNew, isNewLocked, isOffHeapValuesOnly, isReplicated, isStartVersion, key, keyValue, localCandidate, localCandidates, localOwner, lockedBy, lockedByAny, lockedByThread, lockedByThread, lockedByThread, lockedByThreadUnsafe, lockedByUnsafe, lockedLocally, lockedLocallyByIdOrThread, lockedLocallyUnsafe, markObsolete, markObsolete0, markObsoleteIfEmpty, markObsoleteVersion, mvccExtras, mvccExtras, obsolete, obsolete, obsoleteOrDeleted, obsoleteVersion, obsoleteVersionExtras, obsoleteVersionExtras, offHeapPointer, offHeapPointer, offheapSwapEvict, onInvalidate, onTtlExpired, peek, peek, peekVisibleValue, rawExpireTime, rawGet, rawGetOrUnmarshal, rawGetOrUnmarshalUnlocked, rawPut, rawTtl, readThrough, recordNodeId, releaseSwap, saveValueForIndexUnlocked, startVersion, ttl, ttlAndExpireTimeExtras, ttlExtras, txKey, unswap, unswap, update, updateIndex, updateTtl, valid, value, valueBytes, valueBytes, valueBytes0, valueBytesUnlocked, 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, meta, putMetaIfAbsent, removeMeta, removeMeta, replaceMeta`

### Constructor Detail

#### GridDhtCacheEntry

    public GridDhtCacheEntry(GridCacheContext ctx,
                     AffinityTopologyVersion topVer,
                     KeyCacheObject key,
                     int hash,
                     CacheObject val,
                     GridCacheMapEntry next,
                     int hdrId)

Parameters:
  `ctx` - Cache context.
  `topVer` - Topology version at the time of creation (if negative, then latest topology is assumed).
  `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.

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

#### localCandidateByNearVersion

    @Nullable
    public GridCacheMvccCandidate localCandidateByNearVersion(GridCacheVersion nearVer,
                                                              boolean rmv)
                                                       throws GridCacheEntryRemovedException

Parameters:
  `nearVer` - Near version.
  `rmv` - If `true`, then add to removed list if not found.
Returns:
  Local candidate by near version.
Throws:
  `GridCacheEntryRemovedException` - If removed.

#### addDhtLocal

    @Nullable
    public GridCacheMvccCandidate addDhtLocal(UUID nearNodeId,
                                              GridCacheVersion nearVer,
                                              AffinityTopologyVersion topVer,
                                              long threadId,
                                              GridCacheVersion ver,
                                              long timeout,
                                              boolean reenter,
                                              boolean tx,
                                              boolean implicitSingle)
                                       throws GridCacheEntryRemovedException,
                                              GridDistributedLockCancelledException

Add local candidate.

Parameters:
  `nearNodeId` - Near node ID.
  `nearVer` - Near version.
  `topVer` - Topology version.
  `threadId` - Owning thread ID.
  `ver` - Lock version.
  `timeout` - Timeout to acquire lock.
  `reenter` - Reentry flag.
  `tx` - Tx flag.
  `implicitSingle` - Implicit flag.
Returns:
  New candidate.
Throws:
  `GridCacheEntryRemovedException` - If entry has been removed.
  `GridDistributedLockCancelledException` - If lock was cancelled.

#### tmLock

    public boolean tmLock(IgniteInternalTx tx,
                 long timeout)
                   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.
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 org.apache.ignite.internal.processors.cache.distributed.dht.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,
                        boolean swap)
                          throws IgniteCheckedException

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

Parameters:
  `ver` - Obsolete version.
  `swap` - If `true` then remove from swap.
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<org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheEntry.ReaderId> checkReaders()
                                                                                                                    throws GridCacheEntryRemovedException

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

#### checkReadersLocked

    protected Collection<org.apache.ignite.internal.processors.cache.distributed.dht.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 String cacheName()

Returns:
  Cache name.

#### toString

    public String toString()

Overrides:
  `toString` in class `GridDistributedCacheEntry`

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.4.0
Release Date | : September 24 2015