[jbosscache-commits] JBoss Cache SVN: r5250 - in core/trunk/src: test/java/org/jboss/cache/api and 1 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Mon Jan 28 18:55:57 EST 2008


Author: mircea.markus
Date: 2008-01-28 18:55:57 -0500 (Mon, 28 Jan 2008)
New Revision: 5250

Modified:
   core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
   core/trunk/src/test/java/org/jboss/cache/api/NodeAPITest.java
   core/trunk/src/test/java/org/jboss/cache/lock/pessimistic/ConcurrentPutRemoveTest.java
Log:
fixed tests and added an an rolledback the mark node as deleted behavior, in order to supress notifications for temporary created nodes

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java	2008-01-28 22:40:44 UTC (rev 5249)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java	2008-01-28 23:55:57 UTC (rev 5250)
@@ -231,7 +231,7 @@
    protected Object handleRemoveNodeMethod(InvocationContext ctx, GlobalTransaction tx, Fqn fqn, boolean createUndoOps) throws Throwable
    {
       // need to make a note of ALL nodes created here!!
-      List<Fqn> createdNodes = new LinkedList<Fqn>();
+      List<NodeSPI> createdNodes = new LinkedList<NodeSPI>();
       // we need to mark new nodes created as deleted since they are only created to form a path to the node being removed, to
       // create a lock.
       boolean created = acquireLocksWithTimeout(ctx, fqn, NodeLock.LockType.WRITE, true, false, true, false, createdNodes, true);
@@ -239,7 +239,11 @@
       {
          TransactionEntry entry = tx_table.get(ctx.getGlobalTransaction());
          entry.addRemovedNode(fqn);
-         for (Fqn f : createdNodes) entry.addRemovedNode(f);
+         for (NodeSPI nodeSPI : createdNodes)
+         {
+            entry.addRemovedNode(nodeSPI.getFqn());
+            nodeSPI.markAsDeleted(true);
+         }
       }
       acquireLocksOnChildren(peekNode(ctx, fqn, false, false, false), NodeLock.LockType.WRITE, ctx);
       Object retVal = nextInterceptor(ctx);
@@ -248,7 +252,7 @@
       if (ctx.getGlobalTransaction() == null)
       {
 
-         for (Fqn f : createdNodes) cacheImpl.realRemove(f, true);
+         for (NodeSPI nodeSPI : createdNodes) cacheImpl.realRemove(nodeSPI.getFqn(), true);
          cacheImpl.realRemove(fqn, true);
 
          NodeSPI n = peekNode(ctx, fqn, false, true, false);
@@ -328,7 +332,7 @@
 
    private boolean acquireLocksWithTimeout(InvocationContext ctx, Fqn fqn, NodeLock.LockType lockType,
                                            boolean createIfNotExists, boolean zeroLockTimeout,
-                                           boolean acquireLockOnParent, boolean reverseRemoveCheck, List<Fqn> createdNodes, boolean markNewNodesAsDeleted)
+                                           boolean acquireLockOnParent, boolean reverseRemoveCheck, List<NodeSPI> createdNodes, boolean skipNotification)
          throws InterruptedException
    {
       if (fqn == null || configuration.getIsolationLevel() == IsolationLevel.NONE) return false;
@@ -345,7 +349,7 @@
          {
             throw new TimeoutException("Unable to acquire lock on Fqn " + fqn + " after " + timeout + " millis");
          }
-         created = lock(ctx, fqn, lockType, createIfNotExists, timeout, acquireLockOnParent, reverseRemoveCheck, createdNodes, markNewNodesAsDeleted);
+         created = lock(ctx, fqn, lockType, createIfNotExists, timeout, acquireLockOnParent, reverseRemoveCheck, createdNodes, skipNotification);
          firstTry = false;
       }
       while (createIfNotExists && peekNode(ctx, fqn, false, true, false) == null);// keep trying until we have the lock (fixes concurrent remove())
@@ -362,10 +366,10 @@
     *                              reach a node that does not exists
     * @param reverseRemoveCheck    see {@link #manageReverseRemove(org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.NodeSPI, boolean)}
     * @param createdNodes          a list to which any nodes created can register their Fqns so that calling code is aware of which nodes have been newly created.
-    * @param markNewNodesAsDeleted
+    * @param skipNotification
     */
    private boolean lock(InvocationContext ctx, Fqn fqn, NodeLock.LockType lockType, boolean createIfNotExists, long timeout,
-                        boolean acquireWriteLockOnParent, boolean reverseRemoveCheck, List<Fqn> createdNodes, boolean markNewNodesAsDeleted)
+                        boolean acquireWriteLockOnParent, boolean reverseRemoveCheck, List<NodeSPI> createdNodes, boolean skipNotification)
          throws TimeoutException, LockingException, InterruptedException
    {
       Thread currentThread = Thread.currentThread();
@@ -391,11 +395,10 @@
             if (createIfNotExists)
             {
                // if the new node is to be marked as deleted, do not notify!
-               currentNode = parent.addChildDirect(new Fqn(childName), !markNewNodesAsDeleted);
+               currentNode = parent.addChildDirect(new Fqn(childName), !skipNotification);
                created = true;
                if (trace) log.trace("Child node was null, so created child node " + childName);
-               if (createdNodes != null) createdNodes.add(currentNode.getFqn());
-               if (markNewNodesAsDeleted) currentNode.markAsDeleted(true);
+               if (createdNodes != null) createdNodes.add(currentNode);
             }
             else
             {
@@ -429,7 +432,7 @@
             // check if the parent exists!!
             // look into invalidated nodes as well
             currentNode.getLock().releaseAll(owner);
-            if (peekNode(ctx, parent.getFqn(), true, true, true) == null)
+            if (parent == null || peekNode(ctx, parent.getFqn(), true, true, true) == null)
             {
                // crap!
                if (trace) log.trace("Parent has been deleted again.  Go through the lock method all over again.");

Modified: core/trunk/src/test/java/org/jboss/cache/api/NodeAPITest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/NodeAPITest.java	2008-01-28 22:40:44 UTC (rev 5249)
+++ core/trunk/src/test/java/org/jboss/cache/api/NodeAPITest.java	2008-01-28 23:55:57 UTC (rev 5250)
@@ -46,7 +46,7 @@
    public void setUp() throws Exception
    {
       // start a single cache instance
-      cache = (CacheSPI<Object, Object>) new DefaultCacheFactory().createCache("/META-INF/news/local-cache-service.xml", false);
+      cache = (CacheSPI<Object, Object>) new DefaultCacheFactory().createCache("META-INF/conf-test/local-tx-service.xml", false);
       cache.getConfiguration().setNodeLockingScheme(optimistic ? Configuration.NodeLockingScheme.OPTIMISTIC : Configuration.NodeLockingScheme.PESSIMISTIC);
       cache.start();
       rootNode = cache.getRoot();

Modified: core/trunk/src/test/java/org/jboss/cache/lock/pessimistic/ConcurrentPutRemoveTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/pessimistic/ConcurrentPutRemoveTest.java	2008-01-28 22:40:44 UTC (rev 5249)
+++ core/trunk/src/test/java/org/jboss/cache/lock/pessimistic/ConcurrentPutRemoveTest.java	2008-01-28 23:55:57 UTC (rev 5250)
@@ -61,7 +61,7 @@
       }
    }
 
-   @Test(invocationCount = 10, enabled = true)
+   @Test(invocationCount = 25, enabled = true)
    public void testLock() throws Exception
    {
       for (int x = 0; x < 2; x++)
@@ -118,6 +118,8 @@
          }
          catch (Exception e)
          {
+            log.error("*** error on a thread", e);
+//            System.exit(1);
             this.e = e;
          }
       }




More information about the jbosscache-commits mailing list