org.jboss.cache
Class Node

java.lang.Object
  extended byorg.jboss.cache.Node
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable

public class Node
extends java.lang.Object
implements java.io.Externalizable

Represents a node in the tree. Has a relative name and a Fqn. Maintains a hashmap. If the node is created in a replicated cache, the relative and fully qualified name, and the keys and values of the hashmap have to be serializable.

Note that current version supports different levels of transaction locking such as simple locking (TreeCache.SERIALIZABLE, or R/W lock with upgrade ( REPEATABLE_READ) --that is the read lock will be automatically upgraded to write lock when the same owner intends to modify the data after read.

This class is not synchronized, so access to instances of Node need to be run under an isolation level > NONE.

See Also:
Serialized Form

Field Summary
protected static int INDENT
           
static int LOCK_TYPE_READ
          Declare locking type with the intention to read or write data
static int LOCK_TYPE_WRITE
           
static boolean PRINT_LOCK_DETAILS
           
 
Constructor Summary
Node()
           
Node(java.lang.Object child_name, Fqn (src)  fqn, Node (src)  parent, java.util.Map data, TreeCache (src)  cache)
           
Node(java.lang.Object child_name, Fqn (src)  fqn, Node (src)  parent, java.lang.Object key, java.lang.Object value, TreeCache (src)  cache)
           
 
Method Summary
 boolean acquire(java.lang.Object caller, long timeout, int lock_type)
          Acquire a node object by locking it first.
 java.util.Set acquireAll(java.lang.Object caller, long timeout, int lock_type)
          Acquires locks for the entire subtree
protected  boolean acquireReadLock(java.lang.Object caller, long timeout)
           
protected  boolean acquireWriteLock(java.lang.Object caller, long timeout)
           
 boolean childExists(java.lang.Object child_name)
           
protected  java.util.Map children()
           
 void clear()
           
 java.lang.Object clone()
           
 boolean containsKey(java.lang.Object key)
           
 Node (src) createChild(java.lang.Object child_name, Fqn (src)  fqn, Node (src)  parent)
           
 Node (src) createChild(java.lang.Object child_name, Fqn (src)  fqn, Node (src)  parent, java.util.Map data)
           
 Node (src) createChild(java.lang.Object child_name, Fqn (src)  fqn, Node (src)  parent, java.lang.Object key, java.lang.Object value)
           
protected  java.util.Map data()
           
 java.lang.Object get(java.lang.Object key)
           
 Node (src) getChild(java.lang.Object child_name)
           
 java.util.Map getChildren()
           
 java.util.Map getData()
          Returns a copy of the attributes
 java.util.Set getDataKeys()
           
 Fqn (src) getFqn()
           
 IdentityLock (src) getImmutableLock()
          Deprecated. Use getLock() instead
 IdentityLock (src) getLock()
           
 java.lang.Object getName()
           
 Node (src) getParent()
           
 boolean hasChild()
          Deprecated. Use hasChildren() instead
 boolean hasChildren()
           
protected  void init()
           
protected  void init(java.lang.Object child_name, Fqn (src)  fqn, Node (src)  parent, TreeCache (src)  cache)
           
protected  java.util.Map initChildren()
           
protected  java.util.Map initData()
           
 int numAttributes()
           
 void print(java.lang.StringBuffer sb, int indent)
           
 void printDetails(java.lang.StringBuffer sb, int indent)
           
 void printIndent(java.lang.StringBuffer sb, int indent)
           
 void printLockInfo(java.lang.StringBuffer sb, int indent)
           
 void put(java.util.Map data)
           
 void put(java.util.Map data, boolean erase)
           
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
           
 void readExternal(java.io.ObjectInput in)
           
 void release(java.lang.Object caller)
           
 void releaseAll(java.lang.Object owner)
          Releases locks for the entire subtree
 void releaseAllForce()
          Releases locks for the entire subtree.
 void releaseForce()
           
 java.lang.Object remove(java.lang.Object key)
           
 void removeAllChildren()
           
 void removeChild(java.lang.Object child_name)
           
 java.lang.String toString()
           
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOCK_TYPE_READ

public static final int LOCK_TYPE_READ
Declare locking type with the intention to read or write data

See Also:
Constant Field Values (src)

LOCK_TYPE_WRITE

public static final int LOCK_TYPE_WRITE
See Also:
Constant Field Values (src)

INDENT

protected static final int INDENT
See Also:
Constant Field Values (src)

PRINT_LOCK_DETAILS

public static final transient boolean PRINT_LOCK_DETAILS
Constructor Detail

Node

public Node()

Node

public Node(java.lang.Object child_name,
            Fqn (src)  fqn,
            Node (src)  parent,
            java.util.Map data,
            TreeCache (src)  cache)

Node

public Node(java.lang.Object child_name,
            Fqn (src)  fqn,
            Node (src)  parent,
            java.lang.Object key,
            java.lang.Object value,
            TreeCache (src)  cache)
Method Detail

init

protected void init(java.lang.Object child_name,
                    Fqn (src)  fqn,
                    Node (src)  parent,
                    TreeCache (src)  cache)

init

protected void init()

initChildren

protected java.util.Map initChildren()

initData

protected java.util.Map initData()

children

protected java.util.Map children()

data

protected java.util.Map data()

getName

public java.lang.Object getName()

getFqn

public Fqn (src)  getFqn()

get

public java.lang.Object get(java.lang.Object key)

containsKey

public boolean containsKey(java.lang.Object key)

getChild

public Node (src)  getChild(java.lang.Object child_name)

getParent

public Node (src)  getParent()

getDataKeys

public java.util.Set getDataKeys()

childExists

public boolean childExists(java.lang.Object child_name)

getImmutableLock

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

Returns:

getLock

public IdentityLock (src)  getLock()

getChildren

public java.util.Map getChildren()
Returns:
Map

getData

public java.util.Map getData()
Returns a copy of the attributes


numAttributes

public int numAttributes()

hasChild

public boolean hasChild()
Deprecated. Use hasChildren() instead

Returns:

hasChildren

public boolean hasChildren()

put

public void put(java.util.Map data,
                boolean erase)

put

public void put(java.util.Map data)

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)

