Package org.infinispan.persistence.jpa
Class JpaStore<K,V>
- java.lang.Object
-
- org.infinispan.persistence.jpa.JpaStore<K,V>
-
- All Implemented Interfaces:
Lifecycle,AdvancedCacheLoader<K,V>,AdvancedCacheWriter<K,V>,AdvancedLoadWriteStore<K,V>,CacheLoader<K,V>,CacheWriter<K,V>,ExternalStore<K,V>
public class JpaStore<K,V> extends java.lang.Object implements AdvancedLoadWriteStore<K,V>
NOTE: This store can return expired keys or entries on any given operation ifJpaStoreConfiguration.storeMetadata()was set to false.- Author:
- Ray Tsang
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.infinispan.persistence.spi.AdvancedCacheLoader
AdvancedCacheLoader.CacheLoaderTask<K,V>, AdvancedCacheLoader.TaskContext
-
Nested classes/interfaces inherited from interface org.infinispan.persistence.spi.AdvancedCacheWriter
AdvancedCacheWriter.PurgeListener<K>
-
-
Constructor Summary
Constructors Constructor Description JpaStore()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.concurrent.CompletionStage<java.lang.Void>bulkUpdate(org.reactivestreams.Publisher<MarshallableEntry<? extends K,? extends V>> publisher)Persist all provided entries to the store in chunks, with the size of each chunk determined by the store implementation.voidclear()Removes all the data from the storage.booleancontains(java.lang.Object key)Returns true if the storage contains an entry associated with the given key.booleandelete(java.lang.Object key)voiddeleteBatch(java.lang.Iterable<java.lang.Object> keys)Remove all provided keys from the store in a single batch operation.io.reactivex.Flowable<MarshallableEntry<K,V>>entryPublisher(java.util.function.Predicate<? super K> filter, boolean fetchValue, boolean fetchMetadata)Publishes all entries from this store.voidinit(InitializationContext ctx)Used to initialize a cache loader.protected booleanisValidKeyType(java.lang.Object key)MarshallableEntryloadEntry(java.lang.Object key)Fetches an entry from the storage.io.reactivex.Flowable<K>publishKeys(java.util.function.Predicate<? super K> filter)Publishes all the keys from this store.voidpurge(java.util.concurrent.Executor threadPool, AdvancedCacheWriter.PurgeListener listener)Using the thread in the pool, removed all the expired data from the persistence storage.intsize()Returns the number of elements in the store.voidstart()Invoked on component startvoidstop()Invoked on component stopvoidwrite(MarshallableEntry entry)Persists the entry to the storage.-
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.spi.AdvancedCacheLoader
process, publishEntries
-
Methods inherited from interface org.infinispan.persistence.spi.CacheLoader
load
-
Methods inherited from interface org.infinispan.persistence.spi.CacheWriter
isAvailable, write, writeBatch
-
Methods inherited from interface org.infinispan.persistence.spi.ExternalStore
destroy, isAvailable
-
-
-
-
Method Detail
-
init
public void init(InitializationContext ctx)
Description copied from interface:CacheLoaderUsed to initialize a cache loader. Typically invoked by thePersistenceManagerwhen setting up cache loaders.- Specified by:
initin interfaceCacheLoader<K,V>- Specified by:
initin interfaceCacheWriter<K,V>
-
start
public void start()
Description copied from interface:LifecycleInvoked on component start
-
stop
public void stop()
Description copied from interface:LifecycleInvoked on component stop
-
isValidKeyType
protected boolean isValidKeyType(java.lang.Object key)
-
clear
public void clear()
Description copied from interface:AdvancedCacheWriterRemoves all the data from the storage.- Specified by:
clearin interfaceAdvancedCacheWriter<K,V>
-
delete
public boolean delete(java.lang.Object key)
- Specified by:
deletein interfaceCacheWriter<K,V>- Returns:
- true if the entry existed in the persistent store and it was deleted.
-
deleteBatch
public void deleteBatch(java.lang.Iterable<java.lang.Object> keys)
Description copied from interface:CacheWriterRemove all provided keys from the store in a single batch operation. If this is not supported by the underlying store, then keys are removed from the store individually viaCacheWriter.delete(Object).- Specified by:
deleteBatchin interfaceCacheWriter<K,V>- Parameters:
keys- an Iterable of entry Keys to be removed from the store.
-
write
public void write(MarshallableEntry entry)
Description copied from interface:CacheWriterPersists the entry to the storage.- Specified by:
writein interfaceCacheWriter<K,V>- See Also:
MarshallableEntry
-
bulkUpdate
public java.util.concurrent.CompletionStage<java.lang.Void> bulkUpdate(org.reactivestreams.Publisher<MarshallableEntry<? extends K,? extends V>> publisher)
Description copied from interface:CacheWriterPersist all provided entries to the store in chunks, with the size of each chunk determined by the store implementation. If chunking is not supported by the underlying store, then entries are written to the store individually viaCacheWriter.write(MarshallableEntry).- Specified by:
bulkUpdatein interfaceCacheWriter<K,V>- Parameters:
publisher- aPublisherofMarshallableEntryinstances
-
contains
public boolean contains(java.lang.Object key)
Description copied from interface:CacheLoaderReturns true if the storage contains an entry associated with the given key.- Specified by:
containsin interfaceCacheLoader<K,V>
-
loadEntry
public MarshallableEntry loadEntry(java.lang.Object key)
Description copied from interface:CacheLoaderFetches an entry from the storage. If aMarshallableEntryneeds to be created here,InitializationContext.getMarshallableEntryFactory()()} andInitializationContext.getByteBufferFactory()should be used.- Specified by:
loadEntryin interfaceCacheLoader<K,V>- Returns:
- the entry, or null if the entry does not exist
-
publishKeys
public io.reactivex.Flowable<K> publishKeys(java.util.function.Predicate<? super K> filter)
Description copied from interface:AdvancedCacheLoaderPublishes all the keys from this store. The given publisher can be used by as manySubscribers as desired. Keys are not retrieved until a given Subscriber requests them from theSubscription.Stores will return only non expired keys
- Specified by:
publishKeysin interfaceAdvancedCacheLoader<K,V>- Parameters:
filter- a filter - null is treated as allowing all entries- Returns:
- a publisher that will provide the keys from the store
-
entryPublisher
public io.reactivex.Flowable<MarshallableEntry<K,V>> entryPublisher(java.util.function.Predicate<? super K> filter, boolean fetchValue, boolean fetchMetadata)
Description copied from interface:AdvancedCacheLoaderPublishes all entries from this store. The given publisher can be used by as manySubscribers as desired. Entries are not retrieved until a given Subscriber requests them from theSubscription.If fetchMetadata is true this store must guarantee to not return any expired entries.
- Specified by:
entryPublisherin interfaceAdvancedCacheLoader<K,V>- Parameters:
filter- a filter - null is treated as allowing all entriesfetchValue- whether or not to fetch the value from the persistent store. E.g. if the iteration is intended only over the key set, no point fetching the values from the persistent store as wellfetchMetadata- whether or not to fetch the metadata from the persistent store. E.g. if the iteration is intended only ove the key set, then no point fetching the metadata from the persistent store as well- Returns:
- a publisher that will provide the entries from the store
-
size
public int size()
Description copied from interface:AdvancedCacheLoaderReturns the number of elements in the store.- Specified by:
sizein interfaceAdvancedCacheLoader<K,V>
-
purge
public void purge(java.util.concurrent.Executor threadPool, AdvancedCacheWriter.PurgeListener listener)Description copied from interface:AdvancedCacheWriterUsing the thread in the pool, removed all the expired data from the persistence storage. For each removed entry, the supplied listener is invoked.When this method returns all entries will be purged and no tasks will be running due to this loader in the provided executor. If however an exception is thrown there could be tasks still pending or running in the executor.
- Specified by:
purgein interfaceAdvancedCacheWriter<K,V>
-
-