org.jboss.cache.mvcc
Class ReadCommittedNode

java.lang.Object
  extended by org.jboss.cache.invocation.AbstractInvocationDelegate
      extended by org.jboss.cache.invocation.NodeInvocationDelegate
          extended by org.jboss.cache.mvcc.ReadCommittedNode
All Implemented Interfaces:
Node, NodeSPI
Direct Known Subclasses:
RepeatableReadNode

public class ReadCommittedNode
extends NodeInvocationDelegate

A node delegate that encapsulates read committed semantics when writes are initiated, committed or rolled back.

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

Nested Class Summary
protected static class ReadCommittedNode.Flags
           
 
Field Summary
protected  InternalNode backup
           
protected  byte flags
           
protected  InternalNode parent
           
 
Fields inherited from class org.jboss.cache.invocation.NodeInvocationDelegate
node
 
Fields inherited from class org.jboss.cache.invocation.AbstractInvocationDelegate
componentRegistry, configuration, invocationContextContainer, invoker, originLocal
 
Constructor Summary
ReadCommittedNode(InternalNode node, InternalNode parent)
           
 
Method Summary
 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.
 InternalNode getInternalParent()
           
 boolean isChanged()
          Only used with MVCC.
 boolean isCreated()
          Only used with MVCC.
 boolean isDeleted()
          Returns true if the instance has been deleted in the current transaction.
protected  boolean isFlagSet(ReadCommittedNode.Flags flag)
          Tests whether a flag is set.
 boolean isNullNode()
           
