Class GridDhtCacheAdapter<K,V>
- java.lang.Object
-
- org.apache.ignite.internal.processors.cache.GridCacheAdapter<K,V>
-
- org.apache.ignite.internal.processors.cache.distributed.GridDistributedCacheAdapter<K,V>
-
- org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter<K,V>
-
- All Implemented Interfaces:
Externalizable,Serializable,Iterable<javax.cache.Cache.Entry<K,V>>,IgniteInternalCache<K,V>
- Direct Known Subclasses:
GridDhtAtomicCache,GridDhtTransactionalCacheAdapter
public abstract class GridDhtCacheAdapter<K,V> extends GridDistributedCacheAdapter<K,V>
DHT cache adapter.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classGridDhtCacheAdapter.MessageHandler<M>-
Nested classes/interfaces inherited from class org.apache.ignite.internal.processors.cache.distributed.GridDistributedCacheAdapter
GridDistributedCacheAdapter.GlobalRemoveAllJob<K,V>
-
Nested classes/interfaces inherited from class org.apache.ignite.internal.processors.cache.GridCacheAdapter
GridCacheAdapter.AsyncOp<T>, GridCacheAdapter.AtomicReadRepairEntryProcessor<K,V>, GridCacheAdapter.BulkOperation, GridCacheAdapter.CacheExpiryPolicy, GridCacheAdapter.FutureHolder, GridCacheAdapter.InvokeAllTimeStatClosure<T>, GridCacheAdapter.PeekModes, GridCacheAdapter.TopologyVersionAwareJob, GridCacheAdapter.UpdateGetAllTimeStatClosure<T>, GridCacheAdapter.UpdateGetAndRemoveTimeStatClosure<T>, GridCacheAdapter.UpdateGetTimeStatClosure<T>, GridCacheAdapter.UpdatePutAllConflictTimeStatClosure<T>, GridCacheAdapter.UpdatePutAllTimeStatClosure<T>, GridCacheAdapter.UpdatePutAndGetTimeStatClosure<T>, GridCacheAdapter.UpdatePutTimeStatClosure<T>, GridCacheAdapter.UpdateRemoveAllConflictTimeStatClosure<T>, GridCacheAdapter.UpdateRemoveAllTimeStatClosure<T>, GridCacheAdapter.UpdateRemoveTimeStatClosure, GridCacheAdapter.UpdateTimeStatClosure<T>
-
-
Field Summary
-
Fields inherited from class org.apache.ignite.internal.processors.cache.GridCacheAdapter
cacheCfg, CLEAR_ALL_SPLIT_THRESHOLD, ctx, DFLT_CACHE_RETRIES_COUNT, DFLT_CACHE_START_SIZE, DFLT_START_CACHE_SIZE, lastFut, locNodeId, log, map, MAX_RETRIES, metrics, NON_TRANSACTIONAL_IGNITE_CACHE_CLEAR_IN_TX_ERROR_MESSAGE, RET2NULL, txLockMsgLog
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedGridDhtCacheAdapter()Empty constructor required forExternalizable.protectedGridDhtCacheAdapter(GridCacheContext<K,V> ctx)protectedGridDhtCacheAdapter(GridCacheContext<K,V> ctx, GridCacheConcurrentMap map)Constructor used for near-only cache.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanaddFuture(GridDhtForceKeysFuture<?,?> fut)Adds future to future map.protected GridDistributedCacheEntrycreateEntry(KeyCacheObject key)voiddumpDebugInfo()GridCacheEntryExentryEx(KeyCacheObject key, AffinityTopologyVersion topVer)GridDhtCacheEntryentryExx(KeyCacheObject key)GridDhtCacheEntryentryExx(KeyCacheObject key, AffinityTopologyVersion topVer)IgniteInternalFuture<Map<K,V>>getAllAsync(@Nullable Collection<? extends K> keys, boolean forcePrimary, boolean skipTx, String taskName, boolean deserializeBinary, boolean recovery, ReadRepairStrategy readRepairStrategy, boolean skipVals, boolean needVer)GridDhtFuture<Collection<GridCacheEntryInfo>>getDhtAsync(UUID reader, long msgId, Map<KeyCacheObject,Boolean> keys, boolean addReaders, boolean readThrough, AffinityTopologyVersion topVer, int taskNameHash, @Nullable IgniteCacheExpiryPolicy expiry, boolean skipVals, boolean recovery, @Nullable String txLbl)Iterator<javax.cache.Cache.Entry<K,V>>localEntriesIterator(boolean primary, boolean backup, boolean keepBinary)voidlocalLoad(Collection<? extends K> keys, javax.cache.expiry.ExpiryPolicy plc, boolean keepBinary)voidlocalLoadCache(IgniteBiPredicate<K,V> p, Object[] args)Delegates toCacheStore.loadCache(IgniteBiInClosure, Object...)method to load state from the underlying persistent storage.abstract GridNearCacheAdapter<K,V>near()protected booleanneedRemap(AffinityTopologyVersion rmtVer)voidonDeferredDelete(GridCacheEntryEx entry, GridCacheVersion ver)voidonKernalStart()Kernal start callback.voidonKernalStop()Kernal stop callback.@Nullable GridDhtCacheEntrypeekExx(KeyCacheObject key)GridCachePreloaderpreloader()intprimarySize()Gets the number of all primary entries cached on this node.longprimarySizeLong()Gets the number of all primary entries cached on this node as a long value.voidprintMemoryStats()Prints memory stats.protected voidprocessForceKeyResponse(ClusterNode node, GridDhtForceKeysResponse msg)protected voidprocessForceKeysRequest(ClusterNode node, GridDhtForceKeysRequest msg)protected voidprocessNearGetRequest(UUID nodeId, GridNearGetRequest req)protected voidprocessNearGetResponse(UUID nodeId, GridNearGetResponse res)protected voidprocessNearSingleGetRequest(UUID nodeId, GridNearSingleGetRequest req)protected voidprocessNearSingleGetResponse(UUID nodeId, GridNearSingleGetResponse res)voidremoveFuture(GridDhtForceKeysFuture<?,?> fut)Removes future from future map.voidsendTtlUpdateRequest(@Nullable IgniteCacheExpiryPolicy expiryPlc)Initiates process of notifying all interested nodes that TTL was changed.intsize()Gets the number of all entries cached on this node.longsizeLong()Gets the number of all entries cached on this node as a long value.List<GridCacheClearAllRunnable<K,V>>splitClearLocally(boolean srv, boolean near, boolean readers)Split clearLocally all task into multiple runnables.GridDhtPartitionTopologytopology()StringtoString()voidunlockAll(Collection<? extends K> keys)Unlocks given keys only if current thread owns the locks.-
Methods inherited from class org.apache.ignite.internal.processors.cache.distributed.GridDistributedCacheAdapter
localSizeLong, localSizeLong, lockAllAsync, lockAllAsync, removeAll, removeAllAsync, removeVersionedEntry, txLockAsync
-
Methods inherited from class org.apache.ignite.internal.processors.cache.GridCacheAdapter
active, active, affinity, allEntries, asyncOp, asyncOpAcquire, asyncOpRelease, cache, checkJta, clear, clear, clearAll, clearAllAsync, clearAsync, clearAsync, clearLocally, clearLocally, clearLocally, clearLocallyAll, clusterMetrics, clusterMetrics, configuration, containsKey, containsKeyAsync, containsKeys, containsKeysAsync, context, decrementSize, entries, entryEx, entryEx, entrySet, entrySet, evict, evictAll, expiry, expiryPolicy, get, get, getAll, getAll, getAllAsync, getAllOutTx, getAllOutTxAsync, getAndPut, getAndPut, getAndPut0, getAndPutAsync, getAndPutAsync, getAndPutAsync0, getAndPutIfAbsent, getAndPutIfAbsentAsync, getAndRemove, getAndRemove0, getAndRemoveAsync, getAndRemoveAsync0, getAndReplace, getAndReplaceAsync, getAsync, getAsync, getEntries, getEntriesAsync, getEntry, getEntryAsync, getForcePrimary, getForcePrimaryAsync, igniteIterator, igniteIterator, incrementSize, init, invoke, invoke, invokeAll, invokeAll, invokeAllAsync, invokeAllAsync, invokeAsync, isColocated, isDht, isDhtAtomic, isEmpty, isLocal, isLocked, isLockedByThread, isNear, iterator, iterator, keepBinary, keySet, lastAsyncFuture, loadAll, localEntries, localLoadCacheAsync, localMetrics, localPeek, localPreloadPartition, localSize, lock, lockAll, lockAsync, log, lostPartitions, map, metrics0, name, nearSize, nextVersion, nextVersion, offHeapAllocatedSize, offHeapEntriesCount, onReconnected, onUndeploy, parsePeekModes, peekEx, peekEx, preloadPartition, preloadPartitionAsync, put, put, put0, putAll, putAll0, putAllAsync, putAllAsync0, putAllConflict, putAllConflictAsync, putAsync, putAsync, putAsync0, putIfAbsent, putIfAbsentAsync, readExternal, readResolve, rebalance, remove, remove, remove, remove0, removeAll, removeAll0, removeAllAsync, removeAllAsync0, removeAllConflict, removeAllConflictAsync, removeAsync, removeAsync, removeAsync, removeAsync0, removeEntry, removeIfObsolete, removeMetrics, repairableGet, repairableGetAll, repairableGetAllAsync, repairableGetAsync, replace, replace, replaceAsync, replaceAsync, scanIterator, setSkipStore, size, sizeAsync, sizeLong, sizeLong, sizeLongAsync, sizeLongAsync, skipStore, start, startInfo, stop, stopInfo, tx, txStart, txStart, txStartEx, unlock, warnIfUnordered, warnIfUnordered, withExpiryPolicy, withNoRetries, writeExternal
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
GridDhtCacheAdapter
protected GridDhtCacheAdapter()
Empty constructor required forExternalizable.
-
GridDhtCacheAdapter
protected GridDhtCacheAdapter(GridCacheContext<K,V> ctx)
- Parameters:
ctx- Context.
-
GridDhtCacheAdapter
protected GridDhtCacheAdapter(GridCacheContext<K,V> ctx, GridCacheConcurrentMap map)
Constructor used for near-only cache.- Parameters:
ctx- Cache context.map- Cache map.
-
-
Method Detail
-
addFuture
public boolean addFuture(GridDhtForceKeysFuture<?,?> fut)
Adds future to future map.- Parameters:
fut- Future to add.- Returns:
Falseif node cache is stopping and future was completed with error.
-
removeFuture
public void removeFuture(GridDhtForceKeysFuture<?,?> fut)
Removes future from future map.- Parameters:
fut- Future to remove.
-
processForceKeyResponse
protected final void processForceKeyResponse(ClusterNode node, GridDhtForceKeysResponse msg)
- Parameters:
node- Node.msg- Message.
-
processForceKeysRequest
protected final void processForceKeysRequest(ClusterNode node, GridDhtForceKeysRequest msg)
- Parameters:
node- Node originated request.msg- Force keys message.
-
dumpDebugInfo
public void dumpDebugInfo()
-
onKernalStop
public void onKernalStop()
Kernal stop callback.- Overrides:
onKernalStopin classGridCacheAdapter<K,V>
-
processNearGetResponse
protected final void processNearGetResponse(UUID nodeId, GridNearGetResponse res)
- Parameters:
nodeId- Sender node ID.res- Near get response.
-
processNearSingleGetResponse
protected void processNearSingleGetResponse(UUID nodeId, GridNearSingleGetResponse res)
- Parameters:
nodeId- Sender node ID.res- Near get response.
-
onKernalStart
public void onKernalStart() throws IgniteCheckedExceptionKernal start callback.- Overrides:
onKernalStartin classGridCacheAdapter<K,V>- Throws:
IgniteCheckedException- If callback failed.
-
printMemoryStats
public void printMemoryStats()
Prints memory stats.- Overrides:
printMemoryStatsin classGridCacheAdapter<K,V>
-
near
public abstract GridNearCacheAdapter<K,V> near()
- Returns:
- Near cache.
-
topology
public GridDhtPartitionTopology topology()
- Returns:
- Partition topology.
-
preloader
public GridCachePreloader preloader()
- Specified by:
preloaderin classGridCacheAdapter<K,V>- Returns:
- Preloader.
-
peekExx
@Nullable public @Nullable GridDhtCacheEntry peekExx(KeyCacheObject key)
- Parameters:
key- Key.- Returns:
- DHT entry.
-
entryEx
public GridCacheEntryEx entryEx(KeyCacheObject key, AffinityTopologyVersion topVer) throws GridDhtInvalidPartitionException
- Overrides:
entryExin classGridCacheAdapter<K,V>- Parameters:
key- Entry key.topVer- Topology version.- Returns:
- Entry (never
null). - Throws:
GridDhtInvalidPartitionException- If partition for the key is no longer valid.
-
entryExx
public GridDhtCacheEntry entryExx(KeyCacheObject key) throws GridDhtInvalidPartitionException
- Parameters:
key- Key.- Returns:
- DHT entry.
- Throws:
GridDhtInvalidPartitionException- If partition for the key is no longer valid.
-
entryExx
public GridDhtCacheEntry entryExx(KeyCacheObject key, AffinityTopologyVersion topVer) throws GridDhtInvalidPartitionException
- Parameters:
key- Key.topVer- Topology version.- Returns:
- DHT entry.
- Throws:
GridDhtInvalidPartitionException- If partition for the key is no longer valid.
-
createEntry
protected GridDistributedCacheEntry createEntry(KeyCacheObject key)
- Parameters:
key- Key for which entry should be returned.- Returns:
- Cache entry.
-
localLoad
public void localLoad(Collection<? extends K> keys, javax.cache.expiry.ExpiryPolicy plc, boolean keepBinary) throws IgniteCheckedException
- Overrides:
localLoadin classGridCacheAdapter<K,V>- Parameters:
keys- Keys to load.plc- Optional expiry policy.- Throws:
IgniteCheckedException- If failed.
-
localLoadCache
public void localLoadCache(IgniteBiPredicate<K,V> p, Object[] args) throws IgniteCheckedException
Delegates toCacheStore.loadCache(IgniteBiInClosure, Object...)method to load state from the underlying persistent storage. The loaded values will then be given to the optionally passed in predicate, and, if the predicate returnstrue, will be stored in cache. If predicate isnull, then all loaded values will be stored in cache.Note that this method does not receive keys as a parameter, so it is up to
CacheStoreimplementation to provide all the data to be loaded.This method is not transactional and may end up loading a stale value into cache if another thread has updated the value immediately after it has been loaded. It is mostly useful when pre-loading the cache from underlying data store before start, or for read-only caches.
- Specified by:
localLoadCachein interfaceIgniteInternalCache<K,V>- Overrides:
localLoadCachein classGridCacheAdapter<K,V>- Parameters:
p- Optional predicate (may benull). If provided, will be used to filter values to be put into cache.args- Optional user arguments to be passed intoCacheStore.loadCache(IgniteBiInClosure, Object...)method.- Throws:
IgniteCheckedException- If loading failed.
-
size
public int size()
Gets the number of all entries cached on this node. This method will return the count of all cache entries and has O(1) complexity on baseIgniteInternalCache. It is essentially the size of cache key set and is semantically identical to {Cache.keySet().size().NOTE: this operation is not distributed and returns only the number of entries cached on this node.
- Specified by:
sizein interfaceIgniteInternalCache<K,V>- Overrides:
sizein classGridCacheAdapter<K,V>- Returns:
- Size of cache on this node.
-
sizeLong
public long sizeLong()
Gets the number of all entries cached on this node as a long value. This method will return the count of all cache entries and has O(1) complexity on baseIgniteInternalCache. It is essentially the size of cache key set and is semantically identical to {Cache.keySet().size().NOTE: this operation is not distributed and returns only the number of entries cached on this node.
- Specified by:
sizeLongin interfaceIgniteInternalCache<K,V>- Overrides:
sizeLongin classGridCacheAdapter<K,V>- Returns:
- Size of cache on this node.
-
primarySize
public int primarySize()
Gets the number of all primary entries cached on this node.For
CacheMode.PARTITIONEDandCacheMode.REPLICATEDmodes, this method will return number of primary entries cached on this node (excluding any backups). The complexity of this method is O(P), where P is the total number of partitions.NOTE: this operation is not distributed and returns only the number of primary entries cached on this node.
- Specified by:
primarySizein interfaceIgniteInternalCache<K,V>- Overrides:
primarySizein classGridCacheAdapter<K,V>- Returns:
- Number of primary entries in cache.
-
primarySizeLong
public long primarySizeLong()
Gets the number of all primary entries cached on this node as a long value.For
CacheMode.PARTITIONEDandCacheMode.REPLICATEDmodes, this method will return number of primary entries cached on this node (excluding any backups). The complexity of this method is O(P), where P is the total number of partitions.NOTE: this operation is not distributed and returns only the number of primary entries cached on this node.
- Specified by:
primarySizeLongin interfaceIgniteInternalCache<K,V>- Overrides:
primarySizeLongin classGridCacheAdapter<K,V>- Returns:
- Number of primary entries in cache.
-
getAllAsync
public IgniteInternalFuture<Map<K,V>> getAllAsync(@Nullable @Nullable Collection<? extends K> keys, boolean forcePrimary, boolean skipTx, String taskName, boolean deserializeBinary, boolean recovery, ReadRepairStrategy readRepairStrategy, boolean skipVals, boolean needVer)
- Specified by:
getAllAsyncin classGridCacheAdapter<K,V>- Parameters:
keys- Keys.forcePrimary- Force primary.skipTx- Skip tx.taskName- Task name.deserializeBinary- Deserialize binary.recovery- Recovery mode flag.skipVals- Skip values.needVer- Need version.- Returns:
- Future for the get operation.
- See Also:
GridCacheAdapter.getAllAsync(Collection)
-
getDhtAsync
public GridDhtFuture<Collection<GridCacheEntryInfo>> getDhtAsync(UUID reader, long msgId, Map<KeyCacheObject,Boolean> keys, boolean addReaders, boolean readThrough, AffinityTopologyVersion topVer, int taskNameHash, @Nullable @Nullable IgniteCacheExpiryPolicy expiry, boolean skipVals, boolean recovery, @Nullable @Nullable String txLbl)
- Parameters:
reader- Reader node ID.msgId- Message ID.keys- Keys to get.addReaders- Add readers flag.readThrough- Read through flag.topVer- Topology version.taskNameHash- Task name hash code.expiry- Expiry policy.skipVals- Skip values flag.txLbl- Transaction label.- Returns:
- DHT future.
-
processNearSingleGetRequest
protected void processNearSingleGetRequest(UUID nodeId, GridNearSingleGetRequest req)
- Parameters:
nodeId- Node ID.req- Get request.
-
processNearGetRequest
protected void processNearGetRequest(UUID nodeId, GridNearGetRequest req)
- Parameters:
nodeId- Node ID.req- Get request.
-
sendTtlUpdateRequest
public void sendTtlUpdateRequest(@Nullable @Nullable IgniteCacheExpiryPolicy expiryPlc)Initiates process of notifying all interested nodes that TTL was changed. Directly sends requests to primary nodes andIgniteCacheExpiryPolicy.readers().- Parameters:
expiryPlc- Expiry policy.
-
unlockAll
public void unlockAll(Collection<? extends K> keys)
Unlocks given keys only if current thread owns the locks. Only the keys that have been locked by calling thread and pass through the filter (if any) will be unlocked. If none of the key locks is owned by current thread, then this method will do nothing.Transactions
Locks are not transactional and should not be used from within transactions. If you do need explicit locking within transaction, then you should useTransactionConcurrency.PESSIMISTICconcurrency control for transaction which will acquire explicit locks for relevant cache operations.- Parameters:
keys- Keys to unlock.
-
toString
public String toString()
- Overrides:
toStringin classGridDistributedCacheAdapter<K,V>
-
splitClearLocally
public List<GridCacheClearAllRunnable<K,V>> splitClearLocally(boolean srv, boolean near, boolean readers)
Split clearLocally all task into multiple runnables.- Overrides:
splitClearLocallyin classGridCacheAdapter<K,V>- Parameters:
srv- Whether to clear server cache.near- Whether to clear near cache.readers- Whether to clear readers.- Returns:
- Split runnables.
-
onDeferredDelete
public void onDeferredDelete(GridCacheEntryEx entry, GridCacheVersion ver)
- Specified by:
onDeferredDeletein classGridCacheAdapter<K,V>- Parameters:
entry- Entry.ver- Version.
-
needRemap
protected final boolean needRemap(AffinityTopologyVersion rmtVer)
- Parameters:
rmtVer- Topology version that the cache request was mapped to by the remote node.- Returns:
Trueif cache affinity changed and operation should be remapped.
-
localEntriesIterator
public Iterator<javax.cache.Cache.Entry<K,V>> localEntriesIterator(boolean primary, boolean backup, boolean keepBinary)
- Parameters:
primary- Iftrueincludes primary entries.backup- Iftrueincludes backup entries.keepBinary- Keep binary flag.- Returns:
- Local entries iterator.
-
-