|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.infinispan.loaders.AbstractCacheLoader org.infinispan.loaders.AbstractCacheStore org.infinispan.loaders.jdbc.mixed.JdbcMixedCacheStore
public class JdbcMixedCacheStore
Cache store that combines functionality of JdbcBinaryCacheStore
and JdbcStringBasedCacheStore
. It
aggregates an instance of JdbcBinaryCacheStore and JdbcStringBasedCacheStore, delegating work to one of them
(sometimes both, see below) based on the passed in key. In order to determine which store to use it will rely on the
configured Key2StringMapper
)(see configuration).
InternalCacheEntry
s, and at the same time being able to store any other keys, a la
JdbcBinaryCacheStore
.
There will only be a performance cost for the aggregate operations: loadAll, fromStream, toStream and clear. For
these operations there will be two distinct database call, one for each JdbcStore implementation. Most of application
are only using these operations at lifecycles changes (e.g. fromStream and toStream at cluster join time, loadAll at
startup for warm caches), so performance drawback shouldn't be significant (again, most of the cases).
Resource sharing - both aggregated cache loaders have locks and connection pools. The locking is not shared, each
loader keeping its own StripedLock
instance. Also the tables (even though
similar as definition) are different in order to avoid key collision. On the other hand, the connection pooling is a
shared resource.
JdbcMixedCacheStoreConfig
,
JdbcBinaryCacheStore
,
JdbcStringBasedCacheStore
Field Summary |
---|
Fields inherited from class org.infinispan.loaders.AbstractCacheStore |
---|
cache, marshaller, multiThreadedPurge, purgerService |
Constructor Summary | |
---|---|
JdbcMixedCacheStore()
|
Method Summary | |
---|---|
void |
clear()
Clears all entries in the store |
void |
fromStream(ObjectInput inputStream)
Writes contents of the stream to the store. |
JdbcBinaryCacheStore |
getBinaryCacheStore()
|
Class<? extends CacheLoaderConfig> |
getConfigurationClass()
|
ConnectionFactory |
getConnectionFactory()
|
JdbcStringBasedCacheStore |
getStringBasedCacheStore()
|
void |
init(CacheLoaderConfig config,
Cache cache,
Marshaller m)
Used to initialize a cache loader. |
InternalCacheEntry |
load(Object key)
Loads an entry mapped to by a given key. |
Set<InternalCacheEntry> |
loadAll()
Loads all entries in the loader. |
protected void |
purgeInternal()
|
boolean |
remove(Object key)
Removes an entry in the store. |
void |
start()
|
void |
stop()
|
void |
store(InternalCacheEntry ed)
Stores an entry |
void |
toStream(ObjectOutput outputStream)
Loads the entire state into a stream, using whichever format is most efficient for the cache loader implementation. |
Methods inherited from class org.infinispan.loaders.AbstractCacheStore |
---|
applyModifications, commit, getCacheStoreConfig, getConcurrencyLevel, getMarshaller, prepare, purgeExpired, removeAll, rollback, safeClose, safeClose, supportsMultiThreadedPurge |
Methods inherited from class org.infinispan.loaders.AbstractCacheLoader |
---|
containsKey |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.infinispan.loaders.CacheLoader |
---|
containsKey |
Constructor Detail |
---|
public JdbcMixedCacheStore()
Method Detail |
---|
public void init(CacheLoaderConfig config, Cache cache, Marshaller m) throws CacheLoaderException
CacheLoader
CacheLoaderManager
when setting up cache loaders.
init
in interface CacheLoader
init
in class AbstractCacheStore
config
- the cache loader configuration beancache
- cache associated with this cache loader. Implementations may use this to determine cache name when
selecting where refer to state in storage, for example, a different database table name.m
- marshaller to use when loading state from a stream, if supported by the implementation.
CacheLoaderException
public void start() throws CacheLoaderException
start
in interface CacheLoader
start
in class AbstractCacheStore
CacheLoaderException
public void stop() throws CacheLoaderException
stop
in interface CacheLoader
stop
in class AbstractCacheStore
CacheLoaderException
protected void purgeInternal() throws CacheLoaderException
purgeInternal
in class AbstractCacheStore
CacheLoaderException
public InternalCacheEntry load(Object key) throws CacheLoaderException
CacheLoader
key
- key
CacheLoaderException
- in the event of problems reading from sourcepublic Set<InternalCacheEntry> loadAll() throws CacheLoaderException
CacheLoader
CacheLoaderException
- in the event of problems reading from sourcepublic void store(InternalCacheEntry ed) throws CacheLoaderException
CacheStore
ed
- entry to store
CacheLoaderException
- in the event of problems writing to the storepublic void fromStream(ObjectInput inputStream) throws CacheLoaderException
CacheStore
CacheStore.toStream(java.io.ObjectOutput)
. While not a
requirement, it is recommended that implementations make use of the Marshaller
when dealing with the stream to make use of efficient marshalling.
It is imperative that implementations do not close the stream after finishing with it.
It is also recommended that implementations use their own start and end markers on the stream since
other processes may write additional data to the stream after the cache store has written to it. As such, either
markers or some other mechanism to prevent the store from reading too much information should be employed when
writing to the stream in CacheStore.fromStream(java.io.ObjectInput)
to prevent data corruption.
It can be assumed that the stream passed in already performs buffering such that the cache store implementation
doesn't have to.
inputStream
- stream to read from
CacheLoaderException
- in the event of problems writing to the storepublic void toStream(ObjectOutput outputStream) throws CacheLoaderException
CacheStore
CacheStore.fromStream(java.io.ObjectInput)
.
While not a requirement, it is recommended that implementations make use of the Marshaller
when dealing with the stream to make use of efficient marshalling.
It is imperative that implementations do not flush or close the stream after finishing with it.
It is also recommended that implementations use their own start and end markers on the stream since
other processes may write additional data to the stream after the cache store has written to it. As such, either
markers or some other mechanism to prevent the store from reading too much information in CacheStore.fromStream(java.io.ObjectInput)
should be employed, to prevent data corruption.
It can be assumed that the stream passed in already performs buffering such that the cache store implementation
doesn't have to.
outputStream
- stream to write to
CacheLoaderException
- in the event of problems reading from the storepublic boolean remove(Object key) throws CacheLoaderException
CacheStore
key
- key to remove
CacheLoaderException
- in the event of problems writing to the storepublic void clear() throws CacheLoaderException
CacheStore
CacheLoaderException
- in the event of problems writing to the storepublic Class<? extends CacheLoaderConfig> getConfigurationClass()
CacheLoaderConfig
bean used to configure this
implementation of CacheLoader
public ConnectionFactory getConnectionFactory()
public JdbcBinaryCacheStore getBinaryCacheStore()
public JdbcStringBasedCacheStore getStringBasedCacheStore()
|
Google Analytics | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |