Class DelegatingPersistenceManager
- All Implemented Interfaces:
org.infinispan.commons.api.Lifecycle,PersistenceManager
- Direct Known Subclasses:
PassivationPersistenceManager,TracedPersistenceManager
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.infinispan.persistence.manager.PersistenceManager
PersistenceManager.AccessMode, PersistenceManager.StoreChangeListener -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddSegments(org.infinispan.commons.util.IntSet segments) Notifies any underlying segmented stores that the segments provided are owned by this cache and to start/configure any underlying resources required to handle requests for entries on the given segments.addStore(StoreConfiguration persistenceConfiguration) Adds a new store to the cache.voidAdd aPersistenceManager.StoreChangeListenerto be notified when a store is added or removed dynamically.approximateSize(Predicate<? super StoreConfiguration> predicate, org.infinispan.commons.util.IntSet segments) Returns an approximate count of how many entries are persisted in the given segments.clearAllStores(Predicate<? super StoreConfiguration> predicate) InvokesAdvancedCacheWriter.clear()on all the stores that aloes it.commitAllTxStores(TxInvocationContext<AbstractCacheTransaction> txInvocationContext, Predicate<? super StoreConfiguration> predicate) Perform the commit operation for the provided transaction on all Tx stores.deleteFromAllStores(Object key, int segment, Predicate<? super StoreConfiguration> predicate) disableStore(String storeType) Marks the given storage as disabled.<T> Set<T> booleanhasStore(Predicate<StoreConfiguration> test) booleanReturns whether the manager is enabled and has at least one storebooleanbooleanboolean<K,V> CompletionStage <MarshallableEntry<K, V>> loadFromAllStores(Object key, boolean localInvocation, boolean includeStores) Loads an entry from the persistence store for the given key.<K,V> CompletionStage <MarshallableEntry<K, V>> loadFromAllStores(Object key, int segment, boolean localInvocation, boolean includeStores) Same asPersistenceManager.loadFromAllStores(Object, boolean, boolean)except that the segment of the key is also provided to avoid having to calculate the segment.performBatch(TxInvocationContext<AbstractCacheTransaction> invocationContext, TriPredicate<? super WriteCommand, Object, MVCCEntry<?, ?>> commandKeyPredicate) Writes a batch for the given modifications in the transactional contextio.reactivex.rxjava3.core.Flowable<MarshallableEntry<Object, Object>> Loads the data from the external store into memory during cache startup.prepareAllTxStores(TxInvocationContext<AbstractCacheTransaction> txInvocationContext, Predicate<? super StoreConfiguration> predicate) Perform the prepare phase of 2PC on all Tx stores.<K,V> org.reactivestreams.Publisher <MarshallableEntry<K, V>> publishEntries(boolean fetchValue, boolean fetchMetadata) <K,V> org.reactivestreams.Publisher <MarshallableEntry<K, V>> publishEntries(Predicate<? super K> filter, boolean fetchValue, boolean fetchMetadata, Predicate<? super StoreConfiguration> predicate) Returns a publisher that will publish all entries stored by the underlying cache store.<K,V> org.reactivestreams.Publisher <MarshallableEntry<K, V>> publishEntries(org.infinispan.commons.util.IntSet segments, Predicate<? super K> filter, boolean fetchValue, boolean fetchMetadata, Predicate<? super StoreConfiguration> predicate) Returns a publisher that will publish entries that map to the provided segments.<K> org.reactivestreams.Publisher<K> publishKeys(Predicate<? super K> filter, Predicate<? super StoreConfiguration> predicate) Returns a publisher that will publish all keys stored by the underlying cache store.<K> org.reactivestreams.Publisher<K> publishKeys(org.infinispan.commons.util.IntSet segments, Predicate<? super K> filter, Predicate<? super StoreConfiguration> predicate) Returns a publisher that will publish keys that map to the provided segments.Removes the expired entries from all the existing storage.removeSegments(org.infinispan.commons.util.IntSet segments) Notifies any underlying segmented stores that a given segment is no longer owned by this cache and allowing it to remove the given segments and release resources related to it.voidRemote a registeredPersistenceManager.StoreChangeListenerrollbackAllTxStores(TxInvocationContext<AbstractCacheTransaction> txInvocationContext, Predicate<? super StoreConfiguration> predicate) Perform the rollback operation for the provided transaction on all Tx stores.voidsetClearOnStop(boolean clearOnStop) size()size(Predicate<? super StoreConfiguration> predicate) Returns the count of how many entries are persisted.size(Predicate<? super StoreConfiguration> predicate, org.infinispan.commons.util.IntSet segments) Returns the count of how many entries are persisted in the given segments.voidstart()voidstop()<K,V> CompletionStage <Void> writeEntries(Iterable<MarshallableEntry<K, V>> iterable, Predicate<? super StoreConfiguration> predicate) Writes the entries to the stores that pass the given predicatewriteMapCommand(PutMapCommand putMapCommand, InvocationContext ctx, BiPredicate<? super PutMapCommand, Object> commandKeyPredicate) Writes the values modified from a put map command to the stores.writeToAllNonTxStores(MarshallableEntry marshalledEntry, int segment, Predicate<? super StoreConfiguration> predicate) Write to all stores that are not transactional.writeToAllNonTxStores(MarshallableEntry marshalledEntry, int segment, Predicate<? super StoreConfiguration> predicate, long flags) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.infinispan.persistence.manager.PersistenceManager
size
-
Field Details
-
persistenceManager
-
-
Constructor Details
-
DelegatingPersistenceManager
-
-
Method Details
-
start
public void start()- Specified by:
startin interfaceorg.infinispan.commons.api.Lifecycle
-
stop
public void stop()- Specified by:
stopin interfaceorg.infinispan.commons.api.Lifecycle
-
getActual
-
isEnabled
public boolean isEnabled()- Specified by:
isEnabledin interfacePersistenceManager
-
hasWriter
public boolean hasWriter()Description copied from interface:PersistenceManagerReturns whether the manager is enabled and has at least one store- Specified by:
hasWriterin interfacePersistenceManager
-
hasStore
- Specified by:
hasStorein interfacePersistenceManager
-
preloadPublisher
Description copied from interface:PersistenceManagerLoads the data from the external store into memory during cache startup.- Specified by:
preloadPublisherin interfacePersistenceManager
-
disableStore
Description copied from interface:PersistenceManagerMarks the given storage as disabled.- Specified by:
disableStorein interfacePersistenceManager
-
addStore
Description copied from interface:PersistenceManagerAdds a new store to the cache.- Specified by:
addStorein interfacePersistenceManager- Parameters:
persistenceConfiguration- the configuration for the store
-
addStoreListener
Description copied from interface:PersistenceManagerAdd aPersistenceManager.StoreChangeListenerto be notified when a store is added or removed dynamically.- Specified by:
addStoreListenerin interfacePersistenceManager
-
removeStoreListener
Description copied from interface:PersistenceManagerRemote a registeredPersistenceManager.StoreChangeListener- Specified by:
removeStoreListenerin interfacePersistenceManager
-
getStores
- Specified by:
getStoresin interfacePersistenceManager
-
getStoresAsString
- Specified by:
getStoresAsStringin interfacePersistenceManager
-
purgeExpired
Description copied from interface:PersistenceManagerRemoves the expired entries from all the existing storage.- Specified by:
purgeExpiredin interfacePersistenceManager
-
clearAllStores
Description copied from interface:PersistenceManagerInvokesAdvancedCacheWriter.clear()on all the stores that aloes it.- Specified by:
clearAllStoresin interfacePersistenceManager
-
deleteFromAllStores
public CompletionStage<Boolean> deleteFromAllStores(Object key, int segment, Predicate<? super StoreConfiguration> predicate) - Specified by:
deleteFromAllStoresin interfacePersistenceManager
-
publishEntries
public <K,V> org.reactivestreams.Publisher<MarshallableEntry<K,V>> publishEntries(Predicate<? super K> filter, boolean fetchValue, boolean fetchMetadata, Predicate<? super StoreConfiguration> predicate) Description copied from interface:PersistenceManagerReturns a publisher that will publish all entries stored by the underlying cache store. Only the first cache store that implementsAdvancedCacheLoaderwill be used. Predicate is applied by the underlying loader in a best attempt to improve performance.Caller can tell the store to also fetch the value or metadata. In some cases this can improve performance. If metadata is not fetched the publisher may include expired entries.
- Specified by:
publishEntriesin interfacePersistenceManager- Type Parameters:
K- key typeV- value type- Parameters:
filter- filter so that only entries whose key matches are returnedfetchValue- whether to fetch value or notfetchMetadata- whether to fetch metadata or notpredicate- whether a store can be used by publish entries- Returns:
- publisher that will publish entries
-
publishEntries
public <K,V> org.reactivestreams.Publisher<MarshallableEntry<K,V>> publishEntries(org.infinispan.commons.util.IntSet segments, Predicate<? super K> filter, boolean fetchValue, boolean fetchMetadata, Predicate<? super StoreConfiguration> predicate) Description copied from interface:PersistenceManagerReturns a publisher that will publish entries that map to the provided segments. It will attempt to find the first segmented store if one is available. If not it will fall back to the first non segmented store and filter out entries that don't map to the provided segment.- Specified by:
publishEntriesin interfacePersistenceManager- Type Parameters:
K- key typeV- value type- Parameters:
segments- only entries that map to these segments are processedfilter- filter so that only entries whose key matches are returnedfetchValue- whether to fetch value or notfetchMetadata- whether to fetch metadata or notpredicate- whether a store can be used by publish entries- Returns:
- publisher that will publish entries belonging to the given segments
-
publishKeys
public <K> org.reactivestreams.Publisher<K> publishKeys(Predicate<? super K> filter, Predicate<? super StoreConfiguration> predicate) Description copied from interface:PersistenceManagerReturns a publisher that will publish all keys stored by the underlying cache store. Only the first cache store that implementsAdvancedCacheLoaderwill be used. Predicate is applied by the underlying loader in a best attempt to improve performance.This method should be preferred over
PersistenceManager.publishEntries(Predicate, boolean, boolean, Predicate)when only keys are desired as many stores can do this in a significantly more performant way.This publisher will never return a key which belongs to an expired entry
- Specified by:
publishKeysin interfacePersistenceManager- Type Parameters:
K- key type- Parameters:
filter- filter so that only keys which match are returnedpredicate- access mode to choose what type of loader to use- Returns:
- publisher that will publish keys
-
publishKeys
public <K> org.reactivestreams.Publisher<K> publishKeys(org.infinispan.commons.util.IntSet segments, Predicate<? super K> filter, Predicate<? super StoreConfiguration> predicate) Description copied from interface:PersistenceManagerReturns a publisher that will publish keys that map to the provided segments. It will attempt to find the first segmented store if one is available. If not it will fall back to the first non segmented store and filter out entries that don't map to the provided segment.This method should be preferred over
PersistenceManager.publishEntries(IntSet, Predicate, boolean, boolean, Predicate)when only keys are desired as many stores can do this in a significantly more performant way.This publisher will never return a key which belongs to an expired entry
- Specified by:
publishKeysin interfacePersistenceManager- Type Parameters:
K- key type- Parameters:
segments- only keys that map to these segments are processedfilter- filter so that only keys which match are returnedpredicate- access mode to choose what type of loader to use- Returns:
- publisher that will publish keys belonging to the given segments
-
loadFromAllStores
public <K,V> CompletionStage<MarshallableEntry<K,V>> loadFromAllStores(Object key, boolean localInvocation, boolean includeStores) Description copied from interface:PersistenceManagerLoads an entry from the persistence store for the given key. The returned value may be null. This value is guaranteed to not be expired when it was returned.- Specified by:
loadFromAllStoresin interfacePersistenceManager- Parameters:
key- key to read the entry fromlocalInvocation- whether this invocation is a local invocation. Some loaders may be ignored if it is not localincludeStores- if a loader that is also a store can be loaded from- Returns:
- entry that maps to the key
-
size
Description copied from interface:PersistenceManagerReturns the count of how many entries are persisted. If no store can handle the request for the given mode a value of -1 is returned instead.- Specified by:
sizein interfacePersistenceManager- Parameters:
predicate- whether a loader can be used- Returns:
- size or -1 if size couldn't be computed
-
setClearOnStop
public void setClearOnStop(boolean clearOnStop) - Specified by:
setClearOnStopin interfacePersistenceManager
-
writeToAllNonTxStores
public CompletionStage<Void> writeToAllNonTxStores(MarshallableEntry marshalledEntry, int segment, Predicate<? super StoreConfiguration> predicate, long flags) - Specified by:
writeToAllNonTxStoresin interfacePersistenceManager- Parameters:
flags- Flags used during command invocation- See Also:
-
prepareAllTxStores
public CompletionStage<Void> prepareAllTxStores(TxInvocationContext<AbstractCacheTransaction> txInvocationContext, Predicate<? super StoreConfiguration> predicate) throws PersistenceException Description copied from interface:PersistenceManagerPerform the prepare phase of 2PC on all Tx stores.- Specified by:
prepareAllTxStoresin interfacePersistenceManager- Parameters:
txInvocationContext- the tx invocation containing the modificationspredicate- should we prepare on a given store- Throws:
PersistenceException- if an error is encountered at any of the underlying stores.
-
commitAllTxStores
public CompletionStage<Void> commitAllTxStores(TxInvocationContext<AbstractCacheTransaction> txInvocationContext, Predicate<? super StoreConfiguration> predicate) Description copied from interface:PersistenceManagerPerform the commit operation for the provided transaction on all Tx stores.- Specified by:
commitAllTxStoresin interfacePersistenceManager- Parameters:
txInvocationContext- the transactional context to be committed.predicate- should we commit each store
-
rollbackAllTxStores
public CompletionStage<Void> rollbackAllTxStores(TxInvocationContext<AbstractCacheTransaction> txInvocationContext, Predicate<? super StoreConfiguration> predicate) Description copied from interface:PersistenceManagerPerform the rollback operation for the provided transaction on all Tx stores.- Specified by:
rollbackAllTxStoresin interfacePersistenceManager- Parameters:
txInvocationContext- the transactional context to be rolledback.predicate- should we rollback each store
-
writeMapCommand
public CompletionStage<Long> writeMapCommand(PutMapCommand putMapCommand, InvocationContext ctx, BiPredicate<? super PutMapCommand, Object> commandKeyPredicate) Description copied from interface:PersistenceManagerWrites the values modified from a put map command to the stores.- Specified by:
writeMapCommandin interfacePersistenceManager- Parameters:
putMapCommand- the put map command to write values fromctx- context to lookup entriescommandKeyPredicate- predicate to control if a key/command combination should be accepted- Returns:
- a stage of how many writes were performed
-
writeEntries
public <K,V> CompletionStage<Void> writeEntries(Iterable<MarshallableEntry<K, V>> iterable, Predicate<? super StoreConfiguration> predicate) Description copied from interface:PersistenceManagerWrites the entries to the stores that pass the given predicate- Specified by:
writeEntriesin interfacePersistenceManager- Type Parameters:
K- key typeV- value type- Parameters:
iterable- entries to writepredicate- predicate to test for a store- Returns:
- a stage that when complete the values were written
-
performBatch
public CompletionStage<Long> performBatch(TxInvocationContext<AbstractCacheTransaction> invocationContext, TriPredicate<? super WriteCommand, Object, MVCCEntry<?, ?>> commandKeyPredicate) Description copied from interface:PersistenceManagerWrites a batch for the given modifications in the transactional context- Specified by:
performBatchin interfacePersistenceManager- Parameters:
invocationContext- transactional contextcommandKeyPredicate- predicate to control if a key/value/command combination should be accepted- Returns:
- a stage of how many writes were performed
-
isAvailable
public boolean isAvailable()- Specified by:
isAvailablein interfacePersistenceManager- Returns:
- true if all configured stores are available and ready for read/write operations.
-
isReadOnly
public boolean isReadOnly()- Specified by:
isReadOnlyin interfacePersistenceManager- Returns:
- true if no
CacheWriterinstances have been configured.
-
publishEntries
public <K,V> org.reactivestreams.Publisher<MarshallableEntry<K,V>> publishEntries(boolean fetchValue, boolean fetchMetadata) Description copied from interface:PersistenceManager- Specified by:
publishEntriesin interfacePersistenceManager
-
loadFromAllStores
public <K,V> CompletionStage<MarshallableEntry<K,V>> loadFromAllStores(Object key, int segment, boolean localInvocation, boolean includeStores) Description copied from interface:PersistenceManagerSame asPersistenceManager.loadFromAllStores(Object, boolean, boolean)except that the segment of the key is also provided to avoid having to calculate the segment.- Specified by:
loadFromAllStoresin interfacePersistenceManager- Parameters:
key- key to read the entry fromsegment- segment the key maps tolocalInvocation- whether this invocation is a local invocation. Some loaders may be ignored if it is not localincludeStores- if a loader that is also a store can be loaded from- Returns:
- entry that maps to the key
-
approximateSize
public CompletionStage<Long> approximateSize(Predicate<? super StoreConfiguration> predicate, org.infinispan.commons.util.IntSet segments) Description copied from interface:PersistenceManagerReturns an approximate count of how many entries are persisted in the given segments. If no store can handle the request for the given mode, a value of -1 is returned instead.- Specified by:
approximateSizein interfacePersistenceManager- Parameters:
predicate- whether a loader can be usedsegments- the segments to include- Returns:
- size or -1 if approximate size couldn't be computed
-
size
- Specified by:
sizein interfacePersistenceManager
-
size
public CompletionStage<Long> size(Predicate<? super StoreConfiguration> predicate, org.infinispan.commons.util.IntSet segments) Description copied from interface:PersistenceManagerReturns the count of how many entries are persisted in the given segments. If no store can handle the request for the given mode a value of -1 is returned instead.- Specified by:
sizein interfacePersistenceManager- Parameters:
predicate- whether a loader can be usedsegments- segments to check- Returns:
- size or -1 if size couldn't be computed
-
writeToAllNonTxStores
public CompletionStage<Void> writeToAllNonTxStores(MarshallableEntry marshalledEntry, int segment, Predicate<? super StoreConfiguration> predicate) Description copied from interface:PersistenceManagerWrite to all stores that are not transactional. A store is considered transactional if all of the following are true:- The store implements
TransactionalCacheWriter - The store is configured to be transactional
- The cache's TransactionMode === TRANSACTIONAL
- Specified by:
writeToAllNonTxStoresin interfacePersistenceManager- Parameters:
marshalledEntry- the entry to be written to all non-tx stores.segment- the segment the entry maps topredicate- should we write to a given store
- The store implements
-
addSegments
Description copied from interface:PersistenceManagerNotifies any underlying segmented stores that the segments provided are owned by this cache and to start/configure any underlying resources required to handle requests for entries on the given segments.This only affects stores that are not shared as shared stores have to keep all segments running at all times
This method returns true if all stores were able to handle the added segments. That is that either there are no stores or that all the configured stores are segmented. Note that configured loaders do not affect the return value.
- Specified by:
addSegmentsin interfacePersistenceManager- Parameters:
segments- segments this cache owns- Returns:
- false if a configured store couldn't configure newly added segments
-
removeSegments
Description copied from interface:PersistenceManagerNotifies any underlying segmented stores that a given segment is no longer owned by this cache and allowing it to remove the given segments and release resources related to it.This only affects stores that are not shared as shared stores have to keep all segments running at all times
This method returns true if all stores were able to handle the removed segments. That is that either there are no stores or that all the configured stores are segmented. Note that configured loaders do not affect the return value.
- Specified by:
removeSegmentsin interfacePersistenceManager- Parameters:
segments- segments this cache no longer owns- Returns:
- false if a configured store couldn't remove configured segments
-