org.jboss.cache.mvcc
Class NodeReference<K,V>

java.lang.Object
  extended by org.jboss.cache.mvcc.NodeReference<K,V>
All Implemented Interfaces:
InternalNode<K,V>

@ThreadSafe
public class NodeReference<K,V>
extends Object
implements InternalNode<K,V>

A node reference that delegates all calls to a different InternalNode. Simple indirection is all this class does, allowing other processes to change the delegate.

The delegate is a volatile field so the class is thread safe.

This is used to wrap all NodeInvocationDelegates in the DataContainer when using Configuration.NodeLockingScheme.MVCC and IsolationLevel.READ_COMMITTED.

Since:
3.0
Author:
Manik Surtani (manik AT jboss DOT org)
See Also:
ReadCommittedNode

Constructor Summary
NodeReference(InternalNode<K,V> delegate)
           
 
Method Summary
 void addChild(InternalNode<K,V> child)
           
 void addChild(InternalNode<K,V> child, boolean safe)
          Same as above, except that if safe is true, any Fqn ancestry checking is skipped.
 void addChild(Object nodeName, InternalNode<K,V> nodeToAdd)
           
 NodeSPI<K,V> addChildDirect(Fqn f)
           
 NodeSPI<K,V> addChildDirect(Fqn f, boolean notify)
           
 void addChildDirect(NodeSPI<K,V> child)
           
 NodeSPI<K,V> addChildDirect(Object o, boolean notify)
           
 void addChildDirect(Object nodeName, Node<K,V> nodeToAdd)
           
 void clear()
           
 boolean containsKey(K key)
           
 InternalNode<K,V> copy()
          Creates a new instance of the same type and copies internal state.
 boolean equals(Object o)
           
 V get(K key)
           
 CacheSPI<K,V> getCache()
           
 InternalNode<K,V> getChild(Fqn f)
           
 InternalNode<K,V> getChild(Object childName)
           
 NodeSPI<K,V> getChildDirect(Fqn fqn)
           
 NodeSPI<K,V> getChildDirect(Object childName)
           
 Set<InternalNode<K,V>> getChildren()
           
 Set<InternalNode<K,V>> getChildren(boolean includeMarkedForRemoval)
           
 Set<NodeSPI<K,V>> getChildrenDirect()
           
 Set<NodeSPI<K,V>> getChildrenDirect(boolean includeMarkedForRemoval)
           
 ConcurrentMap<Object,InternalNode<K,V>> getChildrenMap()
           
 Map<Object,Node<K,V>> getChildrenMapDirect()
           
 Set<Object> getChildrenNames()
           
 Map<K,V> getData()
           
 InternalNode<K,V> getDelegate()
           
 Fqn getFqn()
           
 Map getInternalState(boolean onlyInternalState)
           
 Set<K> getKeys()
           
 NodeLock getLock()
           
 NodeSPI<K,V> getOrCreateChild(Object child_name, GlobalTransaction gtx)
           
 NodeSPI<K,V> getParent()
           
 DataVersion getVersion()
           
 boolean hasChildren()
           
 int hashCode()
           
 boolean isChildrenLoaded()
           
 boolean isDataLoaded()
           
 boolean isLockForChildInsertRemove()
           
 boolean isRemoved()
           
 boolean isResident()
           
 boolean isValid()
           
 void markAsRemoved(boolean marker, boolean recursive)
           
 void printDetails(StringBuilder sb, int indent)
           
 V put(K key, V value)
           
 void putAll(Map<? extends K,? extends V> data)
           
 void releaseObjectReferences(boolean recursive)
           
 V remove(K key)
           
 boolean removeChild(Fqn f)
           
 boolean removeChild(Object childName)
           
 void removeChildren()
           
 void setChildrenLoaded(boolean flag)
           
 void setChildrenMap(ConcurrentMap<Object,InternalNode<K,V>> children)
           
 void setChildrenMapDirect(Map<Object,Node<K,V>> children)
           
 void setDataLoaded(boolean dataLoaded)
           
 void setDelegate(InternalNode<K,V> delegate)
          Sets the internal node to delegate to.
 void setFqn(Fqn fqn)
          Sets the node's Fqn
 void setInternalState(Map state)
           
 void setLockForChildInsertRemove(boolean lockForChildInsertRemove)
           
 void setRemoved(boolean marker)
           
 void setResident(boolean resident)
           
 void setValid(boolean valid, boolean recursive)
           
 void setVersion(DataVersion version)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NodeReference

