Class JdbcStringBasedStore<K,V>
- java.lang.Object
-
- org.infinispan.persistence.jdbc.common.impl.BaseJdbcStore<K,V,JdbcStringBasedStoreConfiguration>
-
- org.infinispan.persistence.jdbc.stringbased.JdbcStringBasedStore<K,V>
-
- All Implemented Interfaces:
NonBlockingStore<K,V>
public class JdbcStringBasedStore<K,V> extends org.infinispan.persistence.jdbc.common.impl.BaseJdbcStore<K,V,JdbcStringBasedStoreConfiguration>
AdvancedCacheLoaderimplementation 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.Key2StringMapperonly supports key to string transformation(one way); in order to be able to use preload one needs to specify anTwoWayKey2StringMapper, which extendsKey2StringMapperand 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 anTwoWayKey2StringMapperotherwise 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.NonBlockingStore
NonBlockingStore.Characteristic, NonBlockingStore.SegmentedPublisher<Type>
-
-
Constructor Summary
Constructors Constructor Description JdbcStringBasedStore()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompletionStage<Void>addSegments(IntSet segments)Invoked when a node becomes an owner of the given segments.Set<NonBlockingStore.Characteristic>characteristics()Returns a set of characteristics for this store and its elements.protected org.infinispan.persistence.jdbc.common.TableOperations<K,V>createTableOperations(InitializationContext ctx, JdbcStringBasedStoreConfiguration configuration)protected voidextraStopSteps()org.infinispan.persistence.jdbc.common.connectionfactory.ConnectionFactorygetConnectionFactory()org.infinispan.persistence.jdbc.impl.table.TableManager<K,V>getTableManager()org.reactivestreams.Publisher<MarshallableEntry<K,V>>purgeExpired()Returns a Publisher that, after it is subscribed to, removes any expired entries from the store and publishes them to the returned Publisher.CompletionStage<Void>removeSegments(IntSet segments)Invoked when a node loses ownership of the given segments.-
Methods inherited from interface org.infinispan.persistence.spi.NonBlockingStore
approximateSize, containsKey, destroy, ignoreCommandWithFlags
-
-
-
-
Method Detail
-
characteristics
public Set<NonBlockingStore.Characteristic> characteristics()
Description copied from interface:NonBlockingStoreReturns a set of characteristics for this store and its elements. This method may be invoked multiple times to determine which methods of the store can be used and how the data in the store can be handled.Refer to
NonBlockingStore.Characteristicand its values for descriptions of each characteristic for stores.- Returns:
- the set of characteristics that this store supports.
-
createTableOperations
protected org.infinispan.persistence.jdbc.common.TableOperations<K,V> createTableOperations(InitializationContext ctx, JdbcStringBasedStoreConfiguration configuration)
-
getTableManager
public org.infinispan.persistence.jdbc.impl.table.TableManager<K,V> getTableManager()
-
extraStopSteps
protected void extraStopSteps()
-
addSegments
public CompletionStage<Void> addSegments(IntSet segments)
Description copied from interface:NonBlockingStoreInvoked when a node becomes an owner of the given segments. Some store implementations may require initializing additional resources when a new segment is required. For example a store could store entries in a different file per segment.Summary of Characteristics Effects
Characteristic Effect NonBlockingStore.Characteristic.SHAREABLEIf the store has this characteristic and is configured to be StoreConfiguration.shared(), this method will never be invoked.NonBlockingStore.Characteristic.SEGMENTABLEThis method is invoked only if the store has this characteristic and is configured to be segmented.If a problem is encountered, it is recommended to wrap any created/caught Throwable in a
PersistenceExceptionand the stage be completed exceptionally.- Parameters:
segments- the segments to add.- Returns:
- a stage that, when complete, indicates that the segments have been added.
-
removeSegments
public CompletionStage<Void> removeSegments(IntSet segments)
Description copied from interface:NonBlockingStoreInvoked when a node loses ownership of the given segments. A store must then remove any entries that map to the given segments and can remove any resources related to the given segments. For example, a database store can delete rows of the given segment or a file-based store can delete files related to the given segments.Summary of Characteristics Effects
Characteristic Effect NonBlockingStore.Characteristic.SHAREABLEIf the store has this characteristic and is configured to be shared, this method will never be invoked.NonBlockingStore.Characteristic.SEGMENTABLEThis method is invoked only if the store has this characteristic and is configured to be segmented.If a problem is encountered, it is recommended to wrap any created/caught Throwable in a
PersistenceExceptionand the stage be completed exceptionally.- Parameters:
segments- the segments to remove.- Returns:
- a stage that, when complete, indicates that the segments have been removed.
-
getConnectionFactory
public org.infinispan.persistence.jdbc.common.connectionfactory.ConnectionFactory getConnectionFactory()
-
purgeExpired
public org.reactivestreams.Publisher<MarshallableEntry<K,V>> purgeExpired()
Description copied from interface:NonBlockingStoreReturns a Publisher that, after it is subscribed to, removes any expired entries from the store and publishes them to the returned Publisher.When the Publisher is subscribed to, it is expected to do point-in-time expiration and should not return a Publisher that has infinite entries or never completes.
Subscribing to the returned
Publishershould not block the invoking thread. It is the responsibility of the store implementation to ensure this occurs. If however the store must block to perform an operation it is recommended to wrap your Publisher before returning with theBlockingManager.blockingPublisher(Publisher)method and it will handle subscription and observation on the blocking and non blocking executors respectively.Summary of Characteristics Effects
Characteristic Effect NonBlockingStore.Characteristic.EXPIRATIONThis method is only invoked if the store has this characteristic. If a problem is encountered, it is recommended to wrap any created/caught Throwable in a
PersistenceExceptionand the stage be completed exceptionally.- Returns:
- a Publisher that publishes the entries that are expired at the time of subscription.
-
-