[jbosscache-commits] JBoss Cache SVN: r6257 - in core/trunk/src/main/java/org/jboss/cache: mvcc and 1 other directory.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Mon Jul 14 11:35:49 EDT 2008
Author: manik.surtani at jboss.com
Date: 2008-07-14 11:35:49 -0400 (Mon, 14 Jul 2008)
New Revision: 6257
Modified:
core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
core/trunk/src/main/java/org/jboss/cache/mvcc/NullMarkerNode.java
core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java
core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java
Log:
Tidied up NodeFactory implementations
Modified: core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-07-14 14:39:46 UTC (rev 6256)
+++ core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-07-14 15:35:49 UTC (rev 6257)
@@ -128,6 +128,7 @@
this.commandsFactory = commandsFactory;
this.lockStrategyFactory = lockStrategyFactory;
this.nodeFactory = nodeFactory;
+ if (nodeFactory == null) throw new NullPointerException();
init();
}
@@ -263,8 +264,8 @@
{
// construct the new child outside the synchronized block to avoid
// spending any more time than necessary in the synchronized section
- Fqn child_fqn = Fqn.fromRelativeElements(this.fqn, childName);
- NodeSPI newChild = nodeFactory.createNode(childName, Fqn.fromRelativeElements(fqn, childName), delegate, null, true);
+ Fqn childFqn = Fqn.fromRelativeElements(fqn, childName);
+ NodeSPI newChild = nodeFactory.createNode(childName, childFqn, delegate, null, true);
if (newChild == null)
{
throw new IllegalStateException();
@@ -276,13 +277,13 @@
child = (NodeSPI) children().get(childName);
if (child == null)
{
- if (notify) cache.getNotifier().notifyNodeCreated(child_fqn, true, ctx);
+ if (notify) cache.getNotifier().notifyNodeCreated(childFqn, true, ctx);
child = newChild;
children.put(childName, child);
if (gtx != null)
{
- CreateNodeCommand createNodeCommand = commandsFactory.buildCreateNodeCommand(child_fqn);
+ CreateNodeCommand createNodeCommand = commandsFactory.buildCreateNodeCommand(childFqn);
ctx.getTransactionContext().addModification(createNodeCommand);
}
}
@@ -293,9 +294,9 @@
{
if (trace)
{
- log.trace("created child: fqn=" + child_fqn);
+ log.trace("created child: fqn=" + childFqn);
}
- if (notify) cache.getNotifier().notifyNodeCreated(child_fqn, false, ctx);
+ if (notify) cache.getNotifier().notifyNodeCreated(childFqn, false, ctx);
}
}
return child;
@@ -764,6 +765,7 @@
n.children = children;
n.commandsFactory = commandsFactory;
n.delegate = delegate;
+ n.nodeFactory = nodeFactory;
n.flags.clear();
n.flags.addAll(flags);
n.lockStrategyFactory = lockStrategyFactory;
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/NullMarkerNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/NullMarkerNode.java 2008-07-14 14:39:46 UTC (rev 6256)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/NullMarkerNode.java 2008-07-14 15:35:49 UTC (rev 6257)
@@ -19,13 +19,6 @@
super(node);
}
-// to aid with debugging. remove when finalised.
-// @Override
-// protected void assertInternalNodeType()
-// {
-// if (node != null) throw new IllegalArgumentException("NullMarkerNodes can only wrap null values!");
-// }
-
/**
* @return always returns true
*/
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java 2008-07-14 14:39:46 UTC (rev 6256)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java 2008-07-14 15:35:49 UTC (rev 6257)
@@ -25,15 +25,8 @@
public ReadCommittedNode(InternalNode node)
{
super(node);
-// assertInternalNodeType();
}
-// to aid with debugging. remove when finalised.
-// protected void assertInternalNodeType()
-// {
-// if (!(node instanceof NodeReference)) throw new IllegalArgumentException("ReadCommittedNodes can only wrap NodeReferences!");
-// }
-
public boolean isNullNode()
{
return false;
@@ -59,10 +52,6 @@
InternalNode backupDelegationTarget = ((NodeReference) backup).getDelegate();
node = backupDelegationTarget.copy();
}
- // TODO: See if data versions are even needed in the first place!!
- // TODO: Make sure this works with custom versions as well!
-// DataVersion newVersion = ((DefaultDataVersion) node.getVersion()).increment();
-// node.setVersion(newVersion);
}
/**
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java 2008-07-14 14:39:46 UTC (rev 6256)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java 2008-07-14 15:35:49 UTC (rev 6257)
@@ -22,13 +22,6 @@
super(node);
}
-// to aid with debugging. remove when finalised.
-// @Override
-// protected void assertInternalNodeType()
-// {
-// if (!(node instanceof UnversionedNode)) throw new IllegalArgumentException("RepeatableReadNodes can only wrap UnversionedNodes!");
-// }
-
@Override
public void markForUpdate(InvocationContext ctx, DataContainer container, NodeFactory nodeFactory, boolean allowWriteSkew)
{
@@ -41,8 +34,7 @@
// check for write skew.
NodeInvocationDelegate underlyingNode = (NodeInvocationDelegate) container.peek(fqn, false, true); // even check for invalid nodes. we should check tombstones too.
- // TODO: See if data versions are even needed in the first place!!
- //if (!allowWriteSkew && underlyingNode != null && !node.getVersion().equals(underlyingNodeVersion))
+
if (!allowWriteSkew && underlyingNode != null && underlyingNode.getDelegationTarget() != node)
{
String errormsg = new StringBuilder().append("Detected write skew on Fqn [").append(fqn).append("]. Another process has changed the node since we last read it!").toString();
@@ -53,11 +45,6 @@
// make a backup copy
backup = node;
node = backup.copy();
- // TODO: See if data versions are even needed in the first place!!
- // update version on copy
- // TODO: Make sure this works with custom versions as well!
-// DataVersion newVersion = ((DefaultDataVersion) node.getVersion()).increment();
-// node.setVersion(newVersion);
}
@Override
More information about the jbosscache-commits
mailing list