[infinispan-commits] Infinispan SVN: r2242 - in trunk/core/src: test/java/org/infinispan/distribution and 1 other directories.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Tue Aug 17 11:44:12 EDT 2010


Author: manik.surtani at jboss.com
Date: 2010-08-17 11:44:12 -0400 (Tue, 17 Aug 2010)
New Revision: 2242

Added:
   trunk/core/src/test/java/org/infinispan/distribution/SyncDistImplicitLockingTest.java
   trunk/core/src/test/java/org/infinispan/distribution/SyncDistLockingTest.java
Modified:
   trunk/core/src/main/java/org/infinispan/interceptors/DistributionInterceptor.java
   trunk/core/src/test/java/org/infinispan/replication/SyncReplImplicitLockingTest.java
   trunk/core/src/test/java/org/infinispan/replication/SyncReplLockingTest.java
Log:
[ISPN-588] (Explicit locking has no effect in distributed mode)
[ISPN-589] (The useEagerLocking config setting has no effect in distributed mode)

Modified: trunk/core/src/main/java/org/infinispan/interceptors/DistributionInterceptor.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/interceptors/DistributionInterceptor.java	2010-08-17 15:01:45 UTC (rev 2241)
+++ trunk/core/src/main/java/org/infinispan/interceptors/DistributionInterceptor.java	2010-08-17 15:44:12 UTC (rev 2242)
@@ -190,7 +190,7 @@
    @Override
    public Object visitLockControlCommand(TxInvocationContext ctx, LockControlCommand command) throws Throwable {
       if (ctx.isOriginLocal())
-         rpcManager.invokeRemotely(dm.getAffectedNodes(ctx.getAffectedKeys()), command, true, true);
+         rpcManager.invokeRemotely(dm.getAffectedNodes(command.getKeys()), command, true, true);
       return invokeNextInterceptor(ctx, command);
    }
 

Added: trunk/core/src/test/java/org/infinispan/distribution/SyncDistImplicitLockingTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/distribution/SyncDistImplicitLockingTest.java	                        (rev 0)
+++ trunk/core/src/test/java/org/infinispan/distribution/SyncDistImplicitLockingTest.java	2010-08-17 15:44:12 UTC (rev 2242)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.infinispan.distribution;
+
+import org.infinispan.Cache;
+import org.infinispan.config.Configuration;
+import org.infinispan.replication.SyncReplImplicitLockingTest;
+import org.infinispan.test.MultipleCacheManagersTest;
+import org.infinispan.test.TestingUtil;
+import org.infinispan.util.concurrent.locks.LockManager;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertNull;
+
+import org.testng.annotations.Test;
+
+import javax.transaction.TransactionManager;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Tests for implicit locking
+ * <p/>
+ * Transparent eager locking for transactions https://jira.jboss.org/jira/browse/ISPN-70
+ *
+ * @author Vladimir Blagojevic
+ */
+ at Test(groups = "functional", testName = "distribution.SyncDistImplicitLockingTest")
+public class SyncDistImplicitLockingTest extends SyncReplImplicitLockingTest {
+   @Override
+   protected Configuration.CacheMode getCacheMode() {
+      return Configuration.CacheMode.DIST_SYNC;
+   }
+}
\ No newline at end of file

Added: trunk/core/src/test/java/org/infinispan/distribution/SyncDistLockingTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/distribution/SyncDistLockingTest.java	                        (rev 0)
+++ trunk/core/src/test/java/org/infinispan/distribution/SyncDistLockingTest.java	2010-08-17 15:44:12 UTC (rev 2242)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.infinispan.distribution;
+
+import org.infinispan.config.Configuration;
+import org.infinispan.replication.SyncReplLockingTest;
+import org.testng.annotations.Test;
+
+/**
+ * Tests for lock API
+ * <p/>
+ * Introduce lock() API methods https://jira.jboss.org/jira/browse/ISPN-48
+ *
+ * @author Manik Surtani
+ * @author Vladimir Blagojevic
+ */
+ at Test(groups = "functional", testName = "distribution.SyncDistLockingTest")
+public class SyncDistLockingTest extends SyncReplLockingTest {
+
+   @Override
+   protected Configuration.CacheMode getCacheMode() {
+      return Configuration.CacheMode.DIST_SYNC;
+   }
+}
\ No newline at end of file

