|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface CacheLoader
A CacheLoader
implementation persists and load keys to and from
secondary storage, such as a database or filesystem. Typically,
implementations store a series of keys and values (an entire Map
)
under a single Fqn
. Loading and saving properties of an entire
Map
should be atomic.
setConfig(java.util.Properties)
) and cache (setCache(TreeCache)
) are set. After this, Service.create()
is called.
Then Service.start()
is called. When re-deployed, Service.stop()
will be
called, followed by another Service.start()
. Finally, when shut down,
Service.destroy()
is called, after which the loader is unusable.
Method Summary | |
---|---|
void |
commit(java.lang.Object tx)
Commits the transaction. |
boolean |
exists(Fqn name)
Returns true if the CacheLoader has a node with a Fqn . |
java.util.Map |
get(Fqn name)
Returns all keys and values from the persistent store, given a fully qualified name. |
java.util.Set |
getChildrenNames(Fqn fqn)
Returns a set of children node names as Strings. |
byte[] |
loadEntireState()
Fetches the entire state for this cache from secondary storage (disk, DB) and returns it as a byte buffer. |
void |
prepare(java.lang.Object tx,
java.util.List modifications,
boolean one_phase)
Prepares a list of modifications. |
void |
put(Fqn name,
java.util.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. |
java.lang.Object |
put(Fqn name,
java.lang.Object key,
java.lang.Object value)
Puts a key and value into the attribute map of a given node. |
void |
put(java.util.List modifications)
Applies all modifications to the backend store. |
void |
remove(Fqn name)
Removes the given node and all its subnodes. |
java.lang.Object |
remove(Fqn name,
java.lang.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(java.lang.Object tx)
Rolls the transaction back. |
void |
setCache(TreeCache c)
Sets the TreeCache that is maintaining this CacheLoader. |
void |
setConfig(java.util.Properties properties)
Sets the configuration. |
void |
storeEntireState(byte[] state)
Stores the given state in secondary storage. |
Methods inherited from interface org.jboss.system.Service |
---|
create, destroy, start, stop |
Method Detail |
---|
void setConfig(java.util.Properties properties)
Service.create()
and Service.start()
.
properties
- a collection of configuration propertiesvoid setCache(TreeCache c)
TreeCache
that is maintaining this CacheLoader.
This method allows this CacheLoader to invoke methods on TreeCache,
including fetching additional configuration information. This method is
called be called after the CacheLoader instance has been constructed.
c
- The cache on which this loader worksjava.util.Set getChildrenNames(Fqn fqn) throws java.lang.Exception
Fqn
.
Returns null if the named node is not found or there are no children.
The returned set must not be modifiable. Implementors can use
Collections.unmodifiableSet(Set)
to make the set unmodifiable.
fqn
- The FQN of the parent
java.lang.Exception
java.util.Map get(Fqn name) throws java.lang.Exception
name
-
boolean exists(Fqn name) throws java.lang.Exception
Fqn
.
java.lang.Exception
java.lang.Object put(Fqn name, java.lang.Object key, java.lang.Object value) throws java.lang.Exception
java.lang.Exception
void put(Fqn name, java.util.Map attributes) throws java.lang.Exception
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
name
- The fully qualified name of the nodeattributes
- A Map of attributes. Can be null
java.lang.Exception
void put(java.util.List modifications) throws java.lang.Exception
modifications
- A Listjava.lang.Exception
java.lang.Object remove(Fqn name, java.lang.Object key) throws java.lang.Exception
java.lang.Exception
void remove(Fqn name) throws java.lang.Exception
java.lang.Exception
void removeData(Fqn name) throws java.lang.Exception
java.lang.Exception
void prepare(java.lang.Object tx, java.util.List modifications, boolean one_phase) throws java.lang.Exception
tx
(tx is the key)
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
java.lang.Exception
void commit(java.lang.Object tx) throws java.lang.Exception
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
tx
- transaction to commit
java.lang.Exception
void rollback(java.lang.Object tx)
tx
and roll back that
transaction.
tx
- transaction to roll backbyte[] loadEntireState() throws java.lang.Exception
storeEntireState(byte[])
.
java.lang.Exception
void storeEntireState(byte[] state) throws java.lang.Exception
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |