|
||||||||||
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.ChainingCacheLoader
public class ChainingCacheLoader
This decorator is used whenever more than one cache loader is configured. 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 cacheloaders that specified set ignoreModifications to false.
Field Summary |
---|
Fields inherited from class org.jboss.cache.loader.AbstractCacheLoader |
---|
buddyFqnTransformer, cache, regionManager, transactions |
Constructor Summary | |
---|---|
ChainingCacheLoader()
|
Method Summary | |
---|---|
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()
|
Methods inherited from class org.jboss.cache.loader.AbstractCacheLoader |
---|
doMarshall, doUnmarshall, getMarshaller, getNodeDataList, loadStateHelper, move, put, regionAwareMarshall, regionAwareUnmarshall, setCache, storeStateHelper |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ChainingCacheLoader()
Method Detail |
---|
public void setConfig(CacheLoaderConfig.IndividualCacheLoaderConfig config)
create()
and start()
config
- ignoredpublic CacheLoaderConfig.IndividualCacheLoaderConfig getConfig()
CacheLoader
CacheLoaderConfig.IndividualCacheLoaderConfig
object.public void injectDependencies(ComponentRegistry registry)
public Set<?> getChildrenNames(Fqn fqn) throws Exception
fqn
- The FQN of the parent
Exception
public Map get(Fqn name) throws Exception
name
-
public boolean exists(Fqn name) throws Exception
name
-
Exception
public Object put(Fqn name, Object key, Object value) throws Exception
Exception
public void put(Fqn name, Map attributes) throws Exception
name
- The fully qualified name of the nodeattributes
- A Map of attributes. Can be null
Exception
public void put(List<Modification> modifications) throws Exception
put
in interface CacheLoader
put
in class AbstractCacheLoader
modifications
- A ListException
public Object remove(Fqn name, Object key) throws Exception
Exception
public void remove(Fqn name) throws Exception
name
- the Fqn
of the node
Exception
public void removeData(Fqn name) throws Exception
name
-
Exception
public void prepare(Object tx, List modifications, boolean one_phase) throws Exception
tx
(tx is the key)
prepare
in interface CacheLoader
prepare
in class AbstractCacheLoader
tx
- 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 later
Exception
public 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=true
commit
in interface CacheLoader
commit
in class AbstractCacheLoader
tx
-
Exception
public void rollback(Object tx)
tx
and roll back that transaction
rollback
in interface CacheLoader
rollback
in class AbstractCacheLoader
tx
- public void create() throws Exception
create
in interface Lifecycle
create
in class AbstractCacheLoader
Exception
public void start() throws Exception
start
in interface Lifecycle
start
in class AbstractCacheLoader
Exception
public void stop()
stop
in interface Lifecycle
stop
in class AbstractCacheLoader
public void destroy()
destroy
in interface Lifecycle
destroy
in class AbstractCacheLoader
public void setRegionManager(RegionManager manager)
setRegionManager
in interface CacheLoader
setRegionManager
in class AbstractCacheLoader
manager
- the region manager to use, or null
.public void loadEntireState(ObjectOutputStream os) throws Exception
CacheLoader
CacheLoader.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 CacheLoader
loadEntireState
in class AbstractCacheLoader
os
- ObjectOutputStream to write state
Exception
AbstractCacheLoader.loadEntireState(ObjectOutputStream)
,
NodeData
public void loadState(Fqn subtree, ObjectOutputStream os) throws Exception
CacheLoader
CacheLoader.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 CacheLoader
loadState
in class AbstractCacheLoader
subtree
- Fqn naming the root (i.e. highest level parent) node of
the subtree for which state is requested.os
- ObjectOutputStream to write state
Exception
AbstractCacheLoader.loadState(Fqn,ObjectOutputStream)
,
Region.activate()
,
NodeData
public void storeEntireState(ObjectInputStream is) throws Exception
CacheLoader
CacheLoader.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 CacheLoader
storeEntireState
in class AbstractCacheLoader
is
- ObjectInputStream to read state
Exception
AbstractCacheLoader.storeEntireState(ObjectInputStream)
,
NodeData
public void storeState(Fqn subtree, ObjectInputStream is) throws Exception
CacheLoader
subtree
,
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 CacheLoader
storeState
in class AbstractCacheLoader
subtree
- 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 state
Exception
AbstractCacheLoader.storeState(Fqn,ObjectInputStream)
,
NodeData
public int getSize()
public List<CacheLoader> getCacheLoaders()
public void addCacheLoader(CacheLoader l, CacheLoaderConfig.IndividualCacheLoaderConfig cfg)
l
- the cache loader to addcfg
- and its configurationpublic String toString()
toString
in class Object
public void purgeIfNecessary() throws Exception
Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |