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 Modifier and Type Class Description static classGridDhtCacheEntry.ReaderIdReader 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, DFLT_LOCK_TIMEOUT_ENV, ENTRY_LOCK_TIMEOUT_ENV, flags, key, log, logRef, val, ver
-
-
Constructor Summary
Constructors Constructor Description GridDhtCacheEntry(GridCacheContext ctx, AffinityTopologyVersion topVer, KeyCacheObject key)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @Nullable IgniteInternalFuture<Boolean>addReader(UUID nodeId, long msgId, AffinityTopologyVersion topVer)protected StringcacheName()Collection<GridDhtCacheEntry.ReaderId>checkReaders()protected Collection<GridDhtCacheEntry.ReaderId>checkReadersLocked()booleanclearInternal(GridCacheVersion ver, GridCacheObsoleteEntryExtras extras)Marks entry as obsolete and, if possible or required, removes it from swap storage.voidclearReader(UUID nodeId)voidclearReaders()Clears all readers (usually when partition becomes invalid and ready for eviction).protected voiddecrementMapPublicSize()Decrements public size of map.protected booleanhasReaders()protected voidincrementMapPublicSize()Increments public size of map.booleanisDht()protected GridDhtLocalPartitionlocalPartition()@Nullable GridCacheMvccCandidatemappings(GridCacheVersion ver, Collection<ClusterNode> dhtNodeIds, Collection<ClusterNode> nearNodeIds)Sets mappings into entry.intmemorySize()protected longnextPartitionCounter(AffinityTopologyVersion topVer, boolean primary, boolean init, @Nullable Long primaryCntr)protected longnextPartitionCounter(IgniteInternalTx tx, @Nullable Long primaryCntr)voidonMarkedObsolete()This method should be called each time entry is marked obsolete other than by callingGridCacheEntryEx.markObsolete(GridCacheVersion).voidonUnlock()CallsGridDhtLocalPartition.onUnlock()for this entry's partition.intpartition()booleanpartitionValid()@Nullable GridDhtCacheEntry.ReaderIdreaderId(UUID nodeId)Collection<UUID>readers()@Nullable GridDhtCacheEntry.ReaderId[]readersLocked()GridCacheMvccCandidateremoveLock()Unlocks local lock.booleanremoveLock(GridCacheVersion ver)voidremoveMapping(GridCacheVersion ver, ClusterNode mappedNode)booleanremoveReader(UUID nodeId, long msgId)booleantmLock(IgniteInternalTx tx, long timeout, @Nullable GridCacheVersion serOrder, GridCacheVersion serReadVer, boolean read)This locks is called by transaction manager during prepare step for optimistic transactions.StringtoString()@Nullable 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
-
Methods inherited from class org.apache.ignite.internal.processors.cache.GridCacheMapEntry
candidate, candidate, checkObsolete, checkOwnerChanged, 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, invalidate, isInternal, isLocal, isNear, isNew, isNewLocked, isReplicated, isStartVersion, key, keyValue, localCandidate, localCandidates, localOwner, lockedBy, lockedByAny, lockedByCurrentThread, lockedByThread, lockedByThread, lockedByThread, lockedByThreadUnsafe, lockedByUnsafe, lockedLocally, lockedLocallyByIdOrThread, lockedLocallyUnsafe, lockEntry, logTxUpdate, logUpdate, markObsolete, markObsolete0, markObsoleteIfEmpty, markObsoleteVersion, mvccAllLocal, mvccExtras, mvccExtras, obsolete, obsolete, obsoleteOrDeleted, obsoleteVersion, obsoleteVersionExtras, onInvalidate, onTtlExpired, onUpdateFinished, peek, peek, peekVisibleValue, rawExpireTime, rawGet, rawPut, rawTtl, readThrough, recordNodeId, removeValue, storeValue, storeValue, toStringWithTryLock, touch, tryLockEntry, ttl, ttlAndExpireTimeExtras, ttlExtras, txKey, txUnlock, unlockEntry, unswap, unswap, unswap, unswap, update, updateIndex, updatePlatformCache, updateTtl, 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, 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, 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, boolean init, @Nullable @Nullable Long primaryCntr)
- Overrides:
nextPartitionCounterin classGridCacheMapEntry- Parameters:
topVer- Topology version for current operation.primary- Primary node update flag.init-Trueif initial value.primaryCntr- Counter assigned on primary node.- Returns:
- Update counter.
-
nextPartitionCounter
protected long nextPartitionCounter(IgniteInternalTx tx, @Nullable @Nullable Long primaryCntr)
- Overrides:
nextPartitionCounterin classGridCacheMapEntry- Parameters:
tx- Tx.primaryCntr- Update counter.
-
memorySize
public int memorySize() throws IgniteCheckedException- Specified by:
memorySizein interfaceGridCacheEntryEx- Overrides:
memorySizein classGridCacheMapEntry- Returns:
- Memory size.
- Throws:
IgniteCheckedException- If failed.
-
partition
public int partition()
- Specified by:
partitionin interfaceGridCacheEntryEx- Overrides:
partitionin classGridCacheMapEntry- Returns:
- Partition ID.
-
localPartition
protected GridDhtLocalPartition localPartition()
- Overrides:
localPartitionin classGridCacheMapEntry- Returns:
- Local partition that owns this entry.
-
isDht
public boolean isDht()
- Specified by:
isDhtin interfaceGridCacheEntryEx- Overrides:
isDhtin classGridCacheMapEntry- Returns:
Trueif DHT.
-
partitionValid
public boolean partitionValid()
- Specified by:
partitionValidin interfaceGridCacheEntryEx- Overrides:
partitionValidin classGridCacheMapEntry- Returns:
Trueif partition is in valid.
-
onMarkedObsolete
public void onMarkedObsolete()
This method should be called each time entry is marked obsolete other than by callingGridCacheEntryEx.markObsolete(GridCacheVersion).- Specified by:
onMarkedObsoletein interfaceGridCacheEntryEx- Overrides:
onMarkedObsoletein classGridCacheMapEntry
-
tmLock
public boolean tmLock(IgniteInternalTx tx, long timeout, @Nullable @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:
tmLockin interfaceGridCacheEntryEx- Overrides:
tmLockin classGridDistributedCacheEntry- 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:
Trueif lock was acquired,falseotherwise.- Throws:
GridCacheEntryRemovedException- If this entry is obsolete.GridDistributedLockCancelledException- If lock has been cancelled.
-
removeLock
public GridCacheMvccCandidate removeLock()
Unlocks local lock.- Overrides:
removeLockin classGridDistributedCacheEntry- Returns:
- Removed candidate, or null if thread still holds the lock.
-
removeLock
public boolean removeLock(GridCacheVersion ver) throws GridCacheEntryRemovedException
- Specified by:
removeLockin interfaceGridCacheEntryEx- Overrides:
removeLockin classGridDistributedCacheEntry- Parameters:
ver- Removes lock.- Returns:
TrueIf lock has been removed.- Throws:
GridCacheEntryRemovedException- If this entry has been removed from cache.
-
onUnlock
public void onUnlock()
CallsGridDhtLocalPartition.onUnlock()for this entry's partition.- Specified by:
onUnlockin interfaceGridCacheEntryEx- Overrides:
onUnlockin classGridCacheMapEntry
-
versionedValue
@Nullable public @Nullable IgniteBiTuple<GridCacheVersion,CacheObject> versionedValue(AffinityTopologyVersion topVer) throws GridCacheEntryRemovedException
- Parameters:
topVer- Topology version.- Returns:
- Tuple with version and value of this entry, or
nullif 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 @Nullable GridDhtCacheEntry.ReaderId readerId(UUID nodeId)
- Parameters:
nodeId- Node ID.- Returns:
- reader ID.
-
addReader
@Nullable public @Nullable 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
nullif 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:
Trueif 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:
clearReadersin classGridCacheMapEntry
-
clearReader
public void clearReader(UUID nodeId) throws GridCacheEntryRemovedException
- Overrides:
clearReaderin classGridCacheMapEntry- 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:
Trueif 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 @Nullable 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:
hasReadersin classGridCacheMapEntry- Returns:
trueif entry has readers. It makes sense only for dht entry.- Throws:
GridCacheEntryRemovedException- If removed.
-
mappings
@Nullable public @Nullable 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
nullif 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:
toStringin classGridDistributedCacheEntry
-
incrementMapPublicSize
protected void incrementMapPublicSize()
Increments public size of map.- Overrides:
incrementMapPublicSizein classGridCacheMapEntry
-
decrementMapPublicSize
protected void decrementMapPublicSize()
Decrements public size of map.- Overrides:
decrementMapPublicSizein classGridCacheMapEntry
-
-