Package org.infinispan.interceptors.impl
Class CacheLoaderInterceptor<K,V>
- java.lang.Object
-
- org.infinispan.interceptors.BaseAsyncInterceptor
-
- org.infinispan.interceptors.DDAsyncInterceptor
-
- org.infinispan.interceptors.impl.JmxStatsCommandInterceptor
-
- org.infinispan.interceptors.impl.CacheLoaderInterceptor<K,V>
-
- All Implemented Interfaces:
Visitor,AsyncInterceptor,JmxStatisticsExposer,EntryLoader<K,V>
- Direct Known Subclasses:
ClusteredCacheLoaderInterceptor,PassivationCacheLoaderInterceptor
@MBean(objectName="CacheLoader", description="Component that handles loading entries from a CacheStore into memory.") public class CacheLoaderInterceptor<K,V> extends JmxStatsCommandInterceptor implements EntryLoader<K,V>- Since:
- 9.0
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanactivationprotected AtomicLongcacheLoadsprotected AtomicLongcacheMissesprotected EntryFactoryentryFactoryprotected ExecutorServicenonBlockingExecutorprotected CacheNotifiernotifierprotected PersistenceManagerpersistenceManager-
Fields inherited from class org.infinispan.interceptors.BaseAsyncInterceptor
cacheConfiguration
-
-
Constructor Summary
Constructors Constructor Description CacheLoaderInterceptor()
-
Method Summary
-
Methods inherited from class org.infinispan.interceptors.impl.JmxStatsCommandInterceptor
getStatisticsEnabled, onStart, setStatisticsEnabled
-
Methods inherited from class org.infinispan.interceptors.DDAsyncInterceptor
handleDefault, visitClearCommand, visitCommand, visitCommitCommand, visitEvictCommand, visitInvalidateCommand, visitInvalidateL1Command, visitLockControlCommand, visitPrepareCommand, visitPutMapCommand, visitRollbackCommand, visitUnknownCommand, visitWriteOnlyKeyCommand, visitWriteOnlyKeyValueCommand, visitWriteOnlyManyCommand, visitWriteOnlyManyEntriesCommand
-
Methods inherited from class org.infinispan.interceptors.BaseAsyncInterceptor
asyncInvokeNext, asyncInvokeNext, asyncInvokeNext, asyncValue, delayedNull, delayedValue, delayedValue, invokeNext, invokeNextAndExceptionally, invokeNextAndFinally, invokeNextAndHandle, invokeNextThenAccept, invokeNextThenApply, isSuccessfullyDone, makeStage, setNextInterceptor, valueOrException
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.infinispan.persistence.util.EntryLoader
loadAndStoreInDataContainer
-
Methods inherited from interface org.infinispan.commands.Visitor
visitRemoveExpiredCommand
-
-
-
-
Field Detail
-
cacheLoads
protected final AtomicLong cacheLoads
-
cacheMisses
protected final AtomicLong cacheMisses
-
persistenceManager
protected PersistenceManager persistenceManager
-
notifier
protected CacheNotifier notifier
-
entryFactory
protected EntryFactory entryFactory
-
nonBlockingExecutor
protected ExecutorService nonBlockingExecutor
-
activation
protected boolean activation
-
-
Method Detail
-
start
public void start()
-
visitPutKeyValueCommand
public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command)
- Specified by:
visitPutKeyValueCommandin interfaceVisitor- Overrides:
visitPutKeyValueCommandin classDDAsyncInterceptor
-
visitGetKeyValueCommand
public Object visitGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command)
- Specified by:
visitGetKeyValueCommandin interfaceVisitor- Overrides:
visitGetKeyValueCommandin classDDAsyncInterceptor
-
visitGetCacheEntryCommand
public Object visitGetCacheEntryCommand(InvocationContext ctx, GetCacheEntryCommand command)
- Specified by:
visitGetCacheEntryCommandin interfaceVisitor- Overrides:
visitGetCacheEntryCommandin classDDAsyncInterceptor
-
visitGetAllCommand
public Object visitGetAllCommand(InvocationContext ctx, GetAllCommand command)
- Specified by:
visitGetAllCommandin interfaceVisitor- Overrides:
visitGetAllCommandin classDDAsyncInterceptor
-
visitRemoveCommand
public Object visitRemoveCommand(InvocationContext ctx, RemoveCommand command)
- Specified by:
visitRemoveCommandin interfaceVisitor- Overrides:
visitRemoveCommandin classDDAsyncInterceptor
-
visitReplaceCommand
public Object visitReplaceCommand(InvocationContext ctx, ReplaceCommand command)
- Specified by:
visitReplaceCommandin interfaceVisitor- Overrides:
visitReplaceCommandin classDDAsyncInterceptor
-
visitComputeCommand
public Object visitComputeCommand(InvocationContext ctx, ComputeCommand command)
- Specified by:
visitComputeCommandin interfaceVisitor- Overrides:
visitComputeCommandin classDDAsyncInterceptor
-
visitComputeIfAbsentCommand
public Object visitComputeIfAbsentCommand(InvocationContext ctx, ComputeIfAbsentCommand command)
- Specified by:
visitComputeIfAbsentCommandin interfaceVisitor- Overrides:
visitComputeIfAbsentCommandin classDDAsyncInterceptor
-
visitGetKeysInGroupCommand
public Object visitGetKeysInGroupCommand(InvocationContext ctx, GetKeysInGroupCommand command)
- Specified by:
visitGetKeysInGroupCommandin interfaceVisitor- Overrides:
visitGetKeysInGroupCommandin classDDAsyncInterceptor
-
visitEntrySetCommand
public Object visitEntrySetCommand(InvocationContext ctx, EntrySetCommand command) throws Throwable
- Specified by:
visitEntrySetCommandin interfaceVisitor- Overrides:
visitEntrySetCommandin classDDAsyncInterceptor- Throws:
Throwable
-
visitKeySetCommand
public Object visitKeySetCommand(InvocationContext ctx, KeySetCommand command) throws Throwable
- Specified by:
visitKeySetCommandin interfaceVisitor- Overrides:
visitKeySetCommandin classDDAsyncInterceptor- Throws:
Throwable
-
visitReadOnlyKeyCommand
public Object visitReadOnlyKeyCommand(InvocationContext ctx, ReadOnlyKeyCommand command)
- Specified by:
visitReadOnlyKeyCommandin interfaceVisitor- Overrides:
visitReadOnlyKeyCommandin classDDAsyncInterceptor
-
visitReadOnlyManyCommand
public Object visitReadOnlyManyCommand(InvocationContext ctx, ReadOnlyManyCommand command)
- Specified by:
visitReadOnlyManyCommandin interfaceVisitor- Overrides:
visitReadOnlyManyCommandin classDDAsyncInterceptor
-
visitReadWriteKeyCommand
public Object visitReadWriteKeyCommand(InvocationContext ctx, ReadWriteKeyCommand command) throws Throwable
- Specified by:
visitReadWriteKeyCommandin interfaceVisitor- Overrides:
visitReadWriteKeyCommandin classDDAsyncInterceptor- Throws:
Throwable
-
visitReadWriteKeyValueCommand
public Object visitReadWriteKeyValueCommand(InvocationContext ctx, ReadWriteKeyValueCommand command)
- Specified by:
visitReadWriteKeyValueCommandin interfaceVisitor- Overrides:
visitReadWriteKeyValueCommandin classDDAsyncInterceptor
-
visitReadWriteManyCommand
public Object visitReadWriteManyCommand(InvocationContext ctx, ReadWriteManyCommand command)
- Specified by:
visitReadWriteManyCommandin interfaceVisitor- Overrides:
visitReadWriteManyCommandin classDDAsyncInterceptor
-
visitReadWriteManyEntriesCommand
public Object visitReadWriteManyEntriesCommand(InvocationContext ctx, ReadWriteManyEntriesCommand command) throws Throwable
- Specified by:
visitReadWriteManyEntriesCommandin interfaceVisitor- Overrides:
visitReadWriteManyEntriesCommandin classDDAsyncInterceptor- Throws:
Throwable
-
visitSizeCommand
public Object visitSizeCommand(InvocationContext ctx, SizeCommand command)
- Specified by:
visitSizeCommandin interfaceVisitor- Overrides:
visitSizeCommandin classDDAsyncInterceptor
-
isConditional
protected final boolean isConditional(WriteCommand cmd)
-
hasSkipLoadFlag
protected final boolean hasSkipLoadFlag(FlagAffectedCommand cmd)
-
canLoad
protected boolean canLoad(Object key)
-
loadIfNeeded
protected final CompletionStage<Void> loadIfNeeded(InvocationContext ctx, Object key, FlagAffectedCommand cmd)
Loads from the cache loader the entry for the given key. A found value is loaded into the current context. The method returns whether the value was found or not, or even if the cache loader was checked.- Parameters:
ctx- The current invocation's contextkey- The key for the entry to look upcmd- The command that was called that now wants to query the cache loader- Returns:
- null or a CompletionStage that when complete all listeners will be notified
- Throws:
Throwable
-
loadInContext
protected CompletionStage<Void> loadInContext(InvocationContext ctx, Object key, FlagAffectedCommand cmd)
Attemps to load the given entry for a key from the persistence store. This method optimizes concurrent loads of the same key so only the first is actually loaded. The additional loads will in turn complete when the first completes, which provides minimal hits to the backing store(s).- Parameters:
ctx- context for this invocationkey- key to find the entry forcmd- the command that initiated this load- Returns:
- a stage that when complete will have the entry loaded into the provided context
-
loadAndStoreInDataContainer
public CompletionStage<InternalCacheEntry<K,V>> loadAndStoreInDataContainer(InvocationContext ctx, Object key, int segment, FlagAffectedCommand cmd)
Description copied from interface:EntryLoaderLoad and store the entry if present in the data container, returning the entry in the CompletionStage- Specified by:
loadAndStoreInDataContainerin interfaceEntryLoader<K,V>- Parameters:
ctx- context that generated this requestkey- key to load from the storesegment- segment of the key to loadcmd- the command that generated this load request- Returns:
- stage that when complete contains the loaded entry. If the entry is non null the entry is also written into the underlying data container
-
skipLoadForWriteCommand
protected boolean skipLoadForWriteCommand(WriteCommand cmd, Object key, InvocationContext ctx)
-
sendNotification
protected CompletionStage<Void> sendNotification(Object key, Object value, boolean pre, InvocationContext ctx, FlagAffectedCommand cmd)
-
getCacheLoaderLoads
@ManagedAttribute(description="Number of entries loaded from cache store", displayName="Number of cache store loads", measurementType=TRENDSUP) public long getCacheLoaderLoads()
-
getCacheLoaderMisses
@ManagedAttribute(description="Number of entries that did not exist in cache store", displayName="Number of cache store load misses", measurementType=TRENDSUP) public long getCacheLoaderMisses()
-
resetStatistics
public void resetStatistics()
Description copied from class:JmxStatsCommandInterceptorResets statistics gathered. Is a no-op, and should be overridden if it is to be meaningful.- Specified by:
resetStatisticsin interfaceJmxStatisticsExposer- Overrides:
resetStatisticsin classJmxStatsCommandInterceptor
-
getStores
@ManagedAttribute(description="Returns a collection of cache loader types which are configured and enabled", displayName="Returns a collection of cache loader types which are configured and enabled") public Collection<String> getStores()This method returns a collection of cache loader types (fully qualified class names) that are configured and enabled.
-
disableStore
@ManagedOperation(description="Disable all stores of a given type, where type is a fully qualified class name of the cache loader to disable", displayName="Disable all stores of a given type") public void disableStore(@Parameter(name="storeType",description="Fully qualified class name of a store implementation") String storeType)Disables a store of a given type. If the given type cannot be found, this is a no-op. If more than one store of the same type is configured, all stores of the given type are disabled.- Parameters:
storeType- fully qualified class name of the cache loader type to disable
-
-