org.jboss.cache
Class Node

java.lang.Object
  extended by org.jboss.cache.AbstractNode
      extended by org.jboss.cache.Node
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, DataNode, TreeNode
Direct Known Subclasses:
OptimisticTreeNode

public class Node
extends AbstractNode
implements java.io.Externalizable

Basic data node class.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jboss.cache.AbstractNode
children, data, fqn, INDENT
 
Fields inherited from interface org.jboss.cache.DataNode
LOCK_TYPE_NONE, LOCK_TYPE_READ, LOCK_TYPE_WRITE, PRINT_LOCK_DETAILS
 
Constructor Summary
Node()
          Construct an empty node; used by serialization.
Node(java.lang.Object child_name, Fqn fqn, Node parent, java.util.Map data, boolean mapSafe, TreeCache cache)
          Constructs a new node with a name, etc.
Node(java.lang.Object child_name, Fqn fqn, Node parent, java.util.Map data, TreeCache cache)
          Constructs a new node with a name, etc.
Node(java.lang.Object child_name, Fqn fqn, Node parent, java.lang.Object key, java.lang.Object value, TreeCache cache)
          Constructs a new node with a single key and value.
 
Method Summary
 boolean acquire(java.lang.Object caller, long timeout, int lock_type)
          Returns true if a lock is acquired.
 java.util.Set acquireAll(java.lang.Object caller, long timeout, int lock_type)
          Not to be exposed.
protected  boolean acquireReadLock(java.lang.Object caller, long timeout)
           
protected  boolean acquireWriteLock(java.lang.Object caller, long timeout)
           
protected  java.util.Map children()
          Override this if concurrent thread access may occur, in which case return a concurrently modifiable Map.
 void clear()
          Clears the data of this node.
 java.lang.Object clone()
          Returns a copy of this node.
 boolean containsKey(java.lang.Object key)
          Returns true if the key is in the data set.
 TreeNode createChild(java.lang.Object child_name, Fqn fqn, TreeNode parent)
          Creates a child node with a name, FQN, and parent.
 TreeNode createChild(java.lang.Object child_name, Fqn fqn, TreeNode parent, java.lang.Object key, java.lang.Object value)
          Creates a child node.
 java.lang.Object get(java.lang.Object key)
          Returns the value of a key or null if it does not exist.
 boolean getChildrenLoaded()
          Not to be exposed.
 java.util.Map getData()
          Returns a copy of the attributes.
 java.util.Set getDataKeys()
          Returns the data keys, or an empty set if there are no keys.
 IdentityLock getImmutableLock()
          Deprecated. Use getLock() instead
 IdentityLock getLock()
          Not to be exposed.
 TreeNode getOrCreateChild(java.lang.Object child_name, GlobalTransaction gtx, boolean createIfNotExists)
          Creates a new child of this node if it doesn't exist.
 TreeNode getParent()
          Returns a parent by checking the TreeMap by name.
protected  void init(java.lang.Object child_name, Fqn fqn, TreeCache cache)
          Initializes with a name and FQN and cache.
 boolean isLocked()
          Not to be exposed.
 int numAttributes()
          Returns the number of attributes.
 void printDetails(java.lang.StringBuffer sb, int indent)
          Prints the node with details and indent.
 void printLockInfo(java.lang.StringBuffer sb, int indent)
          Not to be exposed.
 void put(java.util.Map data, boolean erase)
          Puts the contents of a map into this node.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Puts the key and value into the node.
 void readExternal(java.io.ObjectInput in)
          Deserializes this object from ObjectInput.
 void release(java.lang.Object caller)
          Not to be exposed.
 void releaseAll(java.lang.Object owner)
          Not to be exposed.
 void releaseAllForce()
          Not to be exposed.
 void releaseForce()
          Not to be exposed.
 java.lang.Object remove(java.lang.Object key)
          Removes the old value of the key.
 void setChildrenLoaded(boolean flag)
          Not to be exposed.
 void setRecursiveTreeCacheInstance(TreeCache cache)
          Set the tree cache instance recursively down to the children as well.
 java.lang.String toString()
          Returns a debug string.
 void writeExternal(java.io.ObjectOutput out)
          Serializes this object to ObjectOutput.
 
Methods inherited from class org.jboss.cache.AbstractNode
addChild, childExists, data, getChild, getChildren, getFqn, getName, hasChildren, print, printDetailsInMap, printIndent, put, removeAllChildren, removeChild, setChildren
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Node

