|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jboss.cache.loader.AbstractCacheLoader
public abstract class AbstractCacheLoader
A convenience abstract implementation of a CacheLoader. Specific methods to note are methods like
storeState(org.jboss.cache.Fqn,java.io.ObjectInputStream), loadState(org.jboss.cache.Fqn,java.io.ObjectOutputStream),
storeEntireState(java.io.ObjectInputStream) and loadEntireState(java.io.ObjectOutputStream) which have convenience
implementations here.
put(java.util.List), used during the prepare phase of a transaction.
| Field Summary | |
|---|---|
protected BuddyFqnTransformer |
buddyFqnTransformer
|
protected CacheSPI |
cache
|
protected RegionManager |
regionManager
|
protected Map<Object,List<Modification>> |
transactions
HashMap |
| Constructor Summary | |
|---|---|
AbstractCacheLoader()
|
|
| Method Summary | |
|---|---|
void |
commit(Object tx)
Commits the transaction. |
void |
create()
Lifecycle method, called when the cache loader is created. |
void |
destroy()
Lifecycle method, called when the cache loader is destroyed. |
protected void |
doMarshall(Fqn fqn,
Object toMarshall)
|
protected Object |
doUnmarshall(Fqn fqn,
Object toUnmarshall)
|
protected Marshaller |
getMarshaller()
|
protected void |
getNodeDataList(Fqn fqn,
List<NodeData> list)
|
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. |
protected void |
loadStateHelper(Fqn fqn,
ObjectOutputStream out)
Do a preorder traversal: visit the node first, then the node's children |
void |
prepare(Object tx,
List<Modification> modifications,
boolean one_phase)
Prepares a list of modifications. |
void |
put(Fqn fqn,
Map<Object,Object> attributes,
boolean erase)
|
void |
put(List<Modification> modifications)
Applies all modifications to the backend store. |
protected void |
regionAwareMarshall(Fqn fqn,
Object toMarshall)
|
protected Object |
regionAwareUnmarshall(Fqn fqn,
Object toUnmarshall)
|
void |
rollback(Object tx)
Rolls the transaction back. |
void |
setCache(CacheSPI c)
Sets the CacheSPI that is maintaining this CacheLoader. |
void |
setRegionManager(RegionManager regionManager)
Sets the RegionManager this object should use to manage
marshalling/unmarshalling of different regions using different
classloaders. |
void |
start()
Lifecycle method, called when the cache loader is started. |
void |
stop()
Lifecycle method, called when the cache loader is stopped. |
void |
storeEntireState(ObjectInputStream is)
Stores the entire state for this cache by reading it from a provided ObjectInputStream. |
void |
storeState(Fqn subtree,
ObjectInputStream in)
Stores the given portion of the cache tree's state in secondary storage. |
protected void |
storeStateHelper(Fqn subtree,
List nodeData,
boolean moveToBuddy)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.jboss.cache.loader.CacheLoader |
|---|
exists, get, getChildrenNames, getConfig, put, put, remove, remove, removeData, setConfig |
| Field Detail |
|---|
protected CacheSPI cache
protected RegionManager regionManager
protected BuddyFqnTransformer buddyFqnTransformer
protected Map<Object,List<Modification>> transactions
| Constructor Detail |
|---|
public AbstractCacheLoader()
| Method Detail |
|---|
public void put(Fqn fqn,
Map<Object,Object> attributes,
boolean erase)
throws Exception
Exception
public 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 CacheLoaderis - ObjectInputStream to read state
ExceptionstoreEntireState(ObjectInputStream),
NodeData
public void storeState(Fqn subtree,
ObjectInputStream in)
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 CacheLoadersubtree - 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.in - ObjectInputStream to read state
ExceptionstoreState(Fqn,ObjectInputStream),
NodeData
protected void storeStateHelper(Fqn subtree,
List nodeData,
boolean moveToBuddy)
throws Exception
Exception
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 CacheLoaderos - ObjectOutputStream to write state
ExceptionloadEntireState(ObjectOutputStream),
NodeData
public 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 CacheLoadersubtree - Fqn naming the root (i.e. highest level parent) node of
the subtree for which state is requested.os - ObjectOutputStream to write state
ExceptionloadState(Fqn,ObjectOutputStream),
Region.activate(),
NodeDatapublic void setCache(CacheSPI c)
CacheLoaderCacheSPI that is maintaining this CacheLoader.
This method allows this CacheLoader to set a reference to the CacheSPI.
This method is called be called after the CacheLoader instance has been constructed.
setCache in interface CacheLoaderc - The cache on which this loader workspublic void setRegionManager(RegionManager regionManager)
CacheLoaderRegionManager this object should use to manage
marshalling/unmarshalling of different regions using different
classloaders.
NOTE: This method is only intended to be used
by the CacheSPI instance this cache loader is
associated with.
setRegionManager in interface CacheLoaderregionManager - the region manager to use, or null.
protected void regionAwareMarshall(Fqn fqn,
Object toMarshall)
throws Exception
Exception
protected Object regionAwareUnmarshall(Fqn fqn,
Object toUnmarshall)
throws Exception
Exception
protected void doMarshall(Fqn fqn,
Object toMarshall)
throws Exception
Exception
protected Object doUnmarshall(Fqn fqn,
Object toUnmarshall)
throws Exception
Exception
protected void loadStateHelper(Fqn fqn,
ObjectOutputStream out)
throws Exception
Exception
protected void getNodeDataList(Fqn fqn,
List<NodeData> list)
throws Exception
Exception
public void put(List<Modification> modifications)
throws Exception
CacheLoader
put in interface CacheLoadermodifications - A ListExceptionprotected Marshaller getMarshaller()
public void create()
throws Exception
CacheLoader
create in interface CacheLoaderException
public void start()
throws Exception
CacheLoader
start in interface CacheLoaderExceptionpublic void stop()
CacheLoader
stop in interface CacheLoaderpublic void destroy()
CacheLoader
destroy in interface CacheLoader
public void prepare(Object tx,
List<Modification> modifications,
boolean one_phase)
throws Exception
CacheLoadertx (tx is the key)
prepare in interface CacheLoadertx - 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 Modifications, 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
CacheLoadertx and commit that
transaction. Non-transactional CacheLoaders could simply write the data
that was previously saved transiently under the given tx
key, to (for example) a file system.
Note this only holds if the previous prepare() did not define one_phase=true
commit in interface CacheLoadertx - transaction to commit
Exceptionpublic void rollback(Object tx)
CacheLoadertx and roll back that
transaction.
rollback in interface CacheLoadertx - transaction to roll back
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||