org.jboss.cache.invocation
Class NodeInvocationDelegate<K,V>

java.lang.Object
  extended by org.jboss.cache.invocation.AbstractInvocationDelegate
      extended by org.jboss.cache.invocation.NodeInvocationDelegate<K,V>
All Implemented Interfaces:
Node<K,V>, NodeSPI<K,V>

public class NodeInvocationDelegate<K,V>
extends AbstractInvocationDelegate
implements NodeSPI<K,V>

The delegate that users (and interceptor authors) interact with when they obtain a node from the cache or another node. This wrapper delegates calls down the interceptor chain.

Since:
2.1.0
Author:
Manik Surtani (manik@jboss.org)

Field Summary
 
Fields inherited from class org.jboss.cache.invocation.AbstractInvocationDelegate
configuration, invocationContextContainer, invoker, lifecycleManager, log, originLocal
 
Constructor Summary
NodeInvocationDelegate(UnversionedNode node)
           
 
Method Summary
 Node<K,V> addChild(Fqn<?> f)
          Adds a child node with the given Fqn under the current node.
 void addChild(Object nodeName, Node<K,V> nodeToAdd)
          Adds or replaces a child by name.
 NodeSPI<K,V> addChildDirect(Fqn childName)
          Adds a child directly to a Node.
 NodeSPI<K,V> addChildDirect(Fqn f, boolean notify)
          Same as NodeSPI.addChildDirect(Fqn) except that it optionally allows you to suppress notification events for the creation of this node.
 void addChildDirect(NodeSPI<K,V> child)
          Directly adds the node passed in to the children map of the current node.
 NodeSPI<K,V> addChildDirect(Object childName, boolean notify)
          Same as NodeSPI.addChildDirect(Fqn, boolean) except that it just takes a child name
protected  void assertValid()
           
 void clearData()
          Removes all mappings from the node's data map.
 void clearDataDirect()
          Functionally the same as Node.clearData() except that it operates directly on the node and bypasses the interceptor chain.
 int dataSize()
           
 V get(K key)
          Returns the value to which this node maps the specified key.
 CacheSPI<K,V> getCache()
          Retrieves a reference to the cache in which this Node resides.
 Node<K,V> getChild(Fqn<?> f)
          Returns the child node
 Node<K,V> getChild(Object name)
           
 NodeSPI<K,V> getChildDirect(Fqn childName)
          Retrives a child directly by fully qualified name.
 NodeSPI<K,V> getChildDirect(Object childName)
          Retrives a child directly by name.
 Set<Node<K,V>> getChildren()
          Returns an immutable set of children nodes.
 Set<NodeSPI<K,V>> getChildrenDirect()
          Functionally the same as Node.getChildren() except that it operates directly on the node and bypasses the interceptor chain.
 Set<NodeSPI<K,V>> getChildrenDirect(boolean includeMarkedAsDeleted)
          Retrieves children (directly), optionally including any marked as deleted nodes.
 Map<Object,Node<K,V>> getChildrenMapDirect()
          Returns a map to access the raw children.
 Set<Object> getChildrenNames()
          Returns an immutable set of children node names.
 Set<Object> getChildrenNamesDirect()
          Functionally the same as Node.getChildrenNames() except that it operates directly on the node and bypasses the interceptor chain.
 Map<K,V> getData()
          Returns a map containing the data in this Node.
 Map<K,V> getDataDirect()
          Functionally the same as Node.getData() except that it operates directly on the node and bypasses the interceptor chain.
 Object getDelegationTarget()
           
 V getDirect(K key)
          Functionally the same as Node.get(Object) except that it operates directly on the node and bypasses the interceptor chain.
 Fqn getFqn()
          Returns the Fqn which represents the location of this Node in the cache structure.
 Map getInternalState(boolean onlyInternalState)
          Very similar to NodeSPI.getDataDirect(), except that this method may also encode some internal data as attributes in the map, using special _JBOSS_INTERNAL_XXX Strings as keys.
 Set<K> getKeys()
          Returns a Set containing the data in this Node.
 Set<K> getKeysDirect()
          Functionally the same as Node.getKeys() except that it operates directly on the node and bypasses the interceptor chain.
 NodeLock getLock()
          Returns a lock for this node.
 NodeSPI<K,V> getOrCreateChild(Object name, GlobalTransaction tx)
          Returns an existing child or creates a new one using a global transaction.
 NodeSPI<K,V> getParent()
          Returns the parent node.
 DataVersion getVersion()
          Returns the data version of this node if versioning is supported.
 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 hasChildrenDirect()
           
 void injectDependencies(CacheSPI spi)
           
 boolean isChildrenLoaded()
          Returns true if the children of this node were loaded from a cache loader.
 boolean isDataLoaded()
          Returns true if the data was loaded from the cache loader.
 boolean isDeleted()
          Returns true if the instance has been deleted in the current transaction.
 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.
 void markAsDeleted(boolean marker)
          Marks the node as being deleted (or not) in the current transaction.
 void markAsDeleted(boolean marker, boolean recursive)
          Same as NodeSPI.markAsDeleted(boolean) except that the option to recurse into children is provided.
 void print(StringBuffer sb, int indent)
          Prints basic information of this node to the StringBuffer passed in.
 void printDetails(StringBuffer sb, int indent)
          Prints details of this node to the StringBuffer passed in.
 V put(K key, V value)
          Associates the specified value with the specified key for this node.
 void putAll(Map<K,V> data)
          Copies all of the mappings from the specified map to this node's map.
 void putAllDirect(Map<K,V> data)
          Functionally the same as Node.putAll(Map) except that it operates directly on the node and bypasses the interceptor chain.
 V putDirect(K key, V value)
          Functionally the same as Node.put(Object,Object) except that it operates directly on the node and bypasses the interceptor chain.
 V putIfAbsent(K k, V v)
          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.
 boolean removeChildDirect(Fqn fqn)
          Removes a child directly from a node.
 boolean removeChildDirect(Object childName)
          Removes a child directly from a node.
 void removeChildrenDirect()
          Directly removes all children for this node.
 V removeDirect(K key)
          Removes a data key directly from a node.
 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> data)
          Similar to Node.putAll(java.util.Map) except that it removes any entries that exists in the data map first.
 void setChildrenLoaded(boolean loaded)
          Sets if the children of this node were loaded from a cache loader.
 void setChildrenMapDirect(Map<Object,Node<K,V>> children)
          Sets the node's children explictly.
 void setDataLoaded(boolean dataLoaded)
          Sets if the data was loaded from the cache loader.
 void setFqn(Fqn<?> f)
          Sets the FQN of this node and resets the names of all children as well.
 void setInternalState(Map state)
          Very similar to NodeSPI.putAllDirect(java.util.Map) except that this method first scans the map for any internal attributes using special _JBOSS_INTERNAL_XXX Strings as keys, and uses these to set internal attributes before passing the remaining attributes to NodeSPI.putAllDirect(java.util.Map).
 void setLockForChildInsertRemove(boolean lockForChildInsertRemove)
          Configures the behaviour of how this node is locked when adding/removing children.
 void setResident(boolean resident)
           
 void setValid(boolean valid, boolean recursive)
          Sets the validity of a node.
 void setVersion(DataVersion version)
          Sets the data version of this node if versioning is supported.
 String toString()
           
 
Methods inherited from class org.jboss.cache.invocation.AbstractInvocationDelegate
assertIsConstructed, initialize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NodeInvocationDelegate

public NodeInvocationDelegate(UnversionedNode node)
Method Detail

getDelegationTarget

public Object getDelegationTarget()

injectDependencies

public void injectDependencies(CacheSPI spi)

isChildrenLoaded

public boolean isChildrenLoaded()
Description copied from interface: NodeSPI
Returns true if the children of this node were loaded from a cache loader.

Specified by:
isChildrenLoaded in interface NodeSPI<K,V>
Returns:
true if the children of this node were loaded from a cache loader.

setChildrenLoaded

public void setChildrenLoaded(boolean loaded)
Description copied from interface: NodeSPI
Sets if the children of this node were loaded from a cache loader.

Specified by:
setChildrenLoaded in interface NodeSPI<K,V>
Parameters:
loaded - true if loaded, false otherwise

