Class PersistenceManagerStub
- java.lang.Object
-
- org.infinispan.persistence.manager.PersistenceManagerStub
-
- All Implemented Interfaces:
Lifecycle,PersistenceManager
public class PersistenceManagerStub extends Object implements PersistenceManager
- Author:
- Radim Vansa <rvansa@redhat.com>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.infinispan.persistence.manager.PersistenceManager
PersistenceManager.AccessMode
-
-
Constructor Summary
Constructors Constructor Description PersistenceManagerStub()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearAllStores(Predicate<? super StoreConfiguration> predicate)InvokesAdvancedCacheWriter.clear()on all the stores that aloes it.voidcommitAllTxStores(Transaction transaction, Predicate<? super StoreConfiguration> predicate)Perform the commit operation for the provided transaction on all Tx stores.voiddeleteBatchFromAllNonTxStores(Iterable<Object> keys, Predicate<? super StoreConfiguration> predicate, long flags)Remove all entries from the underlying non-transactional stores as a single batch.booleandeleteFromAllStores(Object key, int segment, Predicate<? super StoreConfiguration> predicate)voiddisableStore(String storeType)Marks the given storage as disabled.AdvancedCacheLoadergetStateTransferProvider()Returns the store one configured with fetch persistent state, or null if none exist.<T> Set<T>getStores(Class<T> storeClass)Collection<String>getStoresAsString()booleanisAvailable()booleanisEnabled()booleanisPreloaded()MarshalledEntryloadFromAllStores(Object key, boolean localInvocation, boolean includeStores)Loads an entry from the persistence store for the given key.MarshalledEntryloadFromAllStores(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.voidpreload()Loads the data from the external store into memory during cache startup.voidprepareAllTxStores(Transaction transaction, BatchModification batchModification, Predicate<? super StoreConfiguration> predicate)Perform the prepare phase of 2PC on all Tx stores.<K,V>
org.reactivestreams.Publisher<MarshalledEntry<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<MarshalledEntry<K,V>>publishEntries(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(IntSet segments, Predicate<? super K> filter, Predicate<? super StoreConfiguration> predicate)Returns a publisher that will publish keys that map to the provided segments.voidpurgeExpired()Removes the expired entries from all the existing storage.voidrollbackAllTxStores(Transaction transaction, Predicate<? super StoreConfiguration> predicate)Perform the rollback operation for the provided transaction on all Tx stores.voidsetClearOnStop(boolean clearOnStop)intsize(Predicate<? super StoreConfiguration> predicate)Returns the count of how many entries are persisted.intsize(IntSet segments)Returns the count of how many entries are persisted within the given segments.voidstart()Invoked on component startvoidstop()Invoked on component stopvoidwriteBatchToAllNonTxStores(Iterable<MarshalledEntry> entries, Predicate<? super StoreConfiguration> predicate, long flags)Write all entries to the underlying non-transactional stores as a single batch.voidwriteToAllNonTxStores(MarshalledEntry marshalledEntry, int segment, Predicate<? super StoreConfiguration> predicates)Write to all stores that are not transactional.voidwriteToAllNonTxStores(MarshalledEntry marshalledEntry, int segment, Predicate<? super StoreConfiguration> predicates, long flags)-
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.manager.PersistenceManager
addSegments, publishEntries, removeSegments, size
-
-
-
-
Method Detail
-
start
public void start()
Description copied from interface:LifecycleInvoked on component start
-
stop
public void stop()
Description copied from interface:LifecycleInvoked on component stop
-
isEnabled
public boolean isEnabled()
- Specified by:
isEnabledin interfacePersistenceManager
-
isPreloaded
public boolean isPreloaded()
- Specified by:
isPreloadedin interfacePersistenceManager- Returns:
- true if all entries from the store have been inserted to the cache. If the persistence/preload is disabled or eviction limit was reached when preloading, returns false.
-
preload
public void preload()
Description copied from interface:PersistenceManagerLoads the data from the external store into memory during cache startup.- Specified by:
preloadin interfacePersistenceManager
-
disableStore
public void disableStore(String storeType)
Description copied from interface:PersistenceManagerMarks the given storage as disabled.- Specified by:
disableStorein interfacePersistenceManager
-
getStores
public <T> Set<T> getStores(Class<T> storeClass)
- Specified by:
getStoresin interfacePersistenceManager
-
getStoresAsString
public Collection<String> getStoresAsString()
- Specified by:
getStoresAsStringin interfacePersistenceManager
-
purgeExpired
public void purgeExpired()
Description copied from interface:PersistenceManagerRemoves the expired entries from all the existing storage.- Specified by:
purgeExpiredin interfacePersistenceManager
-
clearAllStores
public void clearAllStores(Predicate<? super StoreConfiguration> predicate)
Description copied from interface:PersistenceManagerInvokesAdvancedCacheWriter.clear()on all the stores that aloes it.- Specified by:
clearAllStoresin interfacePersistenceManager
-
deleteFromAllStores
public boolean deleteFromAllStores(Object key, int segment, Predicate<? super StoreConfiguration> predicate)
- Specified by:
deleteFromAllStoresin interfacePersistenceManager
-
publishEntries
public <K,V> org.reactivestreams.Publisher<MarshalledEntry<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<MarshalledEntry<K,V>> publishEntries(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(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 MarshalledEntry 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
-
loadFromAllStores
public MarshalledEntry 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
-
writeToAllNonTxStores
public void writeToAllNonTxStores(MarshalledEntry marshalledEntry, int segment, Predicate<? super StoreConfiguration> predicates)
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 topredicates- should we write to a given store
- The store implements
-
writeToAllNonTxStores
public void writeToAllNonTxStores(MarshalledEntry marshalledEntry, int segment, Predicate<? super StoreConfiguration> predicates, long flags)
- Specified by:
writeToAllNonTxStoresin interfacePersistenceManagerflags- Flags used during command invocation- See Also:
PersistenceManager.writeToAllNonTxStores(MarshalledEntry, int, Predicate)
-
getStateTransferProvider
public AdvancedCacheLoader getStateTransferProvider()
Description copied from interface:PersistenceManagerReturns the store one configured with fetch persistent state, or null if none exist.- Specified by:
getStateTransferProviderin interfacePersistenceManager
-
size
public int size(Predicate<? super StoreConfiguration> predicate)
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
-
size
public int size(IntSet segments)
Description copied from interface:PersistenceManagerReturns the count of how many entries are persisted within the given segments. The returned value will always be 0 or greater.- Specified by:
sizein interfacePersistenceManager- Parameters:
segments- which segments to count entries from- Returns:
- how many entries are in the store which map to the given segments
-
setClearOnStop
public void setClearOnStop(boolean clearOnStop)
- Specified by:
setClearOnStopin interfacePersistenceManager
-
prepareAllTxStores
public void prepareAllTxStores(Transaction transaction, BatchModification batchModification, 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:
transaction- the current transactional context.batchModification- an object containing the write/remove operations required for this transaction.predicate- should we prepare on a given store- Throws:
PersistenceException- if an error is encountered at any of the underlying stores.
-
commitAllTxStores
public void commitAllTxStores(Transaction transaction, 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:
transaction- the transactional context to be committed.predicate- should we commit each store
-
rollbackAllTxStores
public void rollbackAllTxStores(Transaction transaction, 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:
transaction- the transactional context to be rolledback.predicate- should we rollback each store
-
writeBatchToAllNonTxStores
public void writeBatchToAllNonTxStores(Iterable<MarshalledEntry> entries, Predicate<? super StoreConfiguration> predicate, long flags)
Description copied from interface:PersistenceManagerWrite all entries to the underlying non-transactional stores as a single batch.- Specified by:
writeBatchToAllNonTxStoresin interfacePersistenceManager- Parameters:
entries- a List of MarshalledEntry to be written to the store.predicate- whether a given store should write the entryflags- Flags used during command invocation
-
deleteBatchFromAllNonTxStores
public void deleteBatchFromAllNonTxStores(Iterable<Object> keys, Predicate<? super StoreConfiguration> predicate, long flags)
Description copied from interface:PersistenceManagerRemove all entries from the underlying non-transactional stores as a single batch.- Specified by:
deleteBatchFromAllNonTxStoresin interfacePersistenceManager- Parameters:
keys- a List of Keys to be removed from the store.predicate- whether a given store should delete the entriesflags- Flags used during command invocation
-
isAvailable
public boolean isAvailable()
- Specified by:
isAvailablein interfacePersistenceManager- Returns:
- true if all configured stores are available and ready for read/write operations.
-
-