public class DelegatingPersistenceManager extends Object implements PersistenceManager, Lifecycle
PersistenceManager.AccessMode
Modifier and Type | Field and Description |
---|---|
protected ComponentRegistry |
componentRegistry |
protected PersistenceManager |
persistenceManager |
Constructor and Description |
---|
DelegatingPersistenceManager(PersistenceManager persistenceManager) |
Modifier and Type | Method and Description |
---|---|
CompletionStage<Boolean> |
addSegments(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.
|
CompletionStage<Void> |
clearAllStores(Predicate<? super StoreConfiguration> predicate)
Invokes
AdvancedCacheWriter.clear() on all the stores that aloes it. |
CompletionStage<Void> |
commitAllTxStores(TxInvocationContext<AbstractCacheTransaction> txInvocationContext,
Predicate<? super StoreConfiguration> predicate)
Perform the commit operation for the provided transaction on all Tx stores.
|
CompletionStage<Boolean> |
deleteFromAllStores(Object key,
int segment,
Predicate<? super StoreConfiguration> predicate) |
CompletionStage<Void> |
disableStore(String storeType)
Marks the given storage as disabled.
|
PersistenceManager |
getActual() |
<T> Set<T> |
getStores(Class<T> storeClass) |
Collection<String> |
getStoresAsString() |
boolean |
hasWriter()
Returns whether the manager is enabled and has at least one store
|
boolean |
isAvailable() |
boolean |
isEnabled() |
boolean |
isPreloaded() |
boolean |
isReadOnly() |
<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 as
PersistenceManager.loadFromAllStores(Object, boolean, boolean) except that the segment of the key is also
provided to avoid having to calculate the segment. |
CompletionStage<Long> |
performBatch(TxInvocationContext<AbstractCacheTransaction> invocationContext,
BiPredicate<? super WriteCommand,Object> commandKeyPredicate)
Writes a batch for the given modifications in the transactional context
|
CompletionStage<Void> |
preload()
Loads the data from the external store into memory during cache startup.
|
CompletionStage<Void> |
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(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,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> 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.
|
<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.
|
CompletionStage<Void> |
purgeExpired()
Removes the expired entries from all the existing storage.
|
CompletionStage<Boolean> |
removeSegments(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.
|
CompletionStage<Void> |
rollbackAllTxStores(TxInvocationContext<AbstractCacheTransaction> txInvocationContext,
Predicate<? super StoreConfiguration> predicate)
Perform the rollback operation for the provided transaction on all Tx stores.
|
void |
setClearOnStop(boolean clearOnStop) |
CompletionStage<Long> |
size() |
CompletionStage<Long> |
size(IntSet segments)
Returns the count of how many entries are persisted within the given segments.
|
CompletionStage<Long> |
size(Predicate<? super StoreConfiguration> predicate)
Returns the count of how many entries are persisted.
|
void |
start()
Invoked on component start
|
void |
stop()
Invoked on component stop
|
<K,V> CompletionStage<Void> |
writeEntries(Iterable<MarshallableEntry<K,V>> iterable,
Predicate<? super StoreConfiguration> predicate)
Writes the entries to the stores that pass the given predicate
|
CompletionStage<Long> |
writeMapCommand(PutMapCommand putMapCommand,
InvocationContext ctx,
BiPredicate<? super PutMapCommand,Object> commandKeyPredicate)
Writes the values modified from a put map command to the stores.
|
CompletionStage<Void> |
writeToAllNonTxStores(MarshallableEntry marshalledEntry,
int segment,
Predicate<? super StoreConfiguration> predicate)
Write to all stores that are not transactional.
|
CompletionStage<Void> |
writeToAllNonTxStores(MarshallableEntry marshalledEntry,
int segment,
Predicate<? super StoreConfiguration> predicate,
long flags) |
protected final PersistenceManager persistenceManager
protected ComponentRegistry componentRegistry
public DelegatingPersistenceManager(PersistenceManager persistenceManager)
public void start()
Lifecycle
public void stop()
Lifecycle
public PersistenceManager getActual()
public boolean isEnabled()
isEnabled
in interface PersistenceManager
public boolean hasWriter()
PersistenceManager
hasWriter
in interface PersistenceManager
public boolean isPreloaded()
isPreloaded
in interface PersistenceManager
public CompletionStage<Void> preload()
PersistenceManager
preload
in interface PersistenceManager
public CompletionStage<Void> disableStore(String storeType)
PersistenceManager
disableStore
in interface PersistenceManager
public <T> Set<T> getStores(Class<T> storeClass)
getStores
in interface PersistenceManager
public Collection<String> getStoresAsString()
getStoresAsString
in interface PersistenceManager
public CompletionStage<Void> purgeExpired()
PersistenceManager
purgeExpired
in interface PersistenceManager
public CompletionStage<Void> clearAllStores(Predicate<? super StoreConfiguration> predicate)
PersistenceManager
AdvancedCacheWriter.clear()
on all the stores that aloes it.clearAllStores
in interface PersistenceManager
public CompletionStage<Boolean> deleteFromAllStores(Object key, int segment, Predicate<? super StoreConfiguration> predicate)
deleteFromAllStores
in interface PersistenceManager
public <K,V> org.reactivestreams.Publisher<MarshallableEntry<K,V>> publishEntries(Predicate<? super K> filter, boolean fetchValue, boolean fetchMetadata, Predicate<? super StoreConfiguration> predicate)
PersistenceManager
AdvancedCacheLoader
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.
publishEntries
in interface PersistenceManager
K
- key typeV
- value typefilter
- 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 entriespublic <K,V> org.reactivestreams.Publisher<MarshallableEntry<K,V>> publishEntries(IntSet segments, Predicate<? super K> filter, boolean fetchValue, boolean fetchMetadata, Predicate<? super StoreConfiguration> predicate)
PersistenceManager
publishEntries
in interface PersistenceManager
K
- key typeV
- value typesegments
- 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 entriespublic <K> org.reactivestreams.Publisher<K> publishKeys(Predicate<? super K> filter, Predicate<? super StoreConfiguration> predicate)
PersistenceManager
AdvancedCacheLoader
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, 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
publishKeys
in interface PersistenceManager
K
- key typefilter
- filter so that only keys which match are returnedpredicate
- access mode to choose what type of loader to usepublic <K> org.reactivestreams.Publisher<K> publishKeys(IntSet segments, Predicate<? super K> filter, Predicate<? super StoreConfiguration> predicate)
PersistenceManager
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
publishKeys
in interface PersistenceManager
K
- key typesegments
- 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 usepublic <K,V> CompletionStage<MarshallableEntry<K,V>> loadFromAllStores(Object key, boolean localInvocation, boolean includeStores)
PersistenceManager
loadFromAllStores
in interface PersistenceManager
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 frompublic CompletionStage<Long> size(Predicate<? super StoreConfiguration> predicate)
PersistenceManager
size
in interface PersistenceManager
predicate
- whether a loader can be usedpublic CompletionStage<Long> size(IntSet segments)
PersistenceManager
size
in interface PersistenceManager
segments
- which segments to count entries frompublic void setClearOnStop(boolean clearOnStop)
setClearOnStop
in interface PersistenceManager
public CompletionStage<Void> writeToAllNonTxStores(MarshallableEntry marshalledEntry, int segment, Predicate<? super StoreConfiguration> predicate, long flags)
writeToAllNonTxStores
in interface PersistenceManager
flags
- Flags used during command invocationPersistenceManager.writeToAllNonTxStores(MarshallableEntry, int, Predicate)
public CompletionStage<Void> prepareAllTxStores(TxInvocationContext<AbstractCacheTransaction> txInvocationContext, Predicate<? super StoreConfiguration> predicate) throws PersistenceException
PersistenceManager
prepareAllTxStores
in interface PersistenceManager
txInvocationContext
- the tx invocation containing the modificationspredicate
- should we prepare on a given storePersistenceException
- if an error is encountered at any of the underlying stores.public CompletionStage<Void> commitAllTxStores(TxInvocationContext<AbstractCacheTransaction> txInvocationContext, Predicate<? super StoreConfiguration> predicate)
PersistenceManager
commitAllTxStores
in interface PersistenceManager
txInvocationContext
- the transactional context to be committed.predicate
- should we commit each storepublic CompletionStage<Void> rollbackAllTxStores(TxInvocationContext<AbstractCacheTransaction> txInvocationContext, Predicate<? super StoreConfiguration> predicate)
PersistenceManager
rollbackAllTxStores
in interface PersistenceManager
txInvocationContext
- the transactional context to be rolledback.predicate
- should we rollback each storepublic CompletionStage<Long> writeMapCommand(PutMapCommand putMapCommand, InvocationContext ctx, BiPredicate<? super PutMapCommand,Object> commandKeyPredicate)
PersistenceManager
writeMapCommand
in interface PersistenceManager
putMapCommand
- the put map command to write values fromctx
- context to lookup entriescommandKeyPredicate
- predicate to control if a key/command combination should be acceptedpublic <K,V> CompletionStage<Void> writeEntries(Iterable<MarshallableEntry<K,V>> iterable, Predicate<? super StoreConfiguration> predicate)
PersistenceManager
writeEntries
in interface PersistenceManager
K
- key typeV
- value typeiterable
- entries to writepredicate
- predicate to test for a storepublic CompletionStage<Long> performBatch(TxInvocationContext<AbstractCacheTransaction> invocationContext, BiPredicate<? super WriteCommand,Object> commandKeyPredicate)
PersistenceManager
performBatch
in interface PersistenceManager
invocationContext
- transactional contextcommandKeyPredicate
- predicate to control if a key/command combination should be acceptedpublic boolean isAvailable()
isAvailable
in interface PersistenceManager
public boolean isReadOnly()
isReadOnly
in interface PersistenceManager
CacheWriter
instances have been configured.public <K,V> org.reactivestreams.Publisher<MarshallableEntry<K,V>> publishEntries(boolean fetchValue, boolean fetchMetadata)
PersistenceManager
publishEntries
in interface PersistenceManager
public <K,V> CompletionStage<MarshallableEntry<K,V>> loadFromAllStores(Object key, int segment, boolean localInvocation, boolean includeStores)
PersistenceManager
PersistenceManager.loadFromAllStores(Object, boolean, boolean)
except that the segment of the key is also
provided to avoid having to calculate the segment.loadFromAllStores
in interface PersistenceManager
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 frompublic CompletionStage<Long> size()
size
in interface PersistenceManager
public CompletionStage<Void> writeToAllNonTxStores(MarshallableEntry marshalledEntry, int segment, Predicate<? super StoreConfiguration> predicate)
PersistenceManager
TransactionalCacheWriter
writeToAllNonTxStores
in interface PersistenceManager
marshalledEntry
- the entry to be written to all non-tx stores.segment
- the segment the entry maps topredicate
- should we write to a given storepublic CompletionStage<Boolean> addSegments(IntSet segments)
PersistenceManager
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.
addSegments
in interface PersistenceManager
segments
- segments this cache ownspublic CompletionStage<Boolean> removeSegments(IntSet segments)
PersistenceManager
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.
removeSegments
in interface PersistenceManager
segments
- segments this cache no longer ownsCopyright © 2021 JBoss by Red Hat. All rights reserved.