protected  InternalNode lookupParent(Fqn fqn, InvocationContext ctx, DataContainer container)
          Performs a lookup for the parent node of the Fqn passed in.
 void markAsDeleted(boolean deleted)
          Marks the node as being deleted (or not) in the current transaction.
 void markAsDeleted(boolean deleted, 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 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 setCreated(boolean created)
          Sets the created flag on a node.
 void setDataLoaded(boolean loaded)
          Sets if the data was loaded from the cache loader.
protected  void setFlag(ReadCommittedNode.Flags flag)
          Unility method that sets the value of the given flag to true.
protected  void unsetFlag(ReadCommittedNode.Flags flag)
          Utility method that sets the value of the flag to false.
protected  void updateNode(Fqn fqn, InvocationContext ctx, DataContainer dataContainer)
          Updates state changes on the current node in the underlying data structure.
 
Methods inherited from class org.jboss.cache.invocation.NodeInvocationDelegate
addChild, addChild, addChildDirect, addChildDirect, addChildDirect, addChildDirect, assertValid, clearData, clearDataDirect, containsKeyDirect, dataSize, equals, get, getCache, getChild, getChild, getChildDirect, getChildDirect, getChildren, getChildrenDirect, getChildrenDirect, getChildrenMapDirect, getChildrenNames, getChildrenNamesDirect, getData, getDataDirect, getDelegationTarget, getDirect, getFqn, getInternalState, getKeys, getKeysDirect, getLock, getOrCreateChild, getParent, getParentDirect, getVersion, hasChild, hasChild, hasChildrenDirect, hashCode, injectDependencies, isChildrenLoaded, isDataLoaded, isLeaf, isLockForChildInsertRemove, isResident, isValid, print, printDetails, put, putAll, putAllDirect, putDirect, putIfAbsent, releaseObjectReferences, remove, removeChild, removeChild, removeChildDirect, removeChildDirect, removeChildrenDirect, removeDirect, replace, replace, replaceAll, setChildrenMapDirect, setFqn, setInternalState, setLockForChildInsertRemove, setResident, setValid, setVersion, toString
 
Methods inherited from class org.jboss.cache.invocation.AbstractInvocationDelegate
assertIsConstructed, initialize
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

backup

protected volatile InternalNode backup

flags

protected byte flags

parent

protected InternalNode parent
Constructor Detail

ReadCommittedNode

public ReadCommittedNode(InternalNode node,
                         InternalNode parent)
Method Detail

getInternalParent

public InternalNode getInternalParent()

isFlagSet

protected final boolean isFlagSet(ReadCommittedNode.Flags flag)
Tests whether a flag is set.

Parameters:
flag - flag to test
Returns:
true if set, false otherwise.

setFlag

protected final void setFlag(ReadCommittedNode.Flags flag)
Unility method that sets the value of the given flag to true.

Parameters:
flag - flag to set

unsetFlag

protected final void unsetFlag(ReadCommittedNode.Flags flag)
Utility method that sets the value of the flag to false.

Parameters:
flag - flag to unset

isNullNode

public boolean isNullNode()
Specified by:
isNullNode in interface NodeSPI
Overrides:
isNullNode in class NodeInvocationDelegate
Returns:
true if the node is a null marker node. Only used with MVCC.

markForUpdate

public void markForUpdate(DataContainer container,
                          boolean writeSkewCheck)
Description copied from interface: NodeSPI
Marks a node for updating. Internally, this creates a copy of the delegate and performs any checks necessary to maintain isolation level.

Only used with MVCC.

Specified by:
markForUpdate in interface NodeSPI
Overrides:
markForUpdate in class NodeInvocationDelegate
Parameters:
container - data container
writeSkewCheck - if true, and the node supports write skew checking, nodes are tested for write skews.

commitUpdate

public void commitUpdate(InvocationContext ctx,
                         DataContainer container)
Description copied from interface: NodeSPI
Commits any updates made on this node to the underlying data structure, making it visible to all other transactions.

Only used with MVCC.

Specified by:
commitUpdate in interface NodeSPI
Overrides:
commitUpdate in class NodeInvocationDelegate
Parameters:
ctx - invocation context
container - data container

lookupParent

protected final InternalNode lookupParent(Fqn fqn,
                                          InvocationContext ctx,
                                          DataContainer container)
                                   throws NodeNotExistsException
Performs a lookup for the parent node of the Fqn passed in. The context is checked first, and failing that, the data container is consulted.

Parameters:
fqn - Fqn whos parent to locate
ctx - invocation context
container - data container
Returns:
Parent node, never null.
Throws:
NodeNotExistsException - if the parent node cannot be found in any scope or data container.

updateNode

protected void updateNode(Fqn fqn,
                          InvocationContext ctx,
                          DataContainer dataContainer)
Updates state changes on the current node in the underlying data structure.

Parameters:
ctx - invocation context
dataContainer - data container

rollbackUpdate

public void rollbackUpdate()
Description copied from interface: NodeSPI
Rolls back any changes made to a node.

Only used with MVCC.

Specified by:
rollbackUpdate in interface NodeSPI
Overrides:
rollbackUpdate in class NodeInvocationDelegate

isChanged

public boolean isChanged()
Description copied from interface: NodeSPI
Only used with MVCC.

Specified by:
isChanged in interface NodeSPI
Overrides:
isChanged in class NodeInvocationDelegate
Returns:
true if this node has been marked for update, false otherwise.

isCreated

public boolean isCreated()
Description copied from interface: NodeSPI
Only used with MVCC.

Specified by:
isCreated in interface NodeSPI
Overrides:
isCreated in class NodeInvocationDelegate
Returns:
true if this node has been newly created in the current scope.

setCreated

public void setCreated(boolean created)
Description copied from interface: NodeSPI
Sets the created flag on a node.

Only used with MVCC.

Specified by:
setCreated in interface NodeSPI
Overrides:
setCreated in class NodeInvocationDelegate
Parameters:
created - flag

isDeleted

public boolean isDeleted()
Description copied from interface: NodeSPI
Returns true if the instance has been deleted in the current transaction.

Specified by:
isDeleted in interface NodeSPI
Overrides:
isDeleted in class NodeInvocationDelegate
Returns:
true if the instance has been deleted in the current transaction.

markAsDeleted

public void markAsDeleted(boolean deleted)
Description copied from interface: NodeSPI
Marks the node as being deleted (or not) in the current transaction. This is not recursive, child nodes are not affected.

Specified by:
markAsDeleted in interface NodeSPI
Overrides:
markAsDeleted in class NodeInvocationDelegate
Parameters:
deleted - true if the node has been deleted, false if not.

markAsDeleted

public void markAsDeleted(boolean deleted,
                          boolean recursive)
Description copied from interface: NodeSPI
Same as NodeSPI.markAsDeleted(boolean) except that the option to recurse into children is provided.

Specified by:
markAsDeleted in interface NodeSPI
Overrides:
markAsDeleted in class NodeInvocationDelegate
Parameters:
deleted - true if the node has been deleted, false if not.
recursive - if true, child nodes (and their children) are marked as well.

setChildrenLoaded

public void setChildrenLoaded(boolean loaded)
Description copied from interface: NodeSPI
Sets if the children of this node were loaded from a cache loader.

Specified by:
setChildrenLoaded in interface NodeSPI
Overrides:
setChildrenLoaded in class NodeInvocationDelegate
Parameters:
loaded - true if loaded, false otherwise

setDataLoaded

public void setDataLoaded(boolean loaded)
Description copied from interface: NodeSPI
Sets if the data was loaded from the cache loader.

Specified by:
setDataLoaded in interface NodeSPI
Overrides:
setDataLoaded in class NodeInvocationDelegate
Parameters:
loaded - true if loaded, false otherwise


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