public Node()
Construct an empty node; used by serialization.


Node

public Node(java.lang.Object child_name,
            Fqn fqn,
            Node parent,
            java.util.Map data,
            TreeCache cache)
Constructs a new node with a name, etc.


Node

public Node(java.lang.Object child_name,
            Fqn fqn,
            Node parent,
            java.util.Map data,
            boolean mapSafe,
            TreeCache cache)
Constructs a new node with a name, etc.

Parameters:
mapSafe - true if param data can safely be directly assigned to this object's AbstractNode.data field; false if param data's contents should be copied into this object's AbstractNode.data field.

Node

public Node(java.lang.Object child_name,
            Fqn fqn,
            Node parent,
            java.lang.Object key,
            java.lang.Object value,
            TreeCache cache)
Constructs a new node with a single key and value.

Method Detail

init

protected final void init(java.lang.Object child_name,
                          Fqn fqn,
                          TreeCache cache)
Initializes with a name and FQN and cache.


getParent

public TreeNode getParent()
Returns a parent by checking the TreeMap by name.

Specified by:
getParent in interface TreeNode
Overrides:
getParent in class AbstractNode

children

protected java.util.Map children()
Description copied from class: AbstractNode
Override this if concurrent thread access may occur, in which case return a concurrently modifiable Map.

Overrides:
children in class AbstractNode

setRecursiveTreeCacheInstance

public void setRecursiveTreeCacheInstance(TreeCache cache)
Set the tree cache instance recursively down to the children as well. Note that this method is not currently thread safe.

Specified by:
setRecursiveTreeCacheInstance in interface TreeNode
See Also:
DataNode

getChildrenLoaded

public boolean getChildrenLoaded()
Description copied from interface: TreeNode
Not to be exposed. Internal calls should use impl classes.

Specified by:
getChildrenLoaded in interface TreeNode
See Also:
DataNode

setChildrenLoaded

public void setChildrenLoaded(boolean flag)
Description copied from interface: TreeNode
Not to be exposed. Internal calls should use impl classes.

Specified by:
setChildrenLoaded in interface TreeNode
See Also:
DataNode

get

public java.lang.Object get(java.lang.Object key)
Description copied from interface: TreeNode
Returns the value of a key or null if it does not exist.

Specified by:
get in interface TreeNode

containsKey

public boolean containsKey(java.lang.Object key)
Description copied from interface: TreeNode
Returns true if the key is in the data set.

Specified by:
containsKey in interface TreeNode

getDataKeys

public java.util.Set getDataKeys()
Returns the data keys, or an empty set if there are no keys.

Specified by:
getDataKeys in interface TreeNode

isLocked

public boolean isLocked()
Description copied from interface: TreeNode
Not to be exposed. Internal calls should use impl classes.

Specified by:
isLocked in interface TreeNode
See Also:
DataNode

getImmutableLock

public IdentityLock getImmutableLock()
Deprecated. Use getLock() instead

Description copied from interface: TreeNode
Not to be exposed. Internal calls should use impl classes.

Specified by:
getImmutableLock in interface TreeNode
See Also:
DataNode

getLock

public IdentityLock getLock()
Description copied from interface: TreeNode
Not to be exposed. Internal calls should use impl classes.

Specified by:
getLock in interface TreeNode
See Also:
DataNode

getData

public java.util.Map getData()
Description copied from interface: TreeNode
Returns a copy of the attributes. Use get(Object key) instead.

Specified by:
getData in interface TreeNode
See Also:
DataNode

numAttributes

public int numAttributes()
Description copied from interface: TreeNode
Returns the number of attributes.

Specified by:
numAttributes in interface TreeNode

put

public void put(java.util.Map data,
                boolean erase)
Description copied from interface: TreeNode
Puts the contents of a map into this node. Optionally erases the existing contents.

Specified by:
put in interface TreeNode
erase - true to erase the existing contents

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Description copied from interface: TreeNode
Puts the key and value into the node. Returns the old value of the key, if it existed.

Specified by:
put in interface TreeNode

getOrCreateChild

public TreeNode getOrCreateChild(java.lang.Object child_name,
                                 GlobalTransaction gtx,
                                 boolean createIfNotExists)
Description copied from interface: TreeNode
Creates a new child of this node if it doesn't exist. Also notifies the cache that the new child has been created. dded this new getOrCreateChild() method to avoid thread contention on create_lock in PessimisticLockInterceptor.lock() Not to be exposed. Internal calls should use impl classes.

