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,PersistenceManager.StoreChangeListener,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>, PersistenceManager.StoreChangeListener
- Since:
- 9.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected final AtomicLongprotected final AtomicLongprotected EntryFactoryprotected ExecutorServiceprotected CacheNotifierprotected PersistenceManagerFields inherited from class org.infinispan.interceptors.BaseAsyncInterceptor
cacheConfiguration -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanvoiddisableStore(String storeType) Disables a store of a given type.longlongThis method returns a collection of cache loader types (fully qualified class names) that are configured and enabled.protected final booleanprotected final booleanloadAndStoreInDataContainer(InvocationContext ctx, Object key, int segment, FlagAffectedCommand cmd) Load and store the entry if present in the data container, returning the entry in the CompletionStageprotected final CompletionStage<?>loadIfNeeded(InvocationContext ctx, Object key, FlagAffectedCommand cmd) Loads from the cache loader the entry for the given key.protected CompletionStage<?>loadInContext(InvocationContext ctx, Object key, int segment, FlagAffectedCommand cmd) Attemps to load the given entry for a key from the persistence store.voidResets statistics gathered.protected CompletionStage<Void>sendNotification(Object key, Object value, boolean pre, InvocationContext ctx, FlagAffectedCommand cmd) protected booleanskipLoadForWriteCommand(WriteCommand cmd, Object key, InvocationContext ctx) voidstart()voidstoreChanged(PersistenceStatus persistenceStatus) Notifies when a store was added or removed dynamically.visitComputeCommand(InvocationContext ctx, ComputeCommand command) visitEntrySetCommand(InvocationContext ctx, EntrySetCommand command) visitGetAllCommand(InvocationContext ctx, GetAllCommand command) visitGetCacheEntryCommand(InvocationContext ctx, GetCacheEntryCommand command) visitGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) visitKeySetCommand(InvocationContext ctx, KeySetCommand command) visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) visitReadOnlyKeyCommand(InvocationContext ctx, ReadOnlyKeyCommand command) visitReadOnlyManyCommand(InvocationContext ctx, ReadOnlyManyCommand command) visitReadWriteKeyCommand(InvocationContext ctx, ReadWriteKeyCommand command) visitReadWriteManyCommand(InvocationContext ctx, ReadWriteManyCommand command) visitRemoveCommand(InvocationContext ctx, RemoveCommand command) visitReplaceCommand(InvocationContext ctx, ReplaceCommand command) visitSizeCommand(InvocationContext ctx, SizeCommand command) Methods inherited from class org.infinispan.interceptors.impl.JmxStatsCommandInterceptor
getStatisticsEnabled, onStart, setStatisticsEnabledMethods inherited from class org.infinispan.interceptors.DDAsyncInterceptor
handleDefault, visitClearCommand, visitCommand, visitCommitCommand, visitEvictCommand, visitInvalidateCommand, visitInvalidateL1Command, visitLockControlCommand, visitPrepareCommand, visitPutMapCommand, visitRollbackCommand, visitTouchCommand, visitUnknownCommand, visitWriteOnlyKeyCommand, visitWriteOnlyKeyValueCommand, visitWriteOnlyManyCommand, visitWriteOnlyManyEntriesCommandMethods inherited from class org.infinispan.interceptors.BaseAsyncInterceptor
asyncInvokeNext, asyncInvokeNext, asyncInvokeNext, asyncValue, delayedNull, delayedValue, delayedValue, invokeNext, invokeNextAndExceptionally, invokeNextAndFinally, invokeNextAndHandle, invokeNextThenAccept, invokeNextThenApply, isSuccessfullyDone, makeStage, setNextInterceptor, valueOrExceptionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.infinispan.persistence.util.EntryLoader
loadAndStoreInDataContainerMethods inherited from interface org.infinispan.commands.Visitor
visitRemoveExpiredCommand
-
Field Details
-
cacheLoads
-
cacheMisses
-
persistenceManager
-
notifier
-
entryFactory
-
nonBlockingExecutor
-
activation
protected boolean activation
-
-
Constructor Details
-
CacheLoaderInterceptor
public CacheLoaderInterceptor()
-
-
Method Details
-
start
public void start() -
storeChanged
Description copied from interface:PersistenceManager.StoreChangeListenerNotifies when a store was added or removed dynamically. This method is always invoked with mutual access to any other method inPersistenceManager. Implementations must only ensure visibility or atomicity of their own variables and operations.- Specified by:
storeChangedin interfacePersistenceManager.StoreChangeListener
-
visitPutKeyValueCommand
- Specified by:
visitPutKeyValueCommandin interfaceVisitor- Overrides:
visitPutKeyValueCommandin classDDAsyncInterceptor
-
visitIracPutKeyValueCommand
- Specified by:
visitIracPutKeyValueCommandin interfaceVisitor- Overrides:
visitIracPutKeyValueCommandin classDDAsyncInterceptor
-
visitGetKeyValueCommand
- Specified by:
visitGetKeyValueCommandin interfaceVisitor- Overrides:
visitGetKeyValueCommandin classDDAsyncInterceptor
-
visitGetCacheEntryCommand
- Specified by:
visitGetCacheEntryCommandin interfaceVisitor- Overrides:
visitGetCacheEntryCommandin classDDAsyncInterceptor
-
visitGetAllCommand
- Specified by:
visitGetAllCommandin interfaceVisitor- Overrides:
visitGetAllCommandin classDDAsyncInterceptor
-
visitRemoveCommand
- Specified by:
visitRemoveCommandin interfaceVisitor- Overrides:
visitRemoveCommandin classDDAsyncInterceptor
-
visitReplaceCommand
- Specified by:
visitReplaceCommandin interfaceVisitor- Overrides:
visitReplaceCommandin classDDAsyncInterceptor
-
visitComputeCommand
- Specified by:
visitComputeCommandin interfaceVisitor- Overrides:
visitComputeCommandin classDDAsyncInterceptor
-
visitComputeIfAbsentCommand
- Specified by:
visitComputeIfAbsentCommandin interfaceVisitor- Overrides:
visitComputeIfAbsentCommandin classDDAsyncInterceptor
-
visitEntrySetCommand
- Specified by:
visitEntrySetCommandin interfaceVisitor- Overrides:
visitEntrySetCommandin classDDAsyncInterceptor- Throws:
Throwable
-
visitKeySetCommand
- Specified by:
visitKeySetCommandin interfaceVisitor- Overrides:
visitKeySetCommandin classDDAsyncInterceptor- Throws:
Throwable
-
visitReadOnlyKeyCommand
- Specified by:
visitReadOnlyKeyCommandin interfaceVisitor- Overrides:
visitReadOnlyKeyCommandin classDDAsyncInterceptor
-
visitReadOnlyManyCommand
- 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
- 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
- Specified by:
visitSizeCommandin interfaceVisitor- Overrides:
visitSizeCommandin classDDAsyncInterceptor
-
isConditional
-
hasSkipLoadFlag
-
canLoad
-
loadIfNeeded
protected final CompletionStage<?> 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<?> loadInContext(InvocationContext ctx, Object key, int segment, 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 forsegment- the segment of the keycmd- 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
-
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
-