public class NodeInvocationDelegate<K,V> extends AbstractInvocationDelegate implements NodeSPI<K,V>
| Modifier and Type | Field and Description |
|---|---|
protected InternalNode<K,V> |
node |
componentRegistry, configuration, invocationContextContainer, invoker, originLocal| Constructor and Description |
|---|
NodeInvocationDelegate(InternalNode<K,V> node) |
| Modifier and Type | Method and Description |
|---|---|
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. |
void |
commitUpdate(InvocationContext ctx,
DataContainer container)
Commits any updates made on this node to the underlying data structure, making it visible to all other transactions.
|
boolean |
containsKeyDirect(K key)
Returns true if a mapping exists for this key.
|
int |
dataSize() |
boolean |
equals(Object o) |
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. |
InternalNode |
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()
|
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()
|
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.
|
NodeSPI<K,V> |
getParentDirect()
Returns the parent node as a
NodeSPI, instead
of Node from Node.getParent(), and is otherwise identical. |
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() |
int |
hashCode() |
void |
injectDependencies(CacheSPI<K,V> spi) |
boolean |
isChanged()
Only used with MVCC.
|
boolean |
isChildrenLoaded()
Returns true if the children of this node were loaded from a cache loader.
|
boolean |
isCreated()
Only used with MVCC.
|
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 |
isLeaf() |
boolean |
isLockForChildInsertRemove()
Tests whether this node is configured to be exclusively locked when inserting or removing children.
|
boolean |
isNullNode() |
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 |
markForUpdate(DataContainer container,
boolean writeSkewCheck)
Marks a node for updating.
|
void |
print(StringBuilder sb,
int indent)
Prints basic information of this node to the StringBuilder passed in.
|
void |
printDetails(StringBuilder sb,
int indent)
Prints details of this node to the StringBuilder passed in.
|
V |
put(K key,
V value)
Associates the specified value with the specified key for this node.
|
void |
putAll(Map<? extends K,? extends V> data)
Copies all of the mappings from the specified map to this node's map.
|
void |
putAllDirect(Map<? extends K,? extends 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<? extends K,? extends V> data)
Similar to
Node.putAll(java.util.Map) except that it removes any entries that exists in
the data map first. |
void |
rollbackUpdate()
Rolls back any changes made to a node.
|
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 |
setCreated(boolean b)
Sets the created flag on a node.
|
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() |
assertIsConstructed, initializeprotected volatile InternalNode<K,V> node
public NodeInvocationDelegate(InternalNode<K,V> node)
public InternalNode getDelegationTarget()
getDelegationTarget in interface NodeSPI<K,V>public boolean isChildrenLoaded()
NodeSPIisChildrenLoaded in interface NodeSPI<K,V>public void setChildrenLoaded(boolean loaded)
NodeSPIsetChildrenLoaded in interface NodeSPI<K,V>loaded - true if loaded, false otherwisepublic boolean isDataLoaded()
NodeSPIisDataLoaded in interface NodeSPI<K,V>public void setDataLoaded(boolean dataLoaded)
NodeSPIsetDataLoaded in interface NodeSPI<K,V>dataLoaded - true if loaded, false otherwisepublic Map<Object,Node<K,V>> getChildrenMapDirect()
NodeSPIgetChildrenMapDirect in interface NodeSPI<K,V>public void setChildrenMapDirect(Map<Object,Node<K,V>> children)
NodeSPIsetChildrenMapDirect in interface NodeSPI<K,V>children - cannot be nullpublic NodeSPI<K,V> getOrCreateChild(Object name, GlobalTransaction tx)
NodeSPIgetOrCreateChild in interface NodeSPI<K,V>name - name of child to createtx - transaction under which to create childpublic NodeLock getLock()
NodeSPIpublic void setFqn(Fqn f)
NodeSPIpublic boolean isDeleted()
NodeSPIpublic void markAsDeleted(boolean marker)
NodeSPImarkAsDeleted in interface NodeSPI<K,V>marker - true if the node has been deleted, false if not.public void markAsDeleted(boolean marker,
boolean recursive)
NodeSPINodeSPI.markAsDeleted(boolean) except that the option to recurse into children is provided.markAsDeleted in interface NodeSPI<K,V>marker - true if the node has been deleted, false if not.recursive - if true, child nodes (and their children) are marked as well.public void addChild(Object nodeName, Node<K,V> nodeToAdd)
NodeSPIpublic void printDetails(StringBuilder sb, int indent)
NodeSPIprintDetails in interface NodeSPI<K,V>sb - StringBuilder to print toindent - depth of this node in the tree. Used to indent details by prepending spaces.public void print(StringBuilder sb, int indent)
NodeSPIpublic void setVersion(DataVersion version)
NodeSPIsetVersion in interface NodeSPI<K,V>version - data version to applypublic DataVersion getVersion()
NodeSPIgetVersion in interface NodeSPI<K,V>public Set<NodeSPI<K,V>> getChildrenDirect()
NodeSPINode.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.
getChildrenDirect in interface NodeSPI<K,V>Node.getChildren()public void removeChildrenDirect()
NodeSPIremoveChildrenDirect in interface NodeSPI<K,V>public Set<NodeSPI<K,V>> getChildrenDirect(boolean includeMarkedAsDeleted)
NodeSPIgetChildrenDirect in interface NodeSPI<K,V>includeMarkedAsDeleted - if true, the returned set will include nodes marked as deletedpublic NodeSPI<K,V> getChildDirect(Object childName)
NodeSPINode.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.getChildDirect in interface NodeSPI<K,V>childName - name of childNode.getChild(Object)public NodeSPI<K,V> addChildDirect(Fqn childName)
NodeSPINode.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.addChildDirect in interface NodeSPI<K,V>childName - name of childNode.addChild(Fqn)public NodeSPI<K,V> addChildDirect(Fqn f, boolean notify)
NodeSPINodeSPI.addChildDirect(Fqn) except that it optionally allows you to suppress notification events for
the creation of this node.addChildDirect in interface NodeSPI<K,V>f - name of childnotify - if true, notification events are sent; if false, they are notNode.addChild(Fqn)public NodeSPI<K,V> addChildDirect(Object childName, boolean notify)
NodeSPINodeSPI.addChildDirect(Fqn, boolean) except that it just takes a child nameaddChildDirect in interface NodeSPI<K,V>childName - name of childnotify - if true, notification events are sent; if false, they are notNode.addChild(Fqn)public void addChildDirect(NodeSPI<K,V> child)
NodeSPIaddChildDirect in interface NodeSPI<K,V>child - child to addpublic NodeSPI<K,V> getChildDirect(Fqn childName)
NodeSPINode.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.getChildDirect in interface NodeSPI<K,V>childName - name of childNode.getChild(Fqn)public boolean removeChildDirect(Fqn fqn)
NodeSPINode.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 aremoveChildDirect in interface NodeSPI<K,V>fqn - of child.Node.removeChild(Fqn)public boolean removeChildDirect(Object childName)
NodeSPINode.removeChild(Object) except that bypasses the
interceptor chain.
The caller needs to ensure a proper lock has been obtained prior to calling this method.removeChildDirect in interface NodeSPI<K,V>childName - of child.Node.removeChild(Object)public V removeDirect(K key)
NodeSPINode.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.removeDirect in interface NodeSPI<K,V>key - to removeNode.remove(Object)public V putDirect(K key, V value)
NodeSPINode.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.
putDirect in interface NodeSPI<K,V>key - of datavalue - of dataNode.put(Object,Object)public void putAllDirect(Map<? extends K,? extends V> data)
NodeSPINode.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.
putAllDirect in interface NodeSPI<K,V>data - to putNode.putAll(Map)public Map<K,V> getDataDirect()
NodeSPINode.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.
getDataDirect in interface NodeSPI<K,V>Node.getData()public V getDirect(K key)
NodeSPINode.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.
getDirect in interface NodeSPI<K,V>key - data to getNode.get(Object)public void clearDataDirect()
NodeSPINode.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.
clearDataDirect in interface NodeSPI<K,V>Node.clearData()public boolean containsKeyDirect(K key)
NodeSPIcontainsKeyDirect in interface NodeSPI<K,V>key - The key checked for inclusion in the node data.public Set<K> getKeysDirect()
NodeSPINode.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.
getKeysDirect in interface NodeSPI<K,V>Node.getKeys()public Set<Object> getChildrenNamesDirect()
NodeSPINode.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.
getChildrenNamesDirect in interface NodeSPI<K,V>Node.getChildrenNames()public CacheSPI<K,V> getCache()
NodeSPIpublic NodeSPI<K,V> getParent()
Nodenull.public NodeSPI<K,V> getParentDirect()
NodeSPINodeSPI, instead
of Node from Node.getParent(), and is otherwise identical.getParentDirect in interface NodeSPI<K,V>Node.getParent()public Set<Node<K,V>> getChildren()
Nodepublic Set<Object> getChildrenNames()
Nodepublic boolean isLeaf()
public Map<K,V> getData()
NodeNode.public Node<K,V> addChild(Fqn f)
NodeFqn 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.public boolean removeChild(Fqn f)
NodeFqn.
If you wish to remove children based on absolute Fqns, use the Cache interface instead.removeChild in interface Node<K,V>f - Fqn of the child node, relative to the current node.public boolean removeChild(Object childName)
NoderemoveChild in interface Node<K,V>childName - name of the child node, directly under the current node.public Node<K,V> getChild(Fqn f)
Nodepublic Node<K,V> getChild(Object name)
getChild in interface Node<K,V>name - name of the child. Note that passing in a String of "/a/b/c" will not return a node called 'c',
3 nodes deep. Instead it will try and look for a child called '/a/b/c' directly under this node.
If you wish to retrieve a child more than one level deep, use the Node.getChild(Fqn) version of this method.
public V put(K key, V value)
Nodepublic V putIfAbsent(K k, V v)
Node
if (!node.getKeys().contains(key))
return node.put(key, value);
else
return node.get(key);
except that this is atomic.putIfAbsent in interface Node<K,V>k - key with which the specified value is to be associated.v - value to be associated with the specified key.public V replace(K key, V value)
Node
if ((node.getKeys().contains(key))
{
return node.put(key, value);
}
else
return null;
except that this is atomic.public boolean replace(K key, V oldValue, V newValue)
Node
if (node.get(key).equals(oldValue))
{
node.put(key, newValue);
return true;
}
else
return false;
except that this is atomic.public void putAll(Map<? extends K,? extends V> data)
NodeNode node; for (Map.Entry me : map.entrySet()) node.put(me.getKey(), me.getValue());
public void replaceAll(Map<? extends K,? extends V> data)
NodeNode.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.replaceAll in interface Node<K,V>data - map to copy frompublic V get(K key)
Nodenull if the node contains no mapping for this key.public V remove(K key)
Nodenull if the node contained no mapping for this keypublic void clearData()
Nodepublic int dataSize()
public boolean hasChild(Fqn f)
NodeFqn passed in exists.public boolean hasChild(Object o)
Nodepublic boolean isValid()
NodeNodeNotValidException.public boolean isResident()
NodeisResident in interface Node<K,V>public void setResident(boolean resident)
setResident in interface Node<K,V>Node.isResident()public boolean isLockForChildInsertRemove()
NodeConfiguration.isLockParentForChildInsertRemove()
This can also be configured on a per-node basis using Node.setLockForChildInsertRemove(boolean)isLockForChildInsertRemove in interface Node<K,V>public void setLockForChildInsertRemove(boolean lockForChildInsertRemove)
NodesetLockForChildInsertRemove in interface Node<K,V>lockForChildInsertRemove - if true, exclusive locks will be obtained when children are added/removed. If
false, a shared "read lock" will be obtained instead.public void releaseObjectReferences(boolean recursive)
NodereleaseObjectReferences in interface Node<K,V>recursive - if true, child nodes will have their object references released as well.public boolean hasChildrenDirect()
hasChildrenDirect in interface NodeSPI<K,V>public Map getInternalState(boolean onlyInternalState)
NodeSPINodeSPI.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.getInternalState in interface NodeSPI<K,V>onlyInternalState - if true, the map will only contain internal state and no other data.public void setInternalState(Map state)
NodeSPINodeSPI.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.setInternalState in interface NodeSPI<K,V>state - state to be appliedpublic void setValid(boolean valid,
boolean recursive)
NodeSPINode.isValid().protected void assertValid()
public boolean isNullNode()
isNullNode in interface NodeSPI<K,V>public void markForUpdate(DataContainer container, boolean writeSkewCheck)
NodeSPImarkForUpdate in interface NodeSPI<K,V>container - data containerwriteSkewCheck - if true, and the node supports write skew checking, nodes are tested for write skews.public void commitUpdate(InvocationContext ctx, DataContainer container)
NodeSPIcommitUpdate in interface NodeSPI<K,V>ctx - invocation contextcontainer - data containerpublic boolean isChanged()
NodeSPIpublic boolean isCreated()
NodeSPIpublic void setCreated(boolean b)
NodeSPIsetCreated in interface NodeSPI<K,V>b - flagpublic void rollbackUpdate()
NodeSPIrollbackUpdate in interface NodeSPI<K,V>Copyright © 2012 JBoss, a division of Red Hat. All Rights Reserved.