Specified by:
getOrCreateChild in interface TreeNode
See Also:
DataNode

createChild

public TreeNode createChild(java.lang.Object child_name,
                            Fqn fqn,
                            TreeNode parent)
Description copied from interface: TreeNode
Creates a child node with a name, FQN, and parent. Returns the created node.

Specified by:
createChild in interface TreeNode

createChild

public TreeNode createChild(java.lang.Object child_name,
                            Fqn fqn,
                            TreeNode parent,
                            java.lang.Object key,
                            java.lang.Object value)
Description copied from interface: TreeNode
Creates a child node.

Specified by:
createChild in interface TreeNode

remove

public java.lang.Object remove(java.lang.Object key)
Description copied from interface: TreeNode
Removes the old value of the key.

Specified by:
remove in interface TreeNode

clear

public void clear()
Description copied from interface: TreeNode
Clears the data of this node.

Specified by:
clear in interface TreeNode

printDetails

public void printDetails(java.lang.StringBuffer sb,
                         int indent)
Description copied from interface: TreeNode
Prints the node with details and indent.

Specified by:
printDetails in interface TreeNode

printLockInfo

public void printLockInfo(java.lang.StringBuffer sb,
                          int indent)
Description copied from interface: TreeNode
Not to be exposed. Internal calls should use impl classes.

Specified by:
printLockInfo in interface TreeNode
See Also:
DataNode

toString

public java.lang.String toString()
Returns a debug string.

Overrides:
toString in class java.lang.Object

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Description copied from interface: DataNode
Returns a copy of this node.

Specified by:
clone in interface DataNode
Specified by:
clone in class AbstractNode
Throws:
java.lang.CloneNotSupportedException

acquire

public boolean acquire(java.lang.Object caller,
                       long timeout,
                       int lock_type)
                throws LockingException,
                       TimeoutException,
                       java.lang.InterruptedException
Description copied from interface: DataNode
Returns true if a lock is acquired.

Specified by:
acquire in interface DataNode
timeout - milliseconds to wait
lock_type - lock type to use
Throws:
LockingException
TimeoutException
java.lang.InterruptedException

acquireReadLock

protected boolean acquireReadLock(java.lang.Object caller,
                                  long timeout)
                           throws LockingException,
                                  TimeoutException,
                                  java.lang.InterruptedException
Throws:
LockingException
TimeoutException
java.lang.InterruptedException

acquireWriteLock

protected boolean acquireWriteLock(java.lang.Object caller,
                                   long timeout)
                            throws LockingException,
                                   TimeoutException,
                                   java.lang.InterruptedException
Throws:
LockingException
TimeoutException
java.lang.InterruptedException

acquireAll

public java.util.Set acquireAll(java.lang.Object caller,
                                long timeout,
                                int lock_type)
                         throws LockingException,
                                TimeoutException,
                                java.lang.InterruptedException
Description copied from interface: TreeNode
Not to be exposed. Internal calls should use impl classes.

Specified by:
acquireAll in interface TreeNode
Throws:
LockingException
TimeoutException
java.lang.InterruptedException
See Also:
DataNode

release

public void release(java.lang.Object caller)
Description copied from interface: TreeNode
Not to be exposed. Internal calls should use impl classes.

Specified by:
release in interface TreeNode
See Also:
DataNode

releaseForce

public void releaseForce()
Description copied from interface: TreeNode
Not to be exposed. Internal calls should use impl classes.

Specified by:
releaseForce in interface TreeNode
See Also:
DataNode

releaseAll

public void releaseAll(java.lang.Object owner)
Description copied from interface: TreeNode
Not to be exposed. Internal calls should use impl classes.

Specified by:
releaseAll in interface TreeNode
See Also:
DataNode

releaseAllForce

public void releaseAllForce()
Description copied from interface: TreeNode
Not to be exposed. Internal calls should use impl classes.

Specified by:
releaseAllForce in interface TreeNode
See Also:
DataNode

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Serializes this object to ObjectOutput. Writes the Fqn elements, children as a Map, and data as a Map. (This is no longer used within JBoss Cache.)

Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException
See Also:
TreeCacheMarshaller

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Deserializes this object from ObjectInput. (This is no longer used within JBoss Cache.)

Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException


Copyright © 1998-2005 JBoss Inc . All Rights Reserved.