[jbosscache-commits] JBoss Cache SVN: r5198 - core/trunk/src/test/java/org/jboss/cache/transaction.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Tue Jan 22 14:46:29 EST 2008


Author: manik.surtani at jboss.com
Date: 2008-01-22 14:46:28 -0500 (Tue, 22 Jan 2008)
New Revision: 5198

Modified:
   core/trunk/src/test/java/org/jboss/cache/transaction/PrepareCommitContentionTest.java
Log:
JBCACHE-1270 - use OOB messages for 2-phase commit messages

Modified: core/trunk/src/test/java/org/jboss/cache/transaction/PrepareCommitContentionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/PrepareCommitContentionTest.java	2008-01-22 19:34:40 UTC (rev 5197)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/PrepareCommitContentionTest.java	2008-01-22 19:46:28 UTC (rev 5198)
@@ -2,6 +2,7 @@
 
 import org.jboss.cache.CacheSPI;
 import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
 import org.jboss.cache.RPCManager;
 import org.jboss.cache.RPCManagerImpl;
 import org.jboss.cache.config.Configuration;
@@ -10,7 +11,6 @@
 import org.jboss.cache.marshall.MethodDeclarations;
 import org.jboss.cache.misc.TestingUtil;
 import org.jgroups.Address;
-import org.jgroups.blocks.GroupRequest;
 import org.jgroups.blocks.RspFilter;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
@@ -86,6 +86,7 @@
 
       final CountDownLatch mainThreadCommitLatch = new CountDownLatch(1);
       final CountDownLatch secondThreadPrepareLatch = new CountDownLatch(1);
+      final Fqn fqn = Fqn.fromString("/a/b/c");
 
       DelayingRPCManager delayingRPCManager = new DelayingRPCManager(mainThreadCommitLatch, secondThreadPrepareLatch, syncCommit, noOutOfBandMessages);
       ComponentRegistry cr = TestingUtil.extractComponentRegistry(c1);
@@ -114,13 +115,13 @@
 
             try
             {
-               // now replicate a put on a DIFFERENT node so there is no lock contention
+               // now replicate a put on the SAME node so there is lock contention
                TransactionManager tm = c1.getTransactionManager();
                if (syncCommit)
                   mainThreadCommitLatch.countDown(); // we need to release the main thread commit latch first otherwise it will deadlock!
 
                tm.begin();
-               c1.put("/a/b/c", "k", "v2");
+               c1.put(fqn, "k", "v2");
                tm.commit();
             }
             catch (Exception e)
@@ -133,14 +134,14 @@
 
 
       tm.begin();
-      c1.put("/a/b/c", "k", "v");
+      c1.put(fqn, "k", "v");
       tm.commit();
 
       secondTransaction.join();
 
       // now assert that both transactions have succeeded
-      assert c1.get("/a/b/c", "k").equals("v2");
-      assert c2.get("/a/b/c", "k").equals("v2");
+      assert c1.get(fqn, "k").equals("v2");
+      assert c2.get(fqn, "k").equals("v2");
    }
 
    public static class DelayingRPCManager extends RPCManagerImpl
@@ -172,8 +173,8 @@
                {
                   try
                   {
-                     secondThreadLatch.countDown(); // let the 2nd thread start it's prepapre
-                     mainThreadLatch.await(); // and block arbitrarily until
+                     secondThreadLatch.countDown(); // let the secondTransaction start it's prepapre
+                     mainThreadLatch.await(); // and block arbitrarily until the secondTransaction informs us to proceed
                      Thread.sleep(1000);
                      DelayingRPCManager.super.callRemoteMethods(recipients, methodCall, mode, excludeSelf, timeout, responseFilter, !noOOBMessages && oob);
                   }
@@ -184,10 +185,8 @@
                }
             };
             th.start();
-            if (mode == GroupRequest.GET_ALL) // sync mode!
-            {
-               th.join();
-            }
+            if (syncCommit) th.join();
+
             return Collections.emptyList();
          }
          return super.callRemoteMethods(recipients, methodCall, mode, excludeSelf, timeout, responseFilter, !noOOBMessages && oob);




More information about the jbosscache-commits mailing list