|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jboss.cache.AbstractNode<K,V>
org.jboss.cache.UnversionedNode<K,V>
public class UnversionedNode<K,V>
Basic data node class. Throws UnsupportedOperationException
for version-specific methods like getVersion()
and
setVersion(org.jboss.cache.optimistic.DataVersion)
, defined in NodeSPI
.
Field Summary |
---|
Fields inherited from class org.jboss.cache.AbstractNode |
---|
deleted, fqn, children, resident |
Constructor Summary | |
---|---|
|
UnversionedNode()
Constructs a new node with an FQN of Root. |
protected |
UnversionedNode(Object child_name,
Fqn fqn,
Map<K,V> data,
boolean mapSafe,
CacheSPI<K,V> cache)
Constructs a new node with a name, etc. |
Method Summary | |
---|---|
Node<K,V> |
addChild(Fqn f)
Adds a child node with the given Fqn under the current node. |
void |
addChild(Object child_name,
Node<K,V> n)
Adds or replaces a child by name. |
NodeSPI<K,V> |
addChildDirect(Fqn f)
Adds a child directly to a Node. |
void |
addChildDirect(NodeSPI<K,V> child)
Directly adds the node passed in to the children map of the current node. |
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. |
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. |
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 name of this node. |
Node<K,V> |
getChild(Fqn fqn)
Returns the child node |
Node<K,V> |
getChild(Object childName)
|
NodeSPI<K,V> |
getChildDirect(Fqn fqn)
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 includeMarkedForRemoval)
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 |
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. |
IdentityLock |
getLock()
Returns a lock for this node. |
NodeSPI<K,V> |
getOrCreateChild(Object child_name,
GlobalTransaction gtx)
Returns an existing child or creates a new one using a global transaction. |
NodeSPI<K,V> |
getParent()
Returns a parent by checking the TreeMap by name. |
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()
|
boolean |
isDataLoaded()
Returns true if the data was loaded from the cache loader. |
boolean |
isChildrenLoaded()
Returns true if the children of this node were loaded from a cache loader. |
boolean |
isLockForChildInsertRemove()
Tests whether this node is configured to be exclusively locked when inserting or removing children. |
boolean |
isValid()
Tests if a node reference is still valid. |
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. |
V |
remove(K key)
Removes the mapping for this key from this node if it is present. |
V |
removeDirect(K key)
Removes a data key directly from a node. |
boolean |
removeChild(Fqn fqn)
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 f)
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 |
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 |
setDataLoaded(boolean dataLoaded)
Sets if the data was loaded from the cache loader. |
void |
setFqn(Fqn fqn)
Sets the FQN of this node and resets the names of all children as well. |
void |
setChildrenLoaded(boolean flag)
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 |
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 |
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()
Returns a debug string. |
Methods inherited from class org.jboss.cache.AbstractNode |
---|
equals, hashCode, isDeleted, isResident, markAsDeleted, markAsDeleted, setResident |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.jboss.cache.NodeSPI |
---|
isDeleted, markAsDeleted, markAsDeleted |
Methods inherited from interface org.jboss.cache.Node |
---|
isResident, setResident |
Constructor Detail |
---|
public UnversionedNode()
protected UnversionedNode(Object child_name, Fqn fqn, Map<K,V> data, boolean mapSafe, CacheSPI<K,V> cache)
mapSafe
- true
if param data
can safely be directly assigned to this object's
data
field; false
if param data
's contents should be copied into
this object's data
field.Method Detail |
---|
public NodeSPI<K,V> getParent()
getParent
in interface Node<K,V>
getParent
in interface NodeSPI<K,V>
Node.getParent()
public CacheSPI<K,V> getCache()
NodeSPI
getCache
in interface NodeSPI<K,V>
public boolean isChildrenLoaded()
NodeSPI
isChildrenLoaded
in interface NodeSPI<K,V>
public void setChildrenLoaded(boolean flag)
NodeSPI
setChildrenLoaded
in interface NodeSPI<K,V>
flag
- true if loaded, false otherwisepublic V get(K key)
Node
null
if the node contains no mapping for this key.
get
in interface Node<K,V>
key
- key of the data to return
null
if the map contains no mapping for this keypublic V getDirect(K key)
NodeSPI
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.
getDirect
in interface NodeSPI<K,V>
key
- data to get
Node.get(Object)
public IdentityLock getLock()
NodeSPI
getLock
in interface NodeSPI<K,V>
public Map<K,V> getData()
Node
Node
.
getData
in interface Node<K,V>
Map
containing the data in this Node
. If there is no data, an empty Map
is returned. The Map
returned is always immutable.public Map<K,V> getDataDirect()
NodeSPI
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.
Also note that this method returns an unmodifiable reference to the underlying data map.
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 put(K key, V value)
Node
put
in interface Node<K,V>
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.
public V putDirect(K key, V value)
NodeSPI
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.
putDirect
in interface NodeSPI<K,V>
key
- of datavalue
- of data
Node.put(Object,Object)
public NodeSPI<K,V> getOrCreateChild(Object child_name, GlobalTransaction gtx)
NodeSPI
getOrCreateChild
in interface NodeSPI<K,V>
child_name
- name of child to creategtx
- transaction under which to create child
public V remove(K key)
Node
null
if the node contained no mapping for this key
remove
in interface Node<K,V>
key
- key whose mapping is to be removed
null
if there was no mapping for keypublic V removeDirect(K key)
NodeSPI
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.
removeDirect
in interface NodeSPI<K,V>
key
- to remove
Node.remove(Object)
public void printDetails(StringBuffer sb, int indent)
NodeSPI
printDetails
in interface NodeSPI<K,V>
sb
- StringBuffer to print toindent
- depth of this node in the tree. Used to indent details by prepending spaces.public String toString()
toString
in class Object
public Node<K,V> addChild(Fqn f)
Node
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.
addChild
in interface Node<K,V>
f
- Fqn
of the child node, relative to the current node.
public void addChildDirect(NodeSPI<K,V> child)
NodeSPI
addChildDirect
in interface NodeSPI<K,V>
child
- child to addpublic NodeSPI<K,V> addChildDirect(Fqn f)
NodeSPI
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.
addChildDirect
in interface NodeSPI<K,V>
f
- name of child
Node.addChild(Fqn)
public void clearData()
Node
clearData
in interface Node<K,V>
public void clearDataDirect()
NodeSPI
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.
clearDataDirect
in interface NodeSPI<K,V>
Node.clearData()
public Node<K,V> getChild(Fqn fqn)
Node
getChild
in interface Node<K,V>
fqn
- Fqn
of the child node
public NodeSPI<K,V> getChildDirect(Fqn fqn)
NodeSPI
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.
getChildDirect
in interface NodeSPI<K,V>
fqn
- name of child
Node.getChild(Fqn)
public Set<Object> getChildrenNames()
Node
getChildrenNames
in interface Node<K,V>
Set
of child node names. Empty Set
if there aren't any children.public Set<Object> getChildrenNamesDirect()
NodeSPI
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.
getChildrenNamesDirect
in interface NodeSPI<K,V>
Node.getChildrenNames()
public Set<K> getKeys()
Node
Set
containing the data in this Node
.
getKeys
in interface Node<K,V>
Set
containing the data in this Node
. If there is no data, an empty Set
is returned. The Set
returned is always immutable.public Set<K> getKeysDirect()
NodeSPI
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.
getKeysDirect
in interface NodeSPI<K,V>
Node.getKeys()
public boolean hasChild(Fqn f)
Node
Fqn
passed in exists.
hasChild
in interface Node<K,V>
f
- Fqn
relative to the current node of the child you are testing the existence of.
Fqn
passed in exists.public boolean hasChild(Object o)
Node
hasChild
in interface Node<K,V>
o
- name of the child, relative to the current node
public 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.
replace
in interface Node<K,V>
key
- key with which the specified value is associated.value
- value to be associated with the specified key.
public boolean replace(K key, V oldValue, V newValue)
Node
if (node.get(key).equals(oldValue)) { node.putAll(key, newValue); return true; } else return false;except that this is atomic.
replace
in interface Node<K,V>
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.
public boolean removeChild(Fqn fqn)
Node
Fqn
.
If you wish to remove children based on absolute Fqn
s, use the Cache
interface instead.
removeChild
in interface Node<K,V>
fqn
- Fqn
of the child node, relative to the current node.
public int dataSize()
dataSize
in interface Node<K,V>
public boolean removeChild(Object childName)
Node
removeChild
in interface Node<K,V>
childName
- name of the child node, directly under the current node.
public boolean removeChildDirect(Object childName)
NodeSPI
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.
removeChildDirect
in interface NodeSPI<K,V>
childName
- of child.
Node.removeChild(Object)
public boolean removeChildDirect(Fqn f)
NodeSPI
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
removeChildDirect
in interface NodeSPI<K,V>
f
- of child.
Node.removeChild(Fqn)
public Map<Object,Node<K,V>> getChildrenMapDirect()
NodeSPI
getChildrenMapDirect
in interface NodeSPI<K,V>
public void setChildrenMapDirect(Map<Object,Node<K,V>> children)
NodeSPI
setChildrenMapDirect
in interface NodeSPI<K,V>
children
- cannot be nullpublic void putAll(Map<K,V> data)
Node
Node node; for (Map.Entry me : map.entrySet()) node.put(me.getKey(), me.getValue());
putAll
in interface Node<K,V>
data
- map to copy frompublic void replaceAll(Map<K,V> data)
Node
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.
replaceAll
in interface Node<K,V>
data
- map to copy frompublic void putAllDirect(Map<K,V> data)
NodeSPI
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.
putAllDirect
in interface NodeSPI<K,V>
data
- to putNode.putAll(Map)
public void removeChildrenDirect()
NodeSPI
removeChildrenDirect
in interface NodeSPI<K,V>
public void print(StringBuffer sb, int indent)
NodeSPI
print
in interface NodeSPI<K,V>
sb
- StringBuffer to print toindent
- depth of this node in the tree. Used to indent details by prepending spaces.public void setVersion(DataVersion version)
NodeSPI
setVersion
in interface NodeSPI<K,V>
version
- data version to applypublic DataVersion getVersion()
NodeSPI
getVersion
in interface NodeSPI<K,V>
public void addChild(Object child_name, Node<K,V> n)
NodeSPI
addChild
in interface NodeSPI<K,V>
child_name
- child node name (not an FQN)n
- child nodepublic Fqn getFqn()
getFqn
in interface Node<K,V>
Fqn
which represents the location of this Node
in the cache structure. The Fqn
returned is absolute.public void setFqn(Fqn fqn)
NodeSPI
setFqn
in interface NodeSPI<K,V>
fqn
- fqn to setpublic Node<K,V> getChild(Object childName)
getChild
in interface Node<K,V>
childName
- name of the child
public NodeSPI<K,V> getChildDirect(Object childName)
NodeSPI
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.
getChildDirect
in interface NodeSPI<K,V>
childName
- name of child
Node.getChild(Object)
public Set<Node<K,V>> getChildren()
Node
getChildren
in interface Node<K,V>
Set
of child nodes. Empty Set
if there aren't any children.public Set<NodeSPI<K,V>> getChildrenDirect()
NodeSPI
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.
getChildrenDirect
in interface NodeSPI<K,V>
Node.getChildren()
public boolean hasChildrenDirect()
hasChildrenDirect
in interface NodeSPI<K,V>
public Set<NodeSPI<K,V>> getChildrenDirect(boolean includeMarkedForRemoval)
NodeSPI
getChildrenDirect
in interface NodeSPI<K,V>
includeMarkedForRemoval
- if true, the returned set will include nodes marked as deleted
public boolean isDataLoaded()
isDataLoaded
in interface NodeSPI<K,V>
public void setDataLoaded(boolean dataLoaded)
setDataLoaded
in interface NodeSPI<K,V>
dataLoaded
- true if loaded, false otherwisepublic boolean isValid()
Node
NodeNotValidException
.
isValid
in interface Node<K,V>
public void setValid(boolean valid, boolean recursive)
NodeSPI
Node.isValid()
.
setValid
in interface NodeSPI<K,V>
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.public boolean isLockForChildInsertRemove()
Node
Configuration.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)
Node
setLockForChildInsertRemove
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 setInternalState(Map state)
NodeSPI
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.
setInternalState
in interface NodeSPI<K,V>
state
- state to be appliedpublic Map getInternalState(boolean onlyInternalState)
NodeSPI
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.
getInternalState
in interface NodeSPI<K,V>
onlyInternalState
- if true, the map will only contain internal state and no other data.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |