|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.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()
|
void |
destroy()
|
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 |
protected void |
move(Fqn fqn,
Fqn parent)
|
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()
|
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 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, getConfig, getChildrenNames, 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
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
is
- ObjectInputStream to read state
Exception
storeEntireState(ObjectInputStream)
,
NodeData
public void storeState(Fqn subtree, ObjectInputStream in) 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
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.in
- ObjectInputStream to read state
Exception
storeState(Fqn,ObjectInputStream)
,
NodeData
protected void storeStateHelper(Fqn subtree, List nodeData, boolean moveToBuddy) throws Exception
Exception
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
os
- ObjectOutputStream to write state
Exception
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
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
loadState(Fqn,ObjectOutputStream)
,
Region.activate()
,
NodeData
public void setCache(CacheSPI c)
CacheLoader
CacheSPI
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 CacheLoader
c
- The cache on which this loader workspublic void setRegionManager(RegionManager regionManager)
CacheLoader
RegionManager
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 CacheLoader
regionManager
- 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 CacheLoader
modifications
- A ListException
protected void move(Fqn fqn, Fqn parent) throws Exception
Exception
protected Marshaller getMarshaller()
public void create() throws Exception
create
in interface Lifecycle
Exception
public void start() throws Exception
start
in interface Lifecycle
Exception
public void stop()
stop
in interface Lifecycle
public void destroy()
destroy
in interface Lifecycle
public void prepare(Object tx, List<Modification> modifications, boolean one_phase) throws Exception
CacheLoader
tx
(tx is the key)
prepare
in interface CacheLoader
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
CacheLoader
tx
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 CacheLoader
tx
- transaction to commit
Exception
public void rollback(Object tx)
CacheLoader
tx
and roll back that
transaction.
rollback
in interface CacheLoader
tx
- transaction to roll back
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |