|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.infinispan.loader.decorators.ChainingCacheStore
public class ChainingCacheStore
A chaining cache loader that allows us to configure > 1 cache loader.
READ operations are directed to each of the cache loaders (in the order which they were configured) until a non-null (or non-empty in the case of retrieving collection objects) result is achieved. WRITE operations are propagated to ALL registered cache stores specified, that set ignoreModifications to false.
| Constructor Summary | |
|---|---|
ChainingCacheStore()
|
|
| Method Summary | |
|---|---|
void |
addCacheLoader(CacheLoader loader,
CacheLoaderConfig config)
|
void |
clear()
Clears all entries in the store |
void |
commit(Transaction tx)
Commits a transaction that has been previously prepared. |
boolean |
containsKey(Object key)
|
void |
fromStream(ObjectInput inputStream)
Writes contents of the stream to the store. |
Class<? extends CacheLoaderConfig> |
getConfigurationClass()
|
LinkedHashMap<CacheStore,CacheLoaderConfig> |
getStores()
|
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. |
void |
prepare(List<? extends Modification> list,
Transaction 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. |
void |
purgeIfNecessary()
|
boolean |
remove(Object key)
Removes an entry in the store. |
void |
removeAll(Set<Object> keys)
Bulk remove operation |
void |
rollback(Transaction 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, javax.transaction.Transaction, boolean). |
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 java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ChainingCacheStore()
| Method Detail |
|---|
public void store(InternalCacheEntry ed)
throws CacheLoaderException
CacheStore
store in interface CacheStoreed - entry to store
CacheLoaderException - in the event of problems writing to the store
public void fromStream(ObjectInput inputStream)
throws CacheLoaderException
CacheStoreCacheStore.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.
fromStream in interface CacheStoreinputStream - stream to read from
CacheLoaderException - in the event of problems writing to the store
public void toStream(ObjectOutput outputStream)
throws CacheLoaderException
CacheStoreCacheStore.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.
toStream in interface CacheStoreoutputStream - stream to write to
CacheLoaderException - in the event of problems reading from the store
public void clear()
throws CacheLoaderException
CacheStore
clear in interface CacheStoreCacheLoaderException - in the event of problems writing to the store
public boolean remove(Object key)
throws CacheLoaderException
CacheStore
remove in interface CacheStorekey - key to remove
CacheLoaderException - in the event of problems writing to the store
public void removeAll(Set<Object> keys)
throws CacheLoaderException
CacheStore
removeAll in interface CacheStorekeys - to remove
CacheLoaderException - in the event of problems writing to the store
public void purgeExpired()
throws CacheLoaderException
CacheStore
purgeExpired in interface CacheStoreCacheLoaderException - in the event of problems writing to the store
public void commit(Transaction tx)
throws CacheLoaderException
CacheStoreCacheStore.prepare(java.util.List, javax.transaction.Transaction, boolean). The implementation would need to deal with
this case acordingly. 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, javax.transaction.Transaction, boolean) invocation. As such, ThreadLocals
should not be relied upon to maintain transaction context.
commit in interface CacheStoretx - tx to commit
CacheLoaderException - in the event of problems writing to the storepublic void rollback(Transaction tx)
CacheStoreCacheStore.prepare(java.util.List, javax.transaction.Transaction, boolean). The implementation would need to deal with
this case acordingly. 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, javax.transaction.Transaction, boolean) invocation. As such, ThreadLocals
should not be relied upon to maintain transaction context.
rollback in interface CacheStoretx - tx to roll back
public void prepare(List<? extends Modification> list,
Transaction tx,
boolean isOnePhase)
throws CacheLoaderException
CacheStore
prepare in interface CacheStorelist - modifications to be appliedtx - transaction identifierisOnePhase - if true, there will not be a commit or rollback phase and changes should be flushed
immediately
CacheLoaderException - in the event of problems writing to the store
public void init(CacheLoaderConfig config,
Cache cache,
Marshaller m)
CacheLoaderCacheLoaderManager when
setting up cache loaders.
init in interface CacheLoaderconfig - 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.
public InternalCacheEntry load(Object key)
throws CacheLoaderException
CacheLoader
load in interface CacheLoaderkey - key
CacheLoaderException - in the event of problems reading from source
public Set<InternalCacheEntry> loadAll()
throws CacheLoaderException
CacheLoader
loadAll in interface CacheLoaderCacheLoaderException - in the event of problems reading from source
public boolean containsKey(Object key)
throws CacheLoaderException
containsKey in interface CacheLoaderkey - key to test
CacheLoaderException - in the event of problems reading from sourcepublic Class<? extends CacheLoaderConfig> getConfigurationClass()
getConfigurationClass in interface CacheLoaderCacheLoaderConfig bean used to configure this implementation of
CacheLoader
public void start()
throws CacheLoaderException
start in interface CacheLoaderCacheLoaderException
public void stop()
throws CacheLoaderException
stop in interface CacheLoaderCacheLoaderException
public void addCacheLoader(CacheLoader loader,
CacheLoaderConfig config)
public void purgeIfNecessary()
throws CacheLoaderException
CacheLoaderExceptionpublic LinkedHashMap<CacheStore,CacheLoaderConfig> getStores()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||