public class PersistenceManagerImpl extends Object implements PersistenceManager
PersistenceManager.AccessMode| Constructor and Description |
|---|
PersistenceManagerImpl() |
| 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.
|
<K,V> List<NonBlockingStore<K,V>> |
getAllStores(Predicate<Set<NonBlockingStore.Characteristic>> predicate) |
<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> ctx,
BiPredicate<? super WriteCommand,Object> commandKeyPredicate)
Writes a batch for the given modifications in the transactional context
|
protected CompletionStage<Void> |
pollStoreAvailability()
Polls the availability of all configured stores.
|
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(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,
long flags) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitsize, writeToAllNonTxStorespublic void start()
Lifecycleprotected CompletionStage<Void> pollStoreAvailability()
public void stop()
Lifecyclepublic boolean isEnabled()
isEnabled in interface PersistenceManagerpublic boolean isReadOnly()
isReadOnly in interface PersistenceManagerCacheWriter instances have been configured.public boolean hasWriter()
PersistenceManagerhasWriter in interface PersistenceManagerpublic boolean isPreloaded()
isPreloaded in interface PersistenceManagerpublic CompletionStage<Void> preload()
PersistenceManagerpreload in interface PersistenceManagerpublic CompletionStage<Void> disableStore(String storeType)
PersistenceManagerdisableStore in interface PersistenceManagerpublic <T> Set<T> getStores(Class<T> storeClass)
getStores in interface PersistenceManagerpublic Collection<String> getStoresAsString()
getStoresAsString in interface PersistenceManagerpublic CompletionStage<Void> purgeExpired()
PersistenceManagerpurgeExpired in interface PersistenceManagerpublic CompletionStage<Void> clearAllStores(Predicate<? super StoreConfiguration> predicate)
PersistenceManagerAdvancedCacheWriter.clear() on all the stores that aloes it.clearAllStores in interface PersistenceManagerpublic CompletionStage<Boolean> deleteFromAllStores(Object key, int segment, Predicate<? super StoreConfiguration> predicate)
deleteFromAllStores in interface PersistenceManagerpublic <K,V> org.reactivestreams.Publisher<MarshallableEntry<K,V>> publishEntries(boolean fetchValue, boolean fetchMetadata)
PersistenceManagerpublishEntries in interface PersistenceManagerpublic <K,V> org.reactivestreams.Publisher<MarshallableEntry<K,V>> publishEntries(Predicate<? super K> filter, boolean fetchValue, boolean fetchMetadata, Predicate<? super StoreConfiguration> predicate)
PersistenceManagerAdvancedCacheLoader 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 PersistenceManagerK - 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)
PersistenceManagerpublishEntries in interface PersistenceManagerK - 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)
PersistenceManagerAdvancedCacheLoader 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 PersistenceManagerK - 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 PersistenceManagerK - 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)
PersistenceManagerloadFromAllStores in interface PersistenceManagerkey - 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 <K,V> CompletionStage<MarshallableEntry<K,V>> loadFromAllStores(Object key, int segment, boolean localInvocation, boolean includeStores)
PersistenceManagerPersistenceManager.loadFromAllStores(Object, boolean, boolean) except that the segment of the key is also
provided to avoid having to calculate the segment.loadFromAllStores in interface PersistenceManagerkey - 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(Predicate<? super StoreConfiguration> predicate)
PersistenceManagersize in interface PersistenceManagerpredicate - whether a loader can be usedpublic CompletionStage<Long> size(IntSet segments)
PersistenceManagersize in interface PersistenceManagersegments - which segments to count entries frompublic void setClearOnStop(boolean clearOnStop)
setClearOnStop in interface PersistenceManagerpublic CompletionStage<Void> writeToAllNonTxStores(MarshallableEntry marshalledEntry, int segment, Predicate<? super StoreConfiguration> predicate, long flags)
writeToAllNonTxStores in interface PersistenceManagerflags - Flags used during command invocationPersistenceManager.writeToAllNonTxStores(MarshallableEntry, int, Predicate)public CompletionStage<Void> prepareAllTxStores(TxInvocationContext<AbstractCacheTransaction> txInvocationContext, Predicate<? super StoreConfiguration> predicate) throws PersistenceException
PersistenceManagerprepareAllTxStores in interface PersistenceManagertxInvocationContext - 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)
PersistenceManagercommitAllTxStores in interface PersistenceManagertxInvocationContext - the transactional context to be committed.predicate - should we commit each storepublic CompletionStage<Void> rollbackAllTxStores(TxInvocationContext<AbstractCacheTransaction> txInvocationContext, Predicate<? super StoreConfiguration> predicate)
PersistenceManagerrollbackAllTxStores in interface PersistenceManagertxInvocationContext - the transactional context to be rolledback.predicate - should we rollback each storepublic <K,V> CompletionStage<Void> writeEntries(Iterable<MarshallableEntry<K,V>> iterable, Predicate<? super StoreConfiguration> predicate)
PersistenceManagerwriteEntries in interface PersistenceManagerK - key typeV - value typeiterable - entries to writepredicate - predicate to test for a storepublic CompletionStage<Long> writeMapCommand(PutMapCommand putMapCommand, InvocationContext ctx, BiPredicate<? super PutMapCommand,Object> commandKeyPredicate)
PersistenceManagerwriteMapCommand in interface PersistenceManagerputMapCommand - the put map command to write values fromctx - context to lookup entriescommandKeyPredicate - predicate to control if a key/command combination should be acceptedpublic CompletionStage<Long> performBatch(TxInvocationContext<AbstractCacheTransaction> ctx, BiPredicate<? super WriteCommand,Object> commandKeyPredicate)
PersistenceManagerperformBatch in interface PersistenceManagerctx - transactional contextcommandKeyPredicate - predicate to control if a key/command combination should be acceptedpublic boolean isAvailable()
isAvailable in interface PersistenceManagerpublic CompletionStage<Boolean> addSegments(IntSet segments)
PersistenceManagerThis 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 PersistenceManagersegments - segments this cache ownspublic CompletionStage<Boolean> removeSegments(IntSet segments)
PersistenceManagerThis 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 PersistenceManagersegments - segments this cache no longer ownspublic <K,V> List<NonBlockingStore<K,V>> getAllStores(Predicate<Set<NonBlockingStore.Characteristic>> predicate)
Copyright © 2021 JBoss by Red Hat. All rights reserved.