Modified: trunk/core/src/test/java/org/infinispan/replication/SyncReplImplicitLockingTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/replication/SyncReplImplicitLockingTest.java	2010-08-17 15:01:45 UTC (rev 2241)
+++ trunk/core/src/test/java/org/infinispan/replication/SyncReplImplicitLockingTest.java	2010-08-17 15:44:12 UTC (rev 2242)
@@ -42,18 +42,26 @@
  * <p/>
  * Transparent eager locking for transactions https://jira.jboss.org/jira/browse/ISPN-70
  *
- * @author <a href="mailto:vblagoje at redhat.com">Vladimir Blagojevic (vblagoje at redhat.com)</a>
+ * @author Vladimir Blagojevic
  */
 @Test(groups = "functional", testName = "replication.SyncReplImplicitLockingTest")
 public class SyncReplImplicitLockingTest extends MultipleCacheManagersTest {
    //Cache<String, String> cache1, cache2;
    String k = "key", v = "value";
 
+   public SyncReplImplicitLockingTest() {
+      cleanup = CleanupPhase.AFTER_METHOD;
+   }
+
+   protected Configuration.CacheMode getCacheMode() {
+      return Configuration.CacheMode.REPL_SYNC;
+   }   
+
    protected void createCacheManagers() throws Throwable {
-      Configuration replSync = getDefaultClusteredConfig(Configuration.CacheMode.REPL_SYNC, true);
-      replSync.setLockAcquisitionTimeout(500);
-      replSync.setUseEagerLocking(true);
-      createClusteredCaches(2, "replication.SyncReplImplicitLockingTest", replSync);
+      Configuration cfg = getDefaultClusteredConfig(getCacheMode(), true);
+      cfg.setLockAcquisitionTimeout(500);
+      cfg.setUseEagerLocking(true);
+      createClusteredCaches(2, "testcache", cfg);
    }
 
    public void testBasicOperation() throws Exception {
@@ -68,8 +76,8 @@
 
    public void testLocksReleasedWithNoMods() throws Exception {
       assertClusterSize("Should only be 2  caches in the cluster!!!", 2);
-      Cache cache1 = cache(0,"replication.SyncReplImplicitLockingTest");
-      Cache cache2 = cache(1,"replication.SyncReplImplicitLockingTest");
+      Cache cache1 = cache(0,"testcache");
+      Cache cache2 = cache(1,"testcache");
       assertNull("Should be null", cache1.get(k));
       assertNull("Should be null", cache2.get(k));
 
@@ -85,14 +93,14 @@
       cache1.clear();cache2.clear();
    }
    
-	public void testReplaceNonExistentKey() throws Exception {
-		assertClusterSize("Should only be 2  caches in the cluster!!!", 2);
-		Cache cache1 = cache(0, "replication.SyncReplImplicitLockingTest");
-		Cache cache2 = cache(1, "replication.SyncReplImplicitLockingTest");
+   public void testReplaceNonExistentKey() throws Exception {      
+      assertClusterSize("Should only be 2  caches in the cluster!!!", 2);
+      Cache cache1 = cache(0,"testcache");
+      Cache cache2 = cache(1,"testcache");
+     
+      TransactionManager mgr = TestingUtil.getTransactionManager(cache1);
+      mgr.begin();
 
-		TransactionManager mgr = TestingUtil.getTransactionManager(cache1);
-		mgr.begin();
-
 		// do a replace on empty key
 		// https://jira.jboss.org/browse/ISPN-514
 		Object old = cache1.replace(k, "blah");
@@ -114,8 +122,8 @@
    private void concurrentLockingHelper(final boolean sameNode, final boolean useTx)
          throws Exception {
       
-      final Cache cache1 = cache(0,"replication.SyncReplImplicitLockingTest");
-      final Cache cache2 = cache(1,"replication.SyncReplImplicitLockingTest");
+      final Cache cache1 = cache(0,"testcache");
+      final Cache cache2 = cache(1,"testcache");
       
       assertClusterSize("Should only be 2  caches in the cluster!!!", 2);
 
@@ -171,8 +179,8 @@
    }
 
    private void testBasicOperationHelper(boolean useCommit) throws Exception {
-      Cache cache1 = cache(0,"replication.SyncReplImplicitLockingTest");
-      Cache cache2 = cache(1,"replication.SyncReplImplicitLockingTest");
+      Cache cache1 = cache(0,"testcache");
+      Cache cache2 = cache(1,"testcache");
       
       assertClusterSize("Should only be 2  caches in the cluster!!!", 2);
 

Modified: trunk/core/src/test/java/org/infinispan/replication/SyncReplLockingTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/replication/SyncReplLockingTest.java	2010-08-17 15:01:45 UTC (rev 2241)
+++ trunk/core/src/test/java/org/infinispan/replication/SyncReplLockingTest.java	2010-08-17 15:44:12 UTC (rev 2242)
@@ -41,17 +41,25 @@
  * <p/>
  * Introduce lock() API methods https://jira.jboss.org/jira/browse/ISPN-48
  *
- * @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
- * @author <a href="mailto:vblagoje at redhat.com">Vladimir Blagojevic (vblagoje at redhat.com)</a>
+ * @author Manik Surtani
+ * @author Vladimir Blagojevic
  */
 @Test(groups = "functional", testName = "replication.SyncReplLockingTest")
 public class SyncReplLockingTest extends MultipleCacheManagersTest {
    String k = "key", v = "value";
 
+   public SyncReplLockingTest() {
+      cleanup = CleanupPhase.AFTER_METHOD;
+   }
+
+   protected Configuration.CacheMode getCacheMode() {
+      return Configuration.CacheMode.REPL_SYNC;
+   }
+
    protected void createCacheManagers() throws Throwable {
-      Configuration replSync = getDefaultClusteredConfig(Configuration.CacheMode.REPL_SYNC, true);
-      replSync.setLockAcquisitionTimeout(500);
-      createClusteredCaches(2, "replSync", replSync);
+      Configuration cfg = getDefaultClusteredConfig(getCacheMode(), true);
+      cfg.setLockAcquisitionTimeout(500);
+      createClusteredCaches(2, "testcache", cfg);
    }
 
    public void testLocksReleasedWithoutExplicitUnlock() throws Exception {
@@ -73,8 +81,8 @@
 
 
    public void testLocksReleasedWithNoMods() throws Exception {
-      Cache cache1 = cache(0, "replSync");
-      Cache cache2 = cache(1, "replSync");
+      Cache cache1 = cache(0, "testcache");
+      Cache cache2 = cache(1, "testcache");
       assertClusterSize("Should only be 2  caches in the cluster!!!", 2);
 
       assertNull("Should be null", cache1.get(k));
@@ -98,11 +106,11 @@
       cache2.clear();
    }
    
-	public void testReplaceNonExistentKey() throws Exception {
-		Cache cache1 = cache(0, "replSync");
-		Cache cache2 = cache(1, "replSync");
-		assertClusterSize("Should only be 2  caches in the cluster!!!", 2);
-
+   public void testReplaceNonExistentKey() throws Exception {
+      Cache cache1 = cache(0, "testcache");
+      Cache cache2 = cache(1, "testcache");
+      assertClusterSize("Should only be 2  caches in the cluster!!!", 2);
+     
 		TransactionManager mgr = TestingUtil.getTransactionManager(cache1);
 		mgr.begin();
 
@@ -130,8 +138,8 @@
    
    private void concurrentLockingHelper(final boolean sameNode, final boolean useTx)
          throws Exception {
-      final Cache cache1 = cache(0, "replSync");
-      final Cache cache2 = cache(1, "replSync");
+      final Cache cache1 = cache(0, "testcache");
+      final Cache cache2 = cache(1, "testcache");
       assertClusterSize("Should only be 2  caches in the cluster!!!", 2);
 
       assertNull("Should be null", cache1.get(k));
@@ -174,7 +182,7 @@
       t.start();
 
       // wait till the put in thread t times out
-      assert latch.await(1, TimeUnit.SECONDS) : "Concurrent put didn't time out!";
+      assert latch.await(10, TimeUnit.SECONDS) : "Concurrent put didn't time out!";
 
       cache1.put(k, name);
       mgr.commit();
@@ -191,8 +199,8 @@
    private void locksReleasedWithoutExplicitUnlockHelper(boolean lockPriorToPut, boolean useCommit)
          throws Exception {
       
-      Cache cache1 = cache(0, "replSync");
-      Cache cache2 = cache(1, "replSync");
+      Cache cache1 = cache(0, "testcache");
+      Cache cache2 = cache(1, "testcache");
       
       assertClusterSize("Should only be 2  caches in the cluster!!!", 2);
 



More information about the infinispan-commits mailing list