public class ChainingCacheLoader extends AbstractCacheLoader
buddyFqnTransformer, cache, regionManager, transactions| Constructor and Description |
|---|
ChainingCacheLoader() |
| Modifier and Type | Method and Description |
|---|---|
void |
addCacheLoader(CacheLoader l,
CacheLoaderConfig.IndividualCacheLoaderConfig cfg)
Adds a cache loader to the chain (always added at the end of the chain)
|
void |
commit(Object tx)
Commit the transaction.
|
void |
create()
Creates individual cache loaders.
|
void |
destroy() |
boolean |
exists(Fqn name)
Checks whether the CacheLoader has a node with Fqn
|
Map |
get(Fqn name)
Returns all keys and values from the persistent store, given a fully qualified name
|
List<CacheLoader> |
getCacheLoaders()
Returns a List
|
Set<?> |
getChildrenNames(Fqn fqn)
Returns a list of children names, all names are relative.
|
CacheLoaderConfig.IndividualCacheLoaderConfig |
getConfig()
Gets the configuration.
|
int |
getSize()
Returns the number of cache loaders in the chain.
|
void |
injectDependencies(ComponentRegistry registry) |
void |
loadEntireState(ObjectOutputStream os)
Fetches the entire state for this cache from secondary storage (disk, database)
and writes it to a provided ObjectOutputStream.
|
void |
loadState(Fqn subtree,
ObjectOutputStream os)
Fetches a portion of the state for this cache from secondary storage (disk, database)
and writes it to a provided ObjectOutputStream.
|
void |
prepare(Object tx,
List modifications,
boolean one_phase)
Prepare the modifications.
|
void |
purgeIfNecessary() |
void |
put(Fqn name,
Map attributes)
Inserts all elements of attributes into the attributes hashmap of the given node, overwriting existing
attributes, but not clearing the existing hashmap before insertion (making it a union of existing and
new attributes)
If the node does not exist, all parent nodes from the root down are created automatically
|
Object |
put(Fqn name,
Object key,
Object value)
Inserts key and value into the attributes hashmap of the given node.
|
void |
put(List<Modification> modifications)
Inserts all modifications to the backend store.
|
void |
remove(Fqn name)
Removes the given node.
|
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
|
void |
rollback(Object tx)
Roll the transaction back.
|
void |
setConfig(CacheLoaderConfig.IndividualCacheLoaderConfig config)
Sets the configuration.
|
void |
setRegionManager(RegionManager manager)
No-op, as this class doesn't directly use the ERegionManager.
|
void |
start() |
void |
stop() |
void |
storeEntireState(ObjectInputStream is)
Stores the entire state for this cache by reading it from a provided ObjectInputStream.
|
void |
storeState(Fqn subtree,
ObjectInputStream is)
Stores the given portion of the cache tree's state in secondary storage.
|
String |
toString() |
doMarshall, doUnmarshall, getMarshaller, getNodeDataList, loadStateHelper, move, put, regionAwareMarshall, regionAwareUnmarshall, setCache, storeStateHelperpublic void setConfig(CacheLoaderConfig.IndividualCacheLoaderConfig config)
config - ignoredpublic CacheLoaderConfig.IndividualCacheLoaderConfig getConfig()
CacheLoaderCacheLoaderConfig.IndividualCacheLoaderConfig object.public void injectDependencies(ComponentRegistry registry)
public Set<?> getChildrenNames(Fqn fqn) throws Exception
fqn - The FQN of the parentExceptionpublic Map get(Fqn name) throws Exception
name - Exceptionpublic boolean exists(Fqn name) throws Exception
name - Exceptionpublic Object put(Fqn name, Object key, Object value) throws Exception
Exceptionpublic void put(Fqn name, Map attributes) throws Exception
name - The fully qualified name of the nodeattributes - A Map of attributes. Can be nullExceptionpublic void put(List<Modification> modifications) throws Exception
put in interface CacheLoaderput in class AbstractCacheLoadermodifications - A ListExceptionpublic Object remove(Fqn name, Object key) throws Exception
Exceptionpublic void remove(Fqn name) throws Exception
public void removeData(Fqn name) throws Exception
name - Exceptionpublic void prepare(Object tx, List modifications, boolean one_phase) throws Exception
tx (tx is the key)
prepare in interface CacheLoaderprepare in class AbstractCacheLoadertx - The transaction, just used as a hashmap keymodifications - Listone_phase - Persist immediately and (for example) commit the local JDBC transaction as well. When true,
we won't get a commit(Object) or rollback(Object) method call laterExceptionpublic void commit(Object tx) throws Exception
tx and commit that transactiontx key, to (for example) a file system (note this only holds if the previous prepare() did
not define one_phase=truecommit in interface CacheLoadercommit in class AbstractCacheLoadertx - Exceptionpublic void rollback(Object tx)
tx and roll back that transactionrollback in interface CacheLoaderrollback in class AbstractCacheLoadertx - public void create()
throws Exception
create in interface Lifecyclecreate in class AbstractCacheLoaderExceptionpublic void start()
throws Exception
start in interface Lifecyclestart in class AbstractCacheLoaderExceptionpublic void stop()
stop in interface Lifecyclestop in class AbstractCacheLoaderpublic void destroy()
destroy in interface Lifecycledestroy in class AbstractCacheLoaderpublic void setRegionManager(RegionManager manager)
setRegionManager in interface CacheLoadersetRegionManager in class AbstractCacheLoadermanager - the region manager to use, or null.public void loadEntireState(ObjectOutputStream os) throws Exception
CacheLoaderCacheLoader.storeEntireState(ObjectInputStream)
Implementations of this method should not catch any exception or close the
given ObjectOutputStream parameter. In order to ensure cacheloader interoperability
contents of the cache are written to the ObjectOutputStream as a sequence of
NodeData objects.
Default implementation is provided by AbstractCacheLoader and ensures cacheloader
interoperability. Implementors are encouraged to consider extending AbstractCacheLoader
prior to implementing completely custom cacheloader.loadEntireState in interface CacheLoaderloadEntireState in class AbstractCacheLoaderos - ObjectOutputStream to write stateExceptionAbstractCacheLoader.loadEntireState(ObjectOutputStream),
NodeDatapublic void loadState(Fqn subtree, ObjectOutputStream os) throws Exception
CacheLoaderCacheLoader.storeState(Fqn,ObjectInputStream).
Implementations of this method should not catch any exception or close the
given ObjectOutputStream parameter. In order to ensure cacheloader interoperability
contents of the cache are written to the ObjectOutputStream as a sequence of
NodeData objects.
Default implementation is provided by AbstractCacheLoader and ensures cacheloader
interoperability. Implementors are encouraged to consider extending AbstractCacheLoader
prior to implementing completely custom cacheloader.loadState in interface CacheLoaderloadState in class AbstractCacheLoadersubtree - Fqn naming the root (i.e. highest level parent) node of
the subtree for which state is requested.os - ObjectOutputStream to write stateExceptionAbstractCacheLoader.loadState(Fqn,ObjectOutputStream),
Region.activate(),
NodeDatapublic void storeEntireState(ObjectInputStream is) throws Exception
CacheLoaderCacheLoader.loadEntireState(ObjectOutputStream)}
on some other cache instance. State currently in storage gets overwritten.
Implementations of this method should not catch any exception or close the
given ObjectInputStream parameter. In order to ensure cacheloader interoperability
contents of the cache are read from the ObjectInputStream as a sequence of
NodeData objects.
Default implementation is provided by AbstractCacheLoader and ensures cacheloader
interoperability. Implementors are encouraged to consider extending AbstractCacheLoader
prior to implementing completely custom cacheloader.storeEntireState in interface CacheLoaderstoreEntireState in class AbstractCacheLoaderis - ObjectInputStream to read stateExceptionAbstractCacheLoader.storeEntireState(ObjectInputStream),
NodeDatapublic void storeState(Fqn subtree, ObjectInputStream is) throws Exception
CacheLoadersubtree,
then no special behavior is required. Otherwise, ensure that
the state is integrated under the given subtree. Typically
in the latter case subtree would be the Fqn of the buddy
backup region for
a buddy group; e.g.
If the the transferred state had Fqns starting with "/a" and
subtree was "/_BUDDY_BACKUP_/192.168.1.2:5555" then the
state should be stored in the local persistent store under
"/_BUDDY_BACKUP_/192.168.1.2:5555/a"
Implementations of this method should not catch any exception or close the
given ObjectInputStream parameter. In order to ensure cacheloader interoperability
contents of the cache are read from the ObjectInputStream as a sequence of
NodeData objects.
Default implementation is provided by AbstractCacheLoader and ensures cacheloader
interoperability. Implementors are encouraged to consider extending AbstractCacheLoader
prior to implementing completely custom cacheloader.storeState in interface CacheLoaderstoreState in class AbstractCacheLoadersubtree - Fqn naming the root (i.e. highest level parent) node of
the subtree included in state. If the Fqns
of the data included in state are not
already children of subtree, then their
Fqns should be altered to make them children of
subtree before they are persisted.is - ObjectInputStream to read stateExceptionAbstractCacheLoader.storeState(Fqn,ObjectInputStream),
NodeDatapublic int getSize()
public List<CacheLoader> getCacheLoaders()
public void addCacheLoader(CacheLoader l, CacheLoaderConfig.IndividualCacheLoaderConfig cfg)
l - the cache loader to addcfg - and its configurationCopyright © 2012 JBoss, a division of Red Hat. All Rights Reserved.