public abstract class AbstractCacheStore extends AbstractCacheLoader implements CacheStore
CacheStore
that holds common implementations for some methodsModifier and Type | Field and Description |
---|---|
protected boolean |
multiThreadedPurge |
protected ExecutorService |
purgerService |
cache, marshaller
Constructor and Description |
---|
AbstractCacheStore() |
Modifier and Type | Method and Description |
---|---|
protected void |
applyModifications(List<? extends Modification> mods) |
void |
commit(GlobalTransaction tx)
Commits a transaction that has been previously prepared.
|
CacheStoreConfig |
getCacheStoreConfig()
Returns the configuration object associated to this cache store config.
|
protected int |
getConcurrencyLevel() |
protected StreamingMarshaller |
getMarshaller() |
void |
init(CacheLoaderConfig config,
Cache<?,?> cache,
StreamingMarshaller m)
Used to initialize a cache loader.
|
void |
prepare(List<? extends Modification> mods,
GlobalTransaction tx,
boolean isOnePhase)
Issues a prepare call with a set of modifications to be applied to the cache store
|
void |
purgeExpired()
Purges expired entries from the store.
|
protected abstract void |
purgeInternal() |
void |
removeAll(Set<Object> keys)
Bulk remove operation
|
void |
rollback(GlobalTransaction tx)
Rolls back a transaction that has been previously prepared
This method may be invoked on a transaction for which there is no prior
CacheStore.prepare(java.util.List, org.infinispan.transaction.xa.GlobalTransaction, boolean) . |
protected static void |
safeClose(InputStream stream) |
protected static void |
safeClose(OutputStream stream) |
void |
start() |
void |
stop() |
protected boolean |
supportsMultiThreadedPurge() |
containsKey
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
clear, fromStream, remove, store, toStream
containsKey, getConfigurationClass, load, load, loadAll, loadAllKeys
protected ExecutorService purgerService
protected boolean multiThreadedPurge
public void init(CacheLoaderConfig config, Cache<?,?> cache, StreamingMarshaller m) throws CacheLoaderException
CacheLoader
org.infinispan.loaders.CacheLoaderManager
when setting up cache loaders.init
in interface CacheLoader
init
in class AbstractCacheLoader
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
protected final int getConcurrencyLevel()
public void start() throws CacheLoaderException
start
in interface CacheLoader
CacheLoaderException
protected boolean supportsMultiThreadedPurge()
public void stop() throws CacheLoaderException
stop
in interface CacheLoader
CacheLoaderException
public void purgeExpired() throws CacheLoaderException
CacheStore
purgeExpired
in interface CacheStore
CacheLoaderException
- in the event of problems writing to the storeprotected abstract void purgeInternal() throws CacheLoaderException
CacheLoaderException
protected void applyModifications(List<? extends Modification> mods) throws CacheLoaderException
CacheLoaderException
public void prepare(List<? extends Modification> mods, GlobalTransaction tx, boolean isOnePhase) throws CacheLoaderException
CacheStore
prepare
in interface CacheStore
mods
- modifications to be appliedtx
- transaction identifierisOnePhase
- if true, there will not be a commit or rollback phase and changes should be flushed
immediatelyCacheLoaderException
- in the event of problems writing to the storepublic void rollback(GlobalTransaction tx)
CacheStore
CacheStore.prepare(java.util.List, org.infinispan.transaction.xa.GlobalTransaction, boolean)
. The implementation would
need to deal with this case accordingly. Typically, this would be a no-op, after ensuring any resources attached
to the transaction are cleared up.
Also note that this method may be invoked on a thread which is different from the CacheStore.prepare(java.util.List, org.infinispan.transaction.xa.GlobalTransaction, boolean)
invocation. As such, ThreadLocal
s should not be relied upon to maintain transaction context.
rollback
in interface CacheStore
tx
- tx to roll backpublic CacheStoreConfig getCacheStoreConfig()
CacheStore
getCacheStoreConfig
in interface CacheStore
public void commit(GlobalTransaction tx) throws CacheLoaderException
CacheStore
CacheStore.prepare(java.util.List, org.infinispan.transaction.xa.GlobalTransaction, boolean)
. The implementation would
need to deal with this case accordingly. Typically, this would be a no-op, after ensuring any resources attached
to the transaction are cleared up.
Also note that this method may be invoked on a thread which is different from the CacheStore.prepare(java.util.List, org.infinispan.transaction.xa.GlobalTransaction, boolean)
invocation. As such, ThreadLocal
s should not be relied upon to maintain transaction context.
commit
in interface CacheStore
tx
- tx to commitCacheLoaderException
- in the event of problems writing to the storepublic void removeAll(Set<Object> keys) throws CacheLoaderException
CacheStore
removeAll
in interface CacheStore
keys
- to removeCacheLoaderException
- in the event of problems writing to the storeprotected static void safeClose(InputStream stream) throws CacheLoaderException
CacheLoaderException
protected static void safeClose(OutputStream stream) throws CacheLoaderException
CacheLoaderException
protected StreamingMarshaller getMarshaller()
Copyright © 2014 JBoss, a division of Red Hat. All Rights Reserved.