|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jboss.cache.loader.AbstractCacheLoader org.jboss.cache.loader.AbstractDelegatingCacheLoader org.jboss.cache.loader.AsyncCacheLoader
public class AsyncCacheLoader
The AsyncCacheLoader is a delegating cache loader that extends AbstractDelegatingCacheLoader overriding methods to that should not just delegate the operation to the underlying cache loader.
Read operations are done synchronously, while write (CRUD - Create, Remove, Update, Delete) operations are done asynchronously. There is no provision for exception handling at the moment for problems encountered with the underlying CacheLoader during a CRUD operation, and the exception is just logged. When configuring the CacheLoader, use the following attribute:
<attribute name="CacheLoaderAsynchronous">true</attribute>
to define whether cache loader operations are to be asynchronous. If not
specified, a cache loader operation is assumed synchronous.
The following additional parameters are available:
true
, this loader returns the old values from put(org.jboss.cache.Fqn, java.lang.Object, java.lang.Object)
and remove(org.jboss.cache.Fqn, java.lang.Object)
methods. Otherwise, these methods always return
null. Default is true. false
improves the performance of these
operations.put(org.jboss.cache.Fqn, java.lang.Object, java.lang.Object)
operations will be processed
synchronously, and then only the remove(org.jboss.cache.Fqn, java.lang.Object)
operations will be
processed asynchronously. This mode may be useful for processing
expiration of messages within a separate thread and keeping other
operations synchronous for reliability.
cache.async.batchSize
and
cache.async.pollWait
. For larger sized records, use a smaller
value for cache.async.queueSize
.
Field Summary |
---|
Fields inherited from class org.jboss.cache.loader.AbstractCacheLoader |
---|
buddyFqnTransformer, cache, regionManager, transactions |
Constructor Summary | |
---|---|
AsyncCacheLoader()
|
|
AsyncCacheLoader(CacheLoader cacheLoader)
|
Method Summary | |
---|---|
void |
commit(Object tx)
TODO this is the same as the AbstractCacheLoader. |
Map |
get(Fqn name)
Returns all keys and values from the persistent store, given a Fqn |
void |
prepare(Object tx,
List<Modification> modifications,
boolean one_phase)
TODO this is the same as the AbstractCacheLoader. |
void |
put(Fqn name,
Map attributes)
Puts all entries of the map into the existing map of the given node, overwriting existing keys, but not clearing the existing map before insertion. |
Object |
put(Fqn name,
Object key,
Object value)
Puts a key and value into the attribute map of a given node. |
void |
put(List<Modification> modifications)
Applies all modifications to the backend store. |
void |
remove(Fqn name)
Removes the given node and all its subnodes, does nothing if the node does not exist. |
Object |
remove(Fqn name,
Object key)
Removes the given key and value from the attributes of the given node. |
void |
removeData(Fqn name)
Removes all attributes from a given node, but doesn't delete the node itself or any subnodes. |
void |
rollback(Object tx)
TODO this is the same as the AbstractCacheLoader. |
void |
setConfig(CacheLoaderConfig.IndividualCacheLoaderConfig base)
Sets the configuration. |
void |
start()
|
void |
stop()
|
String |
toString()
|
Methods inherited from class org.jboss.cache.loader.AbstractDelegatingCacheLoader |
---|
create, destroy, exists, getCacheLoader, getConfig, getChildrenNames, loadEntireState, loadState, setCache, setCacheLoader, setRegionManager, storeEntireState, storeState |
Methods inherited from class org.jboss.cache.loader.AbstractCacheLoader |
---|
doMarshall, doUnmarshall, getMarshaller, getNodeDataList, loadStateHelper, move, put, regionAwareMarshall, regionAwareUnmarshall, storeStateHelper |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public AsyncCacheLoader()
public AsyncCacheLoader(CacheLoader cacheLoader)
Method Detail |
---|
public void setConfig(CacheLoaderConfig.IndividualCacheLoaderConfig base)
CacheLoader
Lifecycle.create()
and Lifecycle.start()
.
setConfig
in interface CacheLoader
setConfig
in class AbstractDelegatingCacheLoader
base
- May be an instance of the CacheLoaderConfig.IndividualCacheLoaderConfig
base
class, in which case the cache loader should use the
PluggableConfigurationComponent.getProperties()
method to find configuration information. Alternatively,
may be a type-specific subclass of CacheLoaderConfig.IndividualCacheLoaderConfig
,
if there is one.public Map get(Fqn name) throws Exception
CacheLoader
Fqn
get
in interface CacheLoader
get
in class AbstractDelegatingCacheLoader
name
- the Fqn
to search for.
public void prepare(Object tx, List<Modification> modifications, boolean one_phase) throws Exception
prepare
in interface CacheLoader
prepare
in class AbstractDelegatingCacheLoader
tx
- The transaction, indended to be used by implementations as an identifier of the transaction (and not necessarily a JTA Transaction
object)modifications
- A List
containing Modification
s, for the given transactionone_phase
- Persist immediately and (for example) commit the local JDBC transaction as well. When true,
we won't get a CacheLoader.commit(Object)
or CacheLoader.rollback(Object)
method call later
Exception
public void commit(Object tx) throws Exception
commit
in interface CacheLoader
commit
in class AbstractDelegatingCacheLoader
tx
- transaction to commit
Exception
public void rollback(Object tx)
rollback
in interface CacheLoader
rollback
in class AbstractDelegatingCacheLoader
tx
- transaction to roll backpublic Object put(Fqn name, Object key, Object value) throws Exception
CacheLoader
put
in interface CacheLoader
put
in class AbstractDelegatingCacheLoader
Exception
public void put(Fqn name, Map attributes) throws Exception
CacheLoader
Map.putAll(java.util.Map extends K, ? extends V>)
.
If the node does not exist, all parent nodes from the root down are created automatically
Note since 3.0, as an optimization, this method will require a definitive attribute map and
not just a subset. This will allow cache loader implementations to overwrite rather than merge, if that is
deemed more efficient. This will not break backward compatibility since performing a merge will not cause
any loss of data even though it is an unnecessary step.
put
in interface CacheLoader
put
in class AbstractDelegatingCacheLoader
name
- The fully qualified name of the nodeattributes
- A Map of attributes. Can be null
Exception
public void put(List<Modification> modifications) throws Exception
CacheLoader
put
in interface CacheLoader
put
in class AbstractDelegatingCacheLoader
modifications
- A ListException
public Object remove(Fqn name, Object key) throws Exception
CacheLoader
remove
in interface CacheLoader
remove
in class AbstractDelegatingCacheLoader
Exception
public void remove(Fqn name) throws Exception
CacheLoader
remove
in interface CacheLoader
remove
in class AbstractDelegatingCacheLoader
name
- the Fqn
of the node
Exception
public void removeData(Fqn name) throws Exception
CacheLoader
removeData
in interface CacheLoader
removeData
in class AbstractDelegatingCacheLoader
name
- the Fqn
of the node
Exception
public void start() throws Exception
start
in interface Lifecycle
start
in class AbstractDelegatingCacheLoader
Exception
public void stop()
stop
in interface Lifecycle
stop
in class AbstractDelegatingCacheLoader
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |