Class JdbcStringBasedStore<K,V>
- java.lang.Object
-
- org.infinispan.persistence.jdbc.stringbased.JdbcStringBasedStore<K,V>
-
- All Implemented Interfaces:
org.infinispan.commons.api.Lifecycle
,org.infinispan.persistence.spi.AdvancedCacheLoader<K,V>
,org.infinispan.persistence.spi.AdvancedCacheWriter<K,V>
,org.infinispan.persistence.spi.AdvancedLoadWriteStore<K,V>
,org.infinispan.persistence.spi.CacheLoader<K,V>
,org.infinispan.persistence.spi.CacheWriter<K,V>
,org.infinispan.persistence.spi.ExternalStore<K,V>
,org.infinispan.persistence.spi.TransactionalCacheWriter<K,V>
public class JdbcStringBasedStore<K,V> extends Object implements org.infinispan.persistence.spi.AdvancedLoadWriteStore<K,V>, org.infinispan.persistence.spi.TransactionalCacheWriter<K,V>
AdvancedCacheLoader
implementation that stores the entries in a database. This cache store will store each entry within a row in the table. This assures a finer grained granularity for all operation, and better performance. In order to be able to store non-string keys, it relies on anKey2StringMapper
. Note that only the keys are stored as strings, the values are still saved as binary data. Using a character data type for the value column will result in unmarshalling errors. The actual storage table is defined through configurationJdbcStringBasedStoreConfiguration
. The table can be created/dropped on-the-fly, at deployment time. For more details consult javadoc forJdbcStringBasedStoreConfiguration
. Preload.In order to support preload functionality the store needs to read the string keys from the database and transform them into the corresponding key objects.Key2StringMapper
only supports key to string transformation(one way); in order to be able to use preload one needs to specify anTwoWayKey2StringMapper
, which extendsKey2StringMapper
and allows bidirectional transformation. Rehashing. When a node leaves/joins, Infinispan moves around persistent state as part of rehashing process. For this it needs access to the underlaying key objects, so if distribution is used, the mapper needs to be anTwoWayKey2StringMapper
otherwise the cache won't start (same constraint as with preloading).- Author:
- Mircea.Markus@jboss.com
- See Also:
Key2StringMapper
,DefaultTwoWayKey2StringMapper
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.infinispan.persistence.spi.AdvancedCacheLoader
org.infinispan.persistence.spi.AdvancedCacheLoader.CacheLoaderTask<K extends Object,V extends Object>, org.infinispan.persistence.spi.AdvancedCacheLoader.TaskContext
-
Nested classes/interfaces inherited from interface org.infinispan.persistence.spi.AdvancedCacheWriter
org.infinispan.persistence.spi.AdvancedCacheWriter.PurgeListener<K extends Object>
-
-
Constructor Summary
Constructors Constructor Description JdbcStringBasedStore()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
void
commit(Transaction tx)
boolean
contains(Object key)
boolean
delete(Object key)
void
deleteBatch(Iterable<Object> keys)
ConnectionFactory
getConnectionFactory()
TableManager
getTableManager()
void
init(org.infinispan.persistence.spi.InitializationContext ctx)
boolean
isAvailable()
org.infinispan.marshall.core.MarshalledEntry<K,V>
load(Object key)
void
prepareWithModifications(Transaction transaction, org.infinispan.persistence.support.BatchModification batchModification)
io.reactivex.Flowable<org.infinispan.marshall.core.MarshalledEntry<K,V>>
publishEntries(Predicate<? super K> filter, boolean fetchValue, boolean fetchMetadata)
io.reactivex.Flowable<K>
publishKeys(Predicate<? super K> filter)
void
purge(Executor executor, org.infinispan.persistence.spi.AdvancedCacheWriter.PurgeListener purgeListener)
void
rollback(Transaction tx)
int
size()
void
start()
void
stop()
void
write(org.infinispan.marshall.core.MarshalledEntry entry)
void
writeBatch(Iterable<org.infinispan.marshall.core.MarshalledEntry<? extends K,? extends V>> marshalledEntries)
-
-
-
Method Detail
-
init
public void init(org.infinispan.persistence.spi.InitializationContext ctx)
-
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
-
isAvailable
public boolean isAvailable()
-
getConnectionFactory
public ConnectionFactory getConnectionFactory()
-
write
public void write(org.infinispan.marshall.core.MarshalledEntry entry)
-
writeBatch
public void writeBatch(Iterable<org.infinispan.marshall.core.MarshalledEntry<? extends K,? extends V>> marshalledEntries)
-
clear
public void clear()
-
delete
public boolean delete(Object key)
-
purge
public void purge(Executor executor, org.infinispan.persistence.spi.AdvancedCacheWriter.PurgeListener purgeListener)
-
contains
public boolean contains(Object key)
-
publishEntries
public io.reactivex.Flowable<org.infinispan.marshall.core.MarshalledEntry<K,V>> publishEntries(Predicate<? super K> filter, boolean fetchValue, boolean fetchMetadata)
-
prepareWithModifications
public void prepareWithModifications(Transaction transaction, org.infinispan.persistence.support.BatchModification batchModification) throws org.infinispan.persistence.spi.PersistenceException
-
commit
public void commit(Transaction tx)
-
rollback
public void rollback(Transaction tx)
-
size
public int size()
-
getTableManager
public TableManager getTableManager()
-
-