createChild

public Node (src)  createChild(java.lang.Object child_name,
                        Fqn (src)  fqn,
                        Node (src)  parent)

createChild

public Node (src)  createChild(java.lang.Object child_name,
                        Fqn (src)  fqn,
                        Node (src)  parent,
                        java.util.Map data)

createChild

public Node (src)  createChild(java.lang.Object child_name,
                        Fqn (src)  fqn,
                        Node (src)  parent,
                        java.lang.Object key,
                        java.lang.Object value)

remove

public java.lang.Object remove(java.lang.Object key)

clear

public void clear()

removeChild

public void removeChild(java.lang.Object child_name)

removeAllChildren

public void removeAllChildren()

print

public void print(java.lang.StringBuffer sb,
                  int indent)

printDetails

public void printDetails(java.lang.StringBuffer sb,
                         int indent)

printLockInfo

public void printLockInfo(java.lang.StringBuffer sb,
                          int indent)

printIndent

public void printIndent(java.lang.StringBuffer sb,
                        int indent)

toString

public java.lang.String toString()

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Throws:
java.lang.CloneNotSupportedException

acquire

public boolean acquire(java.lang.Object caller,
                       long timeout,
                       int lock_type)
                throws LockingException (src) ,
                       TimeoutException (src) ,
                       java.lang.InterruptedException
Acquire a node object by locking it first. The lock type is specified via lock_type.

Parameters:
caller - Tansaction context owner.
timeout - Timeout in milliseconds
lock_type - @see Node
Returns:
boolean True if node could be acquired, false if owner already held the lock. An exception is thrown if the owner didn't already hold the lock, but it couldn't be acquired
Throws:
LockingException (src)
TimeoutException (src)
java.lang.InterruptedException

acquireReadLock

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

acquireWriteLock

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

acquireAll

public java.util.Set acquireAll(java.lang.Object caller,
                                long timeout,
                                int lock_type)
                         throws LockingException (src) ,
                                TimeoutException (src) ,
                                java.lang.InterruptedException
Acquires locks for the entire subtree

Throws:
LockingException (src)
TimeoutException (src)
java.lang.InterruptedException

release

public void release(java.lang.Object caller)

releaseForce

public void releaseForce()

releaseAll

public void releaseAll(java.lang.Object owner)
Releases locks for the entire subtree


releaseAllForce

public void releaseAllForce()
Releases locks for the entire subtree. Forces release regardless of owner


writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException