[jbosscache-commits] JBoss Cache SVN: r6143 - in core/trunk/src/main/java/org/jboss/cache: interceptors and 1 other directory.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Tue Jul 1 09:58:17 EDT 2008


Author: manik.surtani at jboss.com
Date: 2008-07-01 09:58:17 -0400 (Tue, 01 Jul 2008)
New Revision: 6143

Modified:
   core/trunk/src/main/java/org/jboss/cache/NodeFactory.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java
Log:
MVCC-RC

Modified: core/trunk/src/main/java/org/jboss/cache/NodeFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/NodeFactory.java	2008-07-01 13:42:59 UTC (rev 6142)
+++ core/trunk/src/main/java/org/jboss/cache/NodeFactory.java	2008-07-01 13:58:17 UTC (rev 6143)
@@ -18,6 +18,7 @@
 import org.jboss.cache.lock.IsolationLevel;
 import org.jboss.cache.lock.LockStrategyFactory;
 import org.jboss.cache.mvcc.InternalNode;
+import org.jboss.cache.mvcc.NodeReference;
 import org.jboss.cache.mvcc.NullMarkerNode;
 import org.jboss.cache.mvcc.ReadCommittedNode;
 import org.jboss.cache.mvcc.RepeatableReadNode;
@@ -126,9 +127,17 @@
    public NodeSPI<K, V> createDataNode(Object childName, Fqn fqn, NodeSPI<K, V> parent, Map<K, V> data, boolean mapSafe)
    {
       UnversionedNode un = useVersionedNode ? new VersionedNode<K, V>(fqn, parent, data, cache) : new UnversionedNode<K, V>(childName, fqn, data, cache);
+
+      // it is internal nodes that are wrapped in NIDs.
+      InternalNode in = un;
+      if (useVersionedNode && !useRepeatableRead)
+      {
+         // this is MVCC with READ_COMMITTED.  Make sure we use node references.
+         in = new NodeReference(un);
+      }
       // always assume that new nodes do not have data loaded
       un.setDataLoaded(false);
-      NodeInvocationDelegate<K, V> nid = new NodeInvocationDelegate(un);
+      NodeInvocationDelegate<K, V> nid = new NodeInvocationDelegate(in);
 
       // Too slow to have these autowired for now.  Look at manually wiring them.
       nid.initialize(configuration, invocationContextContainer, componentRegistry, interceptorChain);

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java	2008-07-01 13:42:59 UTC (rev 6142)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java	2008-07-01 13:58:17 UTC (rev 6143)
@@ -141,7 +141,7 @@
          ctx.putLookedUpNode(fqn, node);
       }
 
-      if (needToCopyNode && !node.isChanged())
+      if (needToCopyNode && node != null && !node.isChanged()) // node could be null if using read-committed
       {
          node.copyNodeForUpdate(dataContainer, allowWriteSkew, ctx, nodeFactory, lockParentForChildInsertRemove);
       }
@@ -366,16 +366,18 @@
             for (int i = fqnsToUnlock.length - 1; i > -1; i--)
             {
                ReadCommittedNode rcn = (ReadCommittedNode) ctx.lookUpNode(fqnsToUnlock[i]);
-               if (commit)
+               if (rcn != null) // could be null with read-committed
                {
-                  // for each of these, swap refs
-//                  rcn.copyNodeForUpdate(dataContainer, allowWriteSkew);
-                  rcn.commitUpdate(dataContainer, nodeFactory);
+                  if (commit)
+                  {
+                     // for each of these, swap refs
+                     rcn.commitUpdate(dataContainer, nodeFactory);
+                  }
+                  else
+                  {
+                     rcn.rollbackUpdate();
+                  }
                }
-               else
-               {
-                  rcn.rollbackUpdate();
-               }
                // and then unlock
                lockManager.unlock(fqnsToUnlock[i], owner);
             }




More information about the jbosscache-commits mailing list