Class PersistenceManagerStub
- java.lang.Object
-
- org.infinispan.persistence.manager.PersistenceManagerStub
-
- All Implemented Interfaces:
org.infinispan.commons.api.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 void
clearAllStores(PersistenceManager.AccessMode mode)
InvokesAdvancedCacheWriter.clear()
on all the stores that aloes it.void
commitAllTxStores(Transaction transaction, PersistenceManager.AccessMode accessMode)
Perform the commit operation for the provided transaction on all Tx stores.void
deleteBatchFromAllNonTxStores(Iterable<Object> keys, PersistenceManager.AccessMode accessMode, long flags)
Remove all entries from the underlying non-transactional stores as a single batch.boolean
deleteFromAllStores(Object key, PersistenceManager.AccessMode mode)
void
disableStore(String storeType)
Marks the given storage as disabled.AdvancedCacheLoader
getStateTransferProvider()
Returns the store one configured with fetch persistent state, or null if none exist.<T> Set<T>
getStores(Class<T> storeClass)
Collection<String>
getStoresAsString()
boolean
isAvailable()
boolean
isEnabled()
boolean
isPreloaded()
MarshalledEntry
loadFromAllStores(Object key, boolean localContext, boolean includeStores)
Loads an entry from the persistence store for the given key.void
preload()
Loads the data from the external store into memory during cache startup.void
prepareAllTxStores(Transaction transaction, BatchModification batchModification, PersistenceManager.AccessMode accessMode)
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, PersistenceManager.AccessMode mode)
Returns a publisher that will publish all entries stored by the underlying cache store.<K> org.reactivestreams.Publisher<K>
publishKeys(Predicate<? super K> filter, PersistenceManager.AccessMode mode)
Returns a publisher that will publish all keys stored by the underlying cache store.void
purgeExpired()
Removes the expired entries from all the existing storage.void
rollbackAllTxStores(Transaction transaction, PersistenceManager.AccessMode accessMode)
Perform the rollback operation for the provided transaction on all Tx stores.void
setClearOnStop(boolean clearOnStop)
int
size()
void
start()
void
stop()
void
writeBatchToAllNonTxStores(Iterable<MarshalledEntry> entries, PersistenceManager.AccessMode accessMode, long flags)
Write all entries to the underlying non-transactional stores as a single batch.void
writeToAllNonTxStores(MarshalledEntry marshalledEntry, PersistenceManager.AccessMode modes)
Write to all stores that are not transactional.void
writeToAllNonTxStores(MarshalledEntry marshalledEntry, PersistenceManager.AccessMode modes, 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
publishEntries
-
-
-
-
Method Detail
-
start
public void start()
- Specified by:
start
in interfaceorg.infinispan.commons.api.Lifecycle
-
stop
public void stop()
- Specified by:
stop
in interfaceorg.infinispan.commons.api.Lifecycle
-
isEnabled
public boolean isEnabled()
- Specified by:
isEnabled
in interfacePersistenceManager
-
isPreloaded
public boolean isPreloaded()
- Specified by:
isPreloaded
in 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:PersistenceManager
Loads the data from the external store into memory during cache startup.- Specified by:
preload
in interfacePersistenceManager
-
disableStore
public void disableStore(String storeType)
Description copied from interface:PersistenceManager
Marks the given storage as disabled.- Specified by:
disableStore
in interfacePersistenceManager
-
getStores
public <T> Set<T> getStores(Class<T> storeClass)
- Specified by:
getStores
in interfacePersistenceManager
-
getStoresAsString
public Collection<String> getStoresAsString()
- Specified by:
getStoresAsString
in interfacePersistenceManager
-
purgeExpired
public void purgeExpired()
Description copied from interface:PersistenceManager
Removes the expired entries from all the existing storage.- Specified by:
purgeExpired
in interfacePersistenceManager
-
clearAllStores
public void clearAllStores(PersistenceManager.AccessMode mode)
Description copied from interface:PersistenceManager
InvokesAdvancedCacheWriter.clear()
on all the stores that aloes it.- Specified by:
clearAllStores
in interfacePersistenceManager
-
deleteFromAllStores
public boolean deleteFromAllStores(Object key, PersistenceManager.AccessMode mode)
- Specified by:
deleteFromAllStores
in interfacePersistenceManager
-
publishEntries
public <K,V> org.reactivestreams.Publisher<MarshalledEntry<K,V>> publishEntries(Predicate<? super K> filter, boolean fetchValue, boolean fetchMetadata, PersistenceManager.AccessMode mode)
Description copied from interface:PersistenceManager
Returns a publisher that will publish all entries stored by the underlying cache store. Only the first cache store that implementsAdvancedCacheLoader
will 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:
publishEntries
in 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 notmode
- access mode to choose what type of loader to use- Returns:
- publisher that will publish entries
-
publishKeys
public <K> org.reactivestreams.Publisher<K> publishKeys(Predicate<? super K> filter, PersistenceManager.AccessMode mode)
Description copied from interface:PersistenceManager
Returns a publisher that will publish all keys stored by the underlying cache store. Only the first cache store that implementsAdvancedCacheLoader
will 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, AccessMode)
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:
publishKeys
in interfacePersistenceManager
- Type Parameters:
K
- key type- Parameters:
filter
- filter so that only keys which match are returnedmode
- access mode to choose what type of loader to use- Returns:
- publisher that will publish keys
-
loadFromAllStores
public MarshalledEntry loadFromAllStores(Object key, boolean localContext, boolean includeStores)
Description copied from interface:PersistenceManager
Loads 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:
loadFromAllStores
in interfacePersistenceManager
- Parameters:
key
- key to read the entry fromlocalContext
- 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, PersistenceManager.AccessMode modes)
Description copied from interface:PersistenceManager
Write 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:
writeToAllNonTxStores
in interfacePersistenceManager
- Parameters:
marshalledEntry
- the entry to be written to all non-tx stores.modes
- the type of access to the underlying store.
- The store implements
-
writeToAllNonTxStores
public void writeToAllNonTxStores(MarshalledEntry marshalledEntry, PersistenceManager.AccessMode modes, long flags)
- Specified by:
writeToAllNonTxStores
in interfacePersistenceManager
flags
- Flags used during command invocation- See Also:
PersistenceManager.writeToAllNonTxStores(MarshalledEntry, AccessMode)
-
getStateTransferProvider
public AdvancedCacheLoader getStateTransferProvider()
Description copied from interface:PersistenceManager
Returns the store one configured with fetch persistent state, or null if none exist.- Specified by:
getStateTransferProvider
in interfacePersistenceManager
-
size
public int size()
- Specified by:
size
in interfacePersistenceManager
-
setClearOnStop
public void setClearOnStop(boolean clearOnStop)
- Specified by:
setClearOnStop
in interfacePersistenceManager
-
prepareAllTxStores
public void prepareAllTxStores(Transaction transaction, BatchModification batchModification, PersistenceManager.AccessMode accessMode) throws PersistenceException
Description copied from interface:PersistenceManager
Perform the prepare phase of 2PC on all Tx stores.- Specified by:
prepareAllTxStores
in interfacePersistenceManager
- Parameters:
transaction
- the current transactional context.batchModification
- an object containing the write/remove operations required for this transaction.accessMode
- the type of access to the underlying store.- Throws:
PersistenceException
- if an error is encountered at any of the underlying stores.
-
commitAllTxStores
public void commitAllTxStores(Transaction transaction, PersistenceManager.AccessMode accessMode)
Description copied from interface:PersistenceManager
Perform the commit operation for the provided transaction on all Tx stores.- Specified by:
commitAllTxStores
in interfacePersistenceManager
- Parameters:
transaction
- the transactional context to be committed.accessMode
- the type of access to the underlying store.
-
rollbackAllTxStores
public void rollbackAllTxStores(Transaction transaction, PersistenceManager.AccessMode accessMode)
Description copied from interface:PersistenceManager
Perform the rollback operation for the provided transaction on all Tx stores.- Specified by:
rollbackAllTxStores
in interfacePersistenceManager
- Parameters:
transaction
- the transactional context to be rolledback.accessMode
- the type of access to the underlying store.
-
writeBatchToAllNonTxStores
public void writeBatchToAllNonTxStores(Iterable<MarshalledEntry> entries, PersistenceManager.AccessMode accessMode, long flags)
Description copied from interface:PersistenceManager
Write all entries to the underlying non-transactional stores as a single batch.- Specified by:
writeBatchToAllNonTxStores
in interfacePersistenceManager
- Parameters:
entries
- a List of MarshalledEntry to be written to the store.accessMode
- the type of access to the underlying store.flags
- Flags used during command invocation
-
deleteBatchFromAllNonTxStores
public void deleteBatchFromAllNonTxStores(Iterable<Object> keys, PersistenceManager.AccessMode accessMode, long flags)
Description copied from interface:PersistenceManager
Remove all entries from the underlying non-transactional stores as a single batch.- Specified by:
deleteBatchFromAllNonTxStores
in interfacePersistenceManager
accessMode
- the type of access to the underlying store.flags
- Flags used during command invocation
-
isAvailable
public boolean isAvailable()
- Specified by:
isAvailable
in interfacePersistenceManager
- Returns:
- true if all configured stores are available and ready for read/write operations.
-
-