|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
@ThreadSafe public interface Node<K,V>
A Node is a named logical grouping of data in the JBoss Cache.
A node should be used to contain data for a single data record, for example
information about a particular person or account.
CacheLoader.)
A node has references to its children, parent (each node except the root - defined by Fqn.ROOT - has
a single parent) and data contained within the node (as key/value pairs). The
data access methods are similar to the collections Map interface,
but some are read-only or return copies of the underlying the data.
Cache| Method Summary | |
|---|---|
Node<K,V> |
addChild(Fqn<?> f)
Adds a child node with the given Fqn under the current node. |
void |
clearData()
Removes all mappings from the node's data map. |
int |
dataSize()
|
V |
get(K key)
Returns the value to which this node maps the specified key. |
Node<K,V> |
getChild(Fqn<?> f)
Returns the child node |
Node<K,V> |
getChild(Object name)
|
Set<Node<K,V>> |
getChildren()
Returns an immutable set of children nodes. |
Set<Object> |
getChildrenNames()
Returns an immutable set of children node names. |
Map<K,V> |
getData()
Returns a map containing the data in this Node. |
Fqn |
getFqn()
Returns the Fqn which represents the location of this Node in the cache structure. |
Set<K> |
getKeys()
Returns a Set containing the data in this Node. |
Node<K,V> |
getParent()
Returns the parent node. |
boolean |
hasChild(Fqn<?> f)
Returns true if the child node denoted by the relative Fqn passed in exists. |
boolean |
hasChild(Object o)
Returns true if the child node denoted by the Object name passed in exists. |
boolean |
isLockForChildInsertRemove()
Tests whether this node is configured to be exclusively locked when inserting or removing children. |
boolean |
isResident()
Nodes marked resident would be ignored by the eviction algorithms. |
boolean |
isValid()
Tests if a node reference is still valid. |
V |
put(K key,
V value)
Associates the specified value with the specified key for this node. |
void |
putAll(Map<K,V> map)
Copies all of the mappings from the specified map to this node's map. |
V |
putIfAbsent(K key,
V value)
If the specified key is not already associated with a value, associate it with the given value, and returns the Object (if any) that occupied the space, or null. |
void |
releaseObjectReferences(boolean recursive)
Method that releases object references of cached objects held in the cache by serializing them to byte buffers. |
V |
remove(K key)
Removes the mapping for this key from this node if it is present. |
boolean |
removeChild(Fqn<?> f)
Removes a child node specified by the given relative Fqn. |
boolean |
removeChild(Object childName)
Removes a child node specified by the given name. |
V |
replace(K key,
V value)
Replace entry for key only if currently mapped to some value. |
boolean |
replace(K key,
V oldValue,
V newValue)
Replace entry for key only if currently mapped to given value. |
void |
replaceAll(Map<K,V> map)
Similar to putAll(java.util.Map) except that it removes any entries that exists in
the data map first. |
void |
setLockForChildInsertRemove(boolean lockForChildInsertRemove)
Configures the behaviour of how this node is locked when adding/removing children. |
void |
setResident(boolean resident)
|
| Method Detail |
|---|
Node<K,V> getParent()
null.
Set<Node<K,V>> getChildren()
Set of child nodes. Empty Set if there aren't any children.Set<Object> getChildrenNames()
Set of child node names. Empty Set if there aren't any children.Map<K,V> getData()
Node.
Map containing the data in this Node. If there is no data, an empty Map is returned. The Map returned is always immutable.Set<K> getKeys()
Set containing the data in this Node.
Set containing the data in this Node. If there is no data, an empty Set is returned. The Set returned is always immutable.Fqn getFqn()
Fqn which represents the location of this Node in the cache structure. The Fqn returned is absolute.
Fqn which represents the location of this Node in the cache structure. The Fqn returned is absolute.Node<K,V> addChild(Fqn<?> f)
Fqn under the current node. Returns the newly created node.
If the child exists returns the child node anyway. Guaranteed to return a non-null node.
The Fqn passed in is relative to the current node. The new child node will have an absolute fqn
calculated as follows: new Fqn(getFqn(), f). See
Fqn for the operation of this constructor.
f - Fqn of the child node, relative to the current node.
boolean removeChild(Fqn<?> f)
Fqn.
If you wish to remove children based on absolute Fqns, use the Cache interface instead.
f - Fqn of the child node, relative to the current node.
boolean removeChild(Object childName)
childName - name of the child node, directly under the current node.
Node<K,V> getChild(Fqn<?> f)
f - Fqn of the child node
Node<K,V> getChild(Object name)
name - name of the child
V put(K key,
V value)
key - key with which the specified value is to be associated.value - value to be associated with the specified key.
V putIfAbsent(K key,
V value)
if (!node.getKeys().contains(key))
return node.put(key, value);
else
return node.get(key);
except that this is atomic.
key - key with which the specified value is to be associated.value - value to be associated with the specified key.
V replace(K key,
V value)
if ((node.getKeys().contains(key))
{
return node.put(key, value);
}
else
return null;
except that this is atomic.
key - key with which the specified value is associated.value - value to be associated with the specified key.
boolean replace(K key,
V oldValue,
V newValue)
if (node.get(key).equals(oldValue))
{
node.put(key, newValue);
return true;
}
else
return false;
except that this is atomic.
key - key with which the specified value is associated.oldValue - value expected to be associated with the specified key.newValue - value to be associated with the specified key.
void putAll(Map<K,V> map)
Node node; for (Map.Entry me : map.entrySet()) node.put(me.getKey(), me.getValue());
map - map to copy fromvoid replaceAll(Map<K,V> map)
putAll(java.util.Map) except that it removes any entries that exists in
the data map first. Note that this happens atomically, under a single lock. This is the analogous
to doing a clearData() followed by a putAll(java.util.Map) in the same transaction.
map - map to copy fromV get(K key)
null if the node contains no mapping for this key.
key - key of the data to return
null if the map contains no mapping for this keyV remove(K key)
null if the node contained no mapping for this key
key - key whose mapping is to be removed
null
if there was no mapping for keyvoid clearData()
int dataSize()
boolean hasChild(Fqn<?> f)
Fqn passed in exists.
f - Fqn relative to the current node of the child you are testing the existence of.
Fqn passed in exists.boolean hasChild(Object o)
o - name of the child, relative to the current node
boolean isValid()
NodeNotValidException.
boolean isResident()
void setResident(boolean resident)
isResident()boolean isLockForChildInsertRemove()
Configuration.isLockParentForChildInsertRemove()
This can also be configured on a per-node basis using setLockForChildInsertRemove(boolean)
void setLockForChildInsertRemove(boolean lockForChildInsertRemove)
lockForChildInsertRemove - if true, exclusive locks will be obtained when children are added/removed. If
false, a shared "read lock" will be obtained instead.void releaseObjectReferences(boolean recursive)
recursive - if true, child nodes will have their object references released as well.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||