public NodeReference(InternalNode<K,V> delegate)
Method Detail

getDelegate

public final InternalNode<K,V> getDelegate()
Returns:
the InternalNode being delegated to.

setDelegate

public final void setDelegate(InternalNode<K,V> delegate)
Sets the internal node to delegate to.

Parameters:
delegate - node to delegate to.

getParent

public final NodeSPI<K,V> getParent()
Specified by:
getParent in interface InternalNode<K,V>

getCache

public final CacheSPI<K,V> getCache()
Specified by:
getCache in interface InternalNode<K,V>

isChildrenLoaded

public final boolean isChildrenLoaded()
Specified by:
isChildrenLoaded in interface InternalNode<K,V>

setChildrenLoaded

public final void setChildrenLoaded(boolean flag)
Specified by:
setChildrenLoaded in interface InternalNode<K,V>

get

public final V get(K key)
Specified by:
get in interface InternalNode<K,V>

getData

public final Map<K,V> getData()
Specified by:
getData in interface InternalNode<K,V>

put

public final V put(K key,
                   V value)
Specified by:
put in interface InternalNode<K,V>

getOrCreateChild

public final NodeSPI<K,V> getOrCreateChild(Object child_name,
                                           GlobalTransaction gtx)
Specified by:
getOrCreateChild in interface InternalNode<K,V>

getChild

public final InternalNode<K,V> getChild(Fqn f)
Specified by:
getChild in interface InternalNode<K,V>

getChild

public final InternalNode<K,V> getChild(Object childName)
Specified by:
getChild in interface InternalNode<K,V>

getChildren

public final Set<InternalNode<K,V>> getChildren()
Specified by:
getChildren in interface InternalNode<K,V>

getChildren

public final Set<InternalNode<K,V>> getChildren(boolean includeMarkedForRemoval)
Specified by:
getChildren in interface InternalNode<K,V>

getChildrenMap

public final ConcurrentMap<Object,InternalNode<K,V>> getChildrenMap()
Specified by:
getChildrenMap in interface InternalNode<K,V>

setChildrenMap

public final void setChildrenMap(ConcurrentMap<Object,InternalNode<K,V>> children)
Specified by:
setChildrenMap in interface InternalNode<K,V>

addChild

public final void addChild(Object nodeName,
                           InternalNode<K,V> nodeToAdd)
Specified by:
addChild in interface InternalNode<K,V>

addChild

public final void addChild(InternalNode<K,V> child)
Specified by:
addChild in interface InternalNode<K,V>

addChild

public final void addChild(InternalNode<K,V> child,
                           boolean safe)
Description copied from interface: InternalNode
Same as above, except that if safe is true, any Fqn ancestry checking is skipped. Don't set safe to true unless you really know what you are doing!

Specified by:
addChild in interface InternalNode<K,V>
Parameters:
child - child to add
safe - safety flag

remove

public final V remove(K key)
Specified by:
remove in interface InternalNode<K,V>

addChildDirect

public final NodeSPI<K,V> addChildDirect(Fqn f)
Specified by:
addChildDirect in interface InternalNode<K,V>

addChildDirect

public final NodeSPI<K,V> addChildDirect(Fqn f,
                                         boolean notify)
Specified by:
addChildDirect in interface InternalNode<K,V>

addChildDirect

public final NodeSPI<K,V> addChildDirect(Object o,
                                         boolean notify)
Specified by:
addChildDirect in interface InternalNode<K,V>

clear

public final void clear()
Specified by:
clear in interface InternalNode<K,V>

getChildDirect

public final NodeSPI<K,V> getChildDirect(Fqn fqn)
Specified by:
getChildDirect in interface InternalNode<K,V>

getChildrenNames

public final Set<Object> getChildrenNames()
Specified by:
getChildrenNames in interface InternalNode<K,V>

getKeys

public final Set<K> getKeys()
Specified by:
getKeys in interface InternalNode<K,V>

containsKey

public final boolean containsKey(K key)
Specified by:
containsKey in interface InternalNode<K,V>

setInternalState

public final void setInternalState(Map state)
Specified by:
setInternalState in interface InternalNode<K,V>

removeChild

public final boolean removeChild(Object childName)
Specified by:
removeChild in interface InternalNode<K,V>

removeChild

public final boolean removeChild(Fqn f)
Specified by:
removeChild in interface InternalNode<K,V>

getChildrenMapDirect

public final Map<Object,Node<K,V>> getChildrenMapDirect()
Specified by:
getChildrenMapDirect in interface InternalNode<K,V>

setChildrenMapDirect

public final void setChildrenMapDirect(Map<Object,Node<K,V>> children)
Specified by:
setChildrenMapDirect in interface InternalNode<K,V>

putAll

public final void putAll(Map<? extends K,? extends V> data)
Specified by:
putAll in interface InternalNode<K,V>

removeChildren

public final void removeChildren()
Specified by:
removeChildren in interface InternalNode<K,V>

setVersion

public final void setVersion(DataVersion version)
Specified by:
setVersion in interface InternalNode<K,V>

getVersion

public final DataVersion getVersion()
Specified by:
getVersion in interface InternalNode<K,V>

getFqn

public final Fqn getFqn()
Specified by:
getFqn in interface InternalNode<K,V>
Returns:
the node's Fqn

setFqn

public final void setFqn(Fqn fqn)
Description copied from interface: InternalNode
Sets the node's Fqn

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

getChildDirect

public final NodeSPI<K,V> getChildDirect(Object childName)
Specified by:
getChildDirect in interface InternalNode<K,V>

getChildrenDirect

public final Set<NodeSPI<K,V>> getChildrenDirect()
Specified by:
getChildrenDirect in interface InternalNode<K,V>

hasChildren

public final boolean hasChildren()
Specified by:
hasChildren in interface InternalNode<K,V>

getChildrenDirect

public final Set<NodeSPI<K,V>> getChildrenDirect(boolean includeMarkedForRemoval)
Specified by:
getChildrenDirect in interface InternalNode<K,V>

isDataLoaded

public final boolean isDataLoaded()
Specified by:
isDataLoaded in interface InternalNode<K,V>

setDataLoaded

public final void setDataLoaded(boolean dataLoaded)
Specified by:
setDataLoaded in interface InternalNode<K,V>

isValid

public final boolean isValid()
Specified by:
isValid in interface InternalNode<K,V>

setValid

public final void setValid(boolean valid,
                           boolean recursive)
Specified by:
setValid in interface InternalNode<K,V>

isLockForChildInsertRemove

public final boolean isLockForChildInsertRemove()
Specified by:
isLockForChildInsertRemove in interface InternalNode<K,V>

setLockForChildInsertRemove

public final void setLockForChildInsertRemove(boolean lockForChildInsertRemove)
Specified by:
setLockForChildInsertRemove in interface InternalNode<K,V>

getInternalState

public final Map getInternalState(boolean onlyInternalState)
Specified by:
getInternalState in interface InternalNode<K,V>

releaseObjectReferences

public final void releaseObjectReferences(boolean recursive)
Specified by:
releaseObjectReferences in interface InternalNode<K,V>

isRemoved

public final boolean isRemoved()
Specified by:
isRemoved in interface InternalNode<K,V>

setRemoved

public final void setRemoved(boolean marker)
Specified by:
setRemoved in interface InternalNode<K,V>

markAsRemoved

public final void markAsRemoved(boolean marker,
                                boolean recursive)
Specified by:
markAsRemoved in interface InternalNode<K,V>

setResident

public final void setResident(boolean resident)
Specified by:
setResident in interface InternalNode<K,V>

isResident

public final boolean isResident()
Specified by:
isResident in interface InternalNode<K,V>

copy

public final InternalNode<K,V> copy()
Description copied from interface: InternalNode
Creates a new instance of the same type and copies internal state. Note that a shallow copy is made for all fields except the data map, where a new map is created.

Specified by:
copy in interface InternalNode<K,V>
Returns:
a copy.

getLock

public final NodeLock getLock()
Specified by:
getLock in interface InternalNode<K,V>

addChildDirect

public final void addChildDirect(Object nodeName,
                                 Node<K,V> nodeToAdd)
Specified by:
addChildDirect in interface InternalNode<K,V>

addChildDirect

public final void addChildDirect(NodeSPI<K,V> child)
Specified by:
addChildDirect in interface InternalNode<K,V>

printDetails

public final void printDetails(StringBuilder sb,
                               int indent)
Specified by:
printDetails in interface InternalNode<K,V>

toString

public final String toString()
Overrides:
toString in class Object

equals

public final boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public final int hashCode()
Overrides:
hashCode in class Object


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