isDataLoaded

public boolean isDataLoaded()
Description copied from interface: NodeSPI
Returns true if the data was loaded from the cache loader.

Specified by:
isDataLoaded in interface NodeSPI<K,V>
Returns:
true if the data was loaded from the cache loader.

setDataLoaded

public void setDataLoaded(boolean dataLoaded)
Description copied from interface: NodeSPI
Sets if the data was loaded from the cache loader.

Specified by:
setDataLoaded in interface NodeSPI<K,V>
Parameters:
dataLoaded - true if loaded, false otherwise

getChildrenMapDirect

public Map<Object,Node<K,V>> getChildrenMapDirect()
Description copied from interface: NodeSPI
Returns a map to access the raw children. This method may return a null if the node does not have any children. It is important to note that this method returns a direct reference to the underlying child map and is intended for internal use only. Incorrect use may result in very inconsistent state of the cache.

Specified by:
getChildrenMapDirect in interface NodeSPI<K,V>
Returns:
Map, keyed by child name, values Nodes.

setChildrenMapDirect

public void setChildrenMapDirect(Map<Object,Node<K,V>> children)
Description copied from interface: NodeSPI
Sets the node's children explictly. This method will remove all children currently associated with this node and add all the children passed in.

Specified by:
setChildrenMapDirect in interface NodeSPI<K,V>
Parameters:
children - cannot be null

getOrCreateChild

public NodeSPI<K,V> getOrCreateChild(Object name,
                                     GlobalTransaction tx)
Description copied from interface: NodeSPI
Returns an existing child or creates a new one using a global transaction.

Specified by:
getOrCreateChild in interface NodeSPI<K,V>
Parameters:
name - name of child to create
tx - transaction under which to create child
Returns:
newly created node

getLock

public NodeLock getLock()
Description copied from interface: NodeSPI
Returns a lock for this node.

Specified by:
getLock in interface NodeSPI<K,V>
Returns:
node lock

setFqn

public void setFqn(Fqn<?> f)
Description copied from interface: NodeSPI
Sets the FQN of this node and resets the names of all children as well.

Specified by:
setFqn in interface NodeSPI<K,V>
Parameters:
f - fqn to set

isDeleted

public boolean isDeleted()
Description copied from interface: NodeSPI
Returns true if the instance has been deleted in the current transaction.

Specified by:
isDeleted in interface NodeSPI<K,V>
Returns:
true if the instance has been deleted in the current transaction.

markAsDeleted

public void markAsDeleted(boolean marker)
Description copied from interface: NodeSPI
Marks the node as being deleted (or not) in the current transaction. This is not recursive, child nodes are not affected.

Specified by:
markAsDeleted in interface NodeSPI<K,V>
Parameters:
marker - true if the node has been deleted, false if not.

markAsDeleted

public void markAsDeleted(boolean marker,
                          boolean recursive)
Description copied from interface: NodeSPI
Same as NodeSPI.markAsDeleted(boolean) except that the option to recurse into children is provided.

Specified by:
markAsDeleted in interface NodeSPI<K,V>
Parameters:
marker - true if the node has been deleted, false if not.
recursive - if true, child nodes (and their children) are marked as well.

addChild

public void addChild(Object nodeName,
                     Node<K,V> nodeToAdd)
Description copied from interface: NodeSPI
Adds or replaces a child by name.

Specified by:
addChild in interface NodeSPI<K,V>
Parameters:
nodeName - child node name (not an FQN)
nodeToAdd - child node

printDetails

public void printDetails(StringBuffer sb,
                         int indent)
Description copied from interface: NodeSPI
Prints details of this node to the StringBuffer passed in.

Specified by:
printDetails in interface NodeSPI<K,V>
Parameters:
sb - StringBuffer to print to
indent - depth of this node in the tree. Used to indent details by prepending spaces.

print

public void print(StringBuffer sb,
                  int indent)
Description copied from interface: NodeSPI
Prints basic information of this node to the StringBuffer passed in.

Specified by:
print in interface NodeSPI<K,V>
Parameters:
sb - StringBuffer to print to
indent - depth of this node in the tree. Used to indent details by prepending spaces.

setVersion

public void setVersion(DataVersion version)
Description copied from interface: NodeSPI
Sets the data version of this node if versioning is supported.

Specified by:
setVersion in interface NodeSPI<K,V>
Parameters:
version - data version to apply

getVersion

public DataVersion getVersion()
Description copied from interface: NodeSPI
Returns the data version of this node if versioning is supported.

Specified by:
getVersion in interface NodeSPI<K,V>
Returns:
data version

getChildrenDirect

public Set<NodeSPI<K,V>> getChildrenDirect()
Description copied from interface: NodeSPI
Functionally the same as Node.getChildren() except that it operates directly on the node and bypasses the interceptor chain.

The caller needs to ensure a proper lock has been obtained prior to calling this method, otherwise a LockingException will be thrown.

Specified by:
getChildrenDirect in interface NodeSPI<K,V>
Returns:
set of child nodes.
See Also:
Node.getChildren()

removeChildrenDirect

public void removeChildrenDirect()
Description copied from interface: NodeSPI
Directly removes all children for this node. The only direct method that does not have a non-direct counterpart.

Specified by:
removeChildrenDirect in interface NodeSPI<K,V>

getChildrenDirect

public Set<NodeSPI<K,V>> getChildrenDirect(boolean includeMarkedAsDeleted)
Description copied from interface: NodeSPI
Retrieves children (directly), optionally including any marked as deleted nodes.

The caller needs to ensure a proper lock has been obtained prior to calling this method.

Specified by:
getChildrenDirect in interface NodeSPI<K,V>
Parameters:
includeMarkedAsDeleted - if true, the returned set will include nodes marked as deleted
Returns:
a set of nodes

getChildDirect

public NodeSPI<K,V> getChildDirect(Object childName)
Description copied from interface: NodeSPI
Retrives a child directly by name. Functionally the same as Node.getChild(Object) except that it bypasses the interceptor chain.

The caller needs to ensure a proper lock has been obtained prior to calling this method.

Specified by:
getChildDirect in interface NodeSPI<K,V>
Parameters:
childName - name of child
Returns:
child node
See Also:
Node.getChild(Object)

addChildDirect

public NodeSPI<K,V> addChildDirect(Fqn childName)
Description copied from interface: NodeSPI
Adds a child directly to a Node. Functionally the same as Node.addChild(Fqn) except that it bypasses the interceptor chain.

The caller needs to ensure a proper lock has been obtained prior to calling this method.

Specified by:
addChildDirect in interface NodeSPI<K,V>
Parameters:
childName - name of child
Returns:
child node
See Also:
Node.addChild(Fqn)

addChildDirect

public NodeSPI<K,V> addChildDirect(Fqn f,
                                   boolean notify)
Description copied from interface: NodeSPI
Same as NodeSPI.addChildDirect(Fqn) except that it optionally allows you to suppress notification events for the creation of this node.

Specified by:
addChildDirect in interface NodeSPI<K,V>
Parameters:
f - name of child
notify - if true, notification events are sent; if false, they are not
Returns:
child node
See Also:
Node.addChild(Fqn)

addChildDirect

public NodeSPI<K,V> addChildDirect(Object childName,
                                   boolean notify)
Description copied from interface: NodeSPI
Same as NodeSPI.addChildDirect(Fqn, boolean) except that it just takes a child name

Specified by:
addChildDirect in interface NodeSPI<K,V>
Parameters:
childName - name of child
notify - if true, notification events are sent; if false, they are not
Returns:
child node
See Also:
Node.addChild(Fqn)

addChildDirect

public void addChildDirect(NodeSPI<K,V> child)
Description copied from interface: NodeSPI
Directly adds the node passed in to the children map of the current node. Will throw a CacheException if child.getFqn().getParent().equals(getFqn()) returns false.

Specified by:
addChildDirect in interface NodeSPI<K,V>
Parameters:
child - child to add

getChildDirect

public NodeSPI<K,V> getChildDirect(Fqn childName)
Description copied from interface: NodeSPI
Retrives a child directly by fully qualified name. Functionally the same as Node.getChild(Fqn) except that it bypasses the interceptor chain.

The caller needs to ensure a proper lock has been obtained prior to calling this method.

Specified by:
getChildDirect in interface NodeSPI<K,V>
Parameters:
childName - name of child
Returns:
child node
See Also:
Node.getChild(Fqn)

removeChildDirect

public boolean removeChildDirect(Fqn fqn)
Description copied from interface: NodeSPI
Removes a child directly from a node. Functionally the same as Node.removeChild(Fqn) except that it bypasses the interceptor chain.

The caller needs to ensure a proper lock has been obtained prior to calling this method, otherwise a

Specified by:
removeChildDirect in interface NodeSPI<K,V>
Parameters:
fqn - of child.
Returns:
true if the node was found, false otherwise
See Also:
Node.removeChild(Fqn)

removeChildDirect

public boolean removeChildDirect(Object childName)
Description copied from interface: NodeSPI
Removes a child directly from a node. Functionally the same as Node.removeChild(Object) except that bypasses the interceptor chain.

The caller needs to ensure a proper lock has been obtained prior to calling this method.

Specified by:
removeChildDirect in interface NodeSPI<K,V>
Parameters:
childName - of child.
Returns:
true if the node was found, false otherwise
See Also:
Node.removeChild(Object)

removeDirect

public V removeDirect(K key)
Description copied from interface: NodeSPI
Removes a data key directly from a node. Functionally the same as Node.remove(Object) except that it bypasses the interceptor chain.

The caller needs to ensure a proper lock has been obtained prior to calling this method.

Specified by:
removeDirect in interface NodeSPI<K,V>
Parameters:
key - to remove
Returns:
the old data contained under the key
See Also:
Node.remove(Object)

putDirect

public V putDirect(K key,
                   V value)
Description copied from interface: NodeSPI
Functionally the same as Node.put(Object,Object) except that it operates directly on the node and bypasses the interceptor chain.

The caller needs to ensure a proper lock has been obtained prior to calling this method, otherwise a LockingException will be thrown.

Specified by:
putDirect in interface NodeSPI<K,V>
Parameters:
key - of data
value - of data
Returns:
the previous value under the key passed in, or null
See Also:
Node.put(Object,Object)

putAllDirect

public void putAllDirect(Map<K,V> data)
Description copied from interface: NodeSPI
Functionally the same as Node.putAll(Map) except that it operates directly on the node and bypasses the interceptor chain.

The caller needs to ensure a proper lock has been obtained prior to calling this method, otherwise a LockingException will be thrown.

Specified by:
putAllDirect in interface NodeSPI<K,V>
Parameters:
data - to put
See Also:
Node.putAll(Map)

getDataDirect

public Map<K,V> getDataDirect()
Description copied from interface: NodeSPI
Functionally the same as Node.getData() except that it operates directly on the node and bypasses the interceptor chain.

Note that this returns a reference to access the node's data. This data should only be modified by the cache itself. This method should never return null.

The caller needs to ensure a proper lock has been obtained prior to calling this method, otherwise a LockingException will be thrown.

Specified by:
getDataDirect in interface NodeSPI<K,V>
Returns:
map containing data
See Also:
Node.getData()

getDirect

public V getDirect(K key)
Description copied from interface: NodeSPI
Functionally the same as Node.get(Object) except that it operates directly on the node and bypasses the interceptor chain.

The caller needs to ensure a proper lock has been obtained prior to calling this method, otherwise a LockingException will be thrown.

Specified by:
getDirect in interface NodeSPI<K,V>
Parameters:
key - data to get
Returns:
value under key
See Also:
Node.get(Object)

clearDataDirect

public void clearDataDirect()
Description copied from interface: NodeSPI
Functionally the same as Node.clearData() except that it operates directly on the node and bypasses the interceptor chain.

The caller needs to ensure a proper lock has been obtained prior to calling this method, otherwise a LockingException will be thrown.

Specified by:
clearDataDirect in interface NodeSPI<K,V>
See Also:
Node.clearData()

getKeysDirect

public Set<K> getKeysDirect()
Description copied from interface: NodeSPI
Functionally the same as Node.getKeys() except that it operates directly on the node and bypasses the interceptor chain.

The caller needs to ensure a proper lock has been obtained prior to calling this method, otherwise a LockingException will be thrown.

Specified by:
getKeysDirect in interface NodeSPI<K,V>
Returns:
set of keys
See Also:
Node.getKeys()

getChildrenNamesDirect

public Set<Object> getChildrenNamesDirect()
Description copied from interface: NodeSPI
Functionally the same as Node.getChildrenNames() except that it operates directly on the node and bypasses the interceptor chain.

The caller needs to ensure a proper lock has been obtained prior to calling this method, otherwise a LockingException will be thrown.

Specified by:
getChildrenNamesDirect in interface NodeSPI<K,V>
Returns:
set of children names
See Also:
Node.getChildrenNames()

getCache

public CacheSPI<K,V> getCache()
Description copied from interface: NodeSPI
Retrieves a reference to the cache in which this Node resides.

Specified by:
getCache in interface NodeSPI<K,V>
Returns:
a cache

getParent

public NodeSPI<K,V> getParent()
Description copied from interface: Node
Returns the parent node. If this is the root node, this method returns null.

Specified by:
getParent in interface Node<K,V>
Specified by:
getParent in interface NodeSPI<K,V>
Returns:
the parent node, or null if this is the root node
See Also:
Node.getParent()

getChildren

public Set<Node<K,V>> getChildren()
Description copied from interface: Node
Returns an immutable set of children nodes.

Specified by:
getChildren in interface Node<K,V>
Returns:
an immutable Set of child nodes. Empty Set if there aren't any children.

getChildrenNames

public Set<Object> getChildrenNames()
Description copied from interface: Node
Returns an immutable set of children node names.

Specified by:
getChildrenNames in interface Node<K,V>
Returns:
an immutable Set of child node names. Empty Set if there aren't any children.

getData

public Map<K,V> getData()
Description copied from interface: Node
Returns a map containing the data in this Node.

Specified by:
getData in interface Node<K,V>
Returns:
a Map containing the data in this Node. If there is no data, an empty Map is returned. The Map returned is always immutable.

getKeys

public Set<K> getKeys()
Description copied from interface: Node
Returns a Set containing the data in this Node.

Specified by:
getKeys in interface Node<K,V>
Returns:
a Set containing the data in this Node. If there is no data, an empty Set is returned. The Set returned is always immutable.

getFqn

public Fqn getFqn()
Description copied from interface: Node
Returns the Fqn which represents the location of this Node in the cache structure. The Fqn returned is absolute.

Specified by:
getFqn in interface Node<K,V>
Returns:
The Fqn which represents the location of this Node in the cache structure. The Fqn returned is absolute.

addChild

public Node<K,V> addChild(Fqn<?> f)
Description copied from interface: Node
Adds a child node with the given 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.

Specified by:
addChild in interface Node<K,V>
Parameters:
f - Fqn of the child node, relative to the current node.
Returns:
the newly created node, or the existing node if one already exists.

removeChild

public boolean removeChild(Fqn<?> f)
Description copied from interface: Node
Removes a child node specified by the given relative Fqn.

If you wish to remove children based on absolute Fqns, use the Cache interface instead.

Specified by:
removeChild in interface Node<K,V>
Parameters:
f - Fqn of the child node, relative to the current node.
Returns:
true if the node was found and removed, false otherwise

removeChild

public boolean removeChild(Object childName)
Description copied from interface: Node
Removes a child node specified by the given name.

Specified by:
removeChild in interface Node<K,V>
Parameters:
childName - name of the child node, directly under the current node.
Returns:
true if the node was found and removed, false otherwise

getChild

public Node<K,V> getChild(Fqn<?> f)
Description copied from interface: Node
Returns the child node

Specified by:
getChild in interface Node<K,V>
Parameters:
f - Fqn of the child node
Returns:
null if the child does not exist.

getChild

public Node<K,V> getChild(Object name)
Specified by:
getChild in interface Node<K,V>
Parameters:
name - name of the child
Returns:
a direct child of the current node.

put

public V put(K key,
             V value)
Description copied from interface: Node
Associates the specified value with the specified key for this node. If this node previously contained a mapping for this key, the old value is replaced by the specified value.

Specified by:
put in interface Node<K,V>
Parameters:
key - key with which the specified value is to be associated.
value - value to be associated with the specified key.
Returns:
Returns the old value contained under this key. Null if key doesn't exist.

putIfAbsent

public V putIfAbsent(K k,
                     V v)
Description copied from interface: Node
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.

Equivalent to calling

   if (!node.getKeys().contains(key))
     return node.put(key, value);
   else
     return node.get(key);
 

except that this is atomic.

Specified by:
putIfAbsent in interface Node<K,V>
Parameters:
k - key with which the specified value is to be associated.
v - value to be associated with the specified key.
Returns:
previous value associated with specified key, or null if there was no mapping for key.

replace

public V replace(K key,
                 V value)
Description copied from interface: Node
Replace entry for key only if currently mapped to some value. Acts as
 if ((node.getKeys().contains(key))
 {
     return node.put(key, value);
 }
 else
     return null;
 

except that this is atomic.

Specified by:
replace in interface Node<K,V>
Parameters:
key - key with which the specified value is associated.
value - value to be associated with the specified key.
Returns:
previous value associated with specified key, or null if there was no mapping for key.

replace

public boolean replace(K key,
                       V oldValue,
                       V newValue)
Description copied from interface: Node
Replace entry for key only if currently mapped to given value. Acts as
 if (node.get(key).equals(oldValue))
 {
     node.putAll(key, newValue);
     return true;
 }
 else
     return false;
 

except that this is atomic.

Specified by:
replace in interface Node<K,V>
Parameters:
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.
Returns:
true if the value was replaced

putAll

public void putAll(Map<K,V> data)
Description copied from interface: Node
Copies all of the mappings from the specified map to this node's map. If any data exists, existing keys are overwritten with the keys in the new map. The behavior is equivalent to:
 Node node;
 for (Map.Entry me : map.entrySet())
   node.put(me.getKey(), me.getValue());
 

Specified by:
putAll in interface Node<K,V>
Parameters:
data - map to copy from

replaceAll

public void replaceAll(Map<K,V> data)
Description copied from interface: Node
Similar to Node.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 Node.clearData() followed by a Node.putAll(java.util.Map) in the same transaction.

Specified by:
replaceAll in interface Node<K,V>
Parameters:
data - map to copy from

get

public V get(K key)
Description copied from interface: Node
Returns the value to which this node maps the specified key. Returns null if the node contains no mapping for this key.

Specified by:
get in interface Node<K,V>
Parameters:
key - key of the data to return
Returns:
the value to which this node maps the specified key, or null if the map contains no mapping for this key

remove

public V remove(K key)
Description copied from interface: Node
Removes the mapping for this key from this node if it is present. Returns the value to which the node previously associated the key, or null if the node contained no mapping for this key

Specified by:
remove in interface Node<K,V>
Parameters:
key - key whose mapping is to be removed
Returns:
previous value associated with specified key, or null if there was no mapping for key

clearData

public void clearData()
Description copied from interface: Node
Removes all mappings from the node's data map.

Specified by:
clearData in interface Node<K,V>

dataSize

public int dataSize()
Specified by:
dataSize in interface Node<K,V>
Returns:
the number of elements (key/value pairs) in the node's data map.

hasChild

public boolean hasChild(Fqn<?> f)
Description copied from interface: Node
Returns true if the child node denoted by the relative Fqn passed in exists.

Specified by:
hasChild in interface Node<K,V>
Parameters:
f - Fqn relative to the current node of the child you are testing the existence of.
Returns:
true if the child node denoted by the relative Fqn passed in exists.

hasChild

public boolean hasChild(Object o)
Description copied from interface: Node
Returns true if the child node denoted by the Object name passed in exists.

Specified by:
hasChild in interface Node<K,V>
Parameters:
o - name of the child, relative to the current node
Returns:
true if the child node denoted by the name passed in exists.

isValid

public boolean isValid()
Description copied from interface: Node
Tests if a node reference is still valid. A node reference may become invalid if it has been removed, invalidated or moved, either locally or remotely. If a node is invalid, it should be fetched again from the cache or a valid parent node. Operations on invalid nodes will throw a NodeNotValidException.

Specified by:
isValid in interface Node<K,V>
Returns:
true if the node is valid.

isResident

public boolean isResident()
Description copied from interface: Node
Nodes marked resident would be ignored by the eviction algorithms. E.g. if the algorithm is "keep LRU 10 nodes" - the resident nodes won't be counted within those 10 nodes, and also won't be evicted when the threshold is reached. N.B. calling this method won't have any effect on node's eviction, e.g. we won't consider this node as being 'used' in a LRU scenario. If the cache is used in a replicated environment then the resident property is NOT replicated across the cluster. Also the property is not transactionable.

Specified by:
isResident in interface Node<K,V>

setResident

public void setResident(boolean resident)
Specified by:
setResident in interface Node<K,V>
See Also:
Node.isResident()

isLockForChildInsertRemove

public boolean isLockForChildInsertRemove()
Description copied from interface: Node
Tests whether this node is configured to be exclusively locked when inserting or removing children.

The default value for this is what is configured in the LockParentForChildInsertRemove configuration property, programatically reachable by querying Configuration.isLockParentForChildInsertRemove()

This can also be configured on a per-node basis using Node.setLockForChildInsertRemove(boolean)

Specified by:
isLockForChildInsertRemove in interface Node<K,V>
Returns:
true if the node is configured to be exclusively locked for child insertions and removal, false otherwise.

setLockForChildInsertRemove

public void setLockForChildInsertRemove(boolean lockForChildInsertRemove)
Description copied from interface: Node
Configures the behaviour of how this node is locked when adding/removing children.

Specified by:
setLockForChildInsertRemove in interface Node<K,V>
Parameters:
lockForChildInsertRemove - if true, exclusive locks will be obtained when children are added/removed. If false, a shared "read lock" will be obtained instead.

releaseObjectReferences

public void releaseObjectReferences(boolean recursive)
Description copied from interface: Node
Method that releases object references of cached objects held in the cache by serializing them to byte buffers. Cached objects are lazily deserialized when accessed again, based on the calling thread's context class loader.

This can be expensive, based on the effort required to serialize cached objects.

Specified by:
releaseObjectReferences in interface Node<K,V>
Parameters:
recursive - if true, child nodes will have their object references released as well.

hasChildrenDirect

public boolean hasChildrenDirect()
Specified by:
hasChildrenDirect in interface NodeSPI<K,V>
Returns:
true if the node has one or more child nodes; false otherwise.

getInternalState

public Map getInternalState(boolean onlyInternalState)
Description copied from interface: NodeSPI
Very similar to NodeSPI.getDataDirect(), except that this method may also encode some internal data as attributes in the map, using special _JBOSS_INTERNAL_XXX Strings as keys. Designed to be used by StateTransferGenerator and CacheStoreInterceptor which attempt to serialize nodes into a stream for storage or transfer.

Specified by:
getInternalState in interface NodeSPI<K,V>
Parameters:
onlyInternalState - if true, the map will only contain internal state and no other data.
Returns:
a map containing data as well as additional information about this node.

setInternalState

public void setInternalState(Map state)
Description copied from interface: NodeSPI
Very similar to NodeSPI.putAllDirect(java.util.Map) except that this method first scans the map for any internal attributes using special _JBOSS_INTERNAL_XXX Strings as keys, and uses these to set internal attributes before passing the remaining attributes to NodeSPI.putAllDirect(java.util.Map). Designed to be used by StateTransferIntegrator and CacheLoaderInterceptor classes which attempt to create nodes based on a data stream.

Specified by:
setInternalState in interface NodeSPI<K,V>
Parameters:
state - state to be applied

setValid

public void setValid(boolean valid,
                     boolean recursive)
Description copied from interface: NodeSPI
Sets the validity of a node. By default, all nodes are valid unless they are deleted, invalidated or moved, either locally or remotely. To be used in conjunction with Node.isValid().

Specified by:
setValid in interface NodeSPI<K,V>
Parameters:
valid - if true, the node is marked as valid; if false, the node is invalid.
recursive - if true, the validity flag passed in is applied to all children as well.

assertValid

protected void assertValid()

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2008 JBoss, a division of Red Hat. All Rights Reserved.