[infinispan-commits] Infinispan SVN: r2241 - in branches/4.1.x/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:01:46 EDT 2010
Author: manik.surtani at jboss.com
Date: 2010-08-17 11:01:45 -0400 (Tue, 17 Aug 2010)
New Revision: 2241
Added:
branches/4.1.x/core/src/test/java/org/infinispan/distribution/SyncDistImplicitLockingTest.java
branches/4.1.x/core/src/test/java/org/infinispan/distribution/SyncDistLockingTest.java
Modified:
branches/4.1.x/core/src/main/java/org/infinispan/interceptors/DistributionInterceptor.java
branches/4.1.x/core/src/test/java/org/infinispan/replication/SyncReplImplicitLockingTest.java
branches/4.1.x/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: branches/4.1.x/core/src/main/java/org/infinispan/interceptors/DistributionInterceptor.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/interceptors/DistributionInterceptor.java 2010-08-17 12:10:23 UTC (rev 2240)
+++ branches/4.1.x/core/src/main/java/org/infinispan/interceptors/DistributionInterceptor.java 2010-08-17 15:01:45 UTC (rev 2241)
@@ -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: branches/4.1.x/core/src/test/java/org/infinispan/distribution/SyncDistImplicitLockingTest.java
===================================================================
--- branches/4.1.x/core/src/test/java/org/infinispan/distribution/SyncDistImplicitLockingTest.java (rev 0)
+++ branches/4.1.x/core/src/test/java/org/infinispan/distribution/SyncDistImplicitLockingTest.java 2010-08-17 15:01:45 UTC (rev 2241)
@@ -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: branches/4.1.x/core/src/test/java/org/infinispan/distribution/SyncDistLockingTest.java
===================================================================
--- branches/4.1.x/core/src/test/java/org/infinispan/distribution/SyncDistLockingTest.java (rev 0)
+++ branches/4.1.x/core/src/test/java/org/infinispan/distribution/SyncDistLockingTest.java 2010-08-17 15:01:45 UTC (rev 2241)
@@ -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: branches/4.1.x/core/src/test/java/org/infinispan/replication/SyncReplImplicitLockingTest.java
===================================================================
--- branches/4.1.x/core/src/test/java/org/infinispan/replication/SyncReplImplicitLockingTest.java 2010-08-17 12:10:23 UTC (rev 2240)
+++ branches/4.1.x/core/src/test/java/org/infinispan/replication/SyncReplImplicitLockingTest.java 2010-08-17 15:01:45 UTC (rev 2241)
@@ -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));
@@ -87,8 +95,8 @@
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");
+ Cache cache1 = cache(0,"testcache");
+ Cache cache2 = cache(1,"testcache");
TransactionManager mgr = TestingUtil.getTransactionManager(cache1);
mgr.begin();
@@ -113,8 +121,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);
@@ -170,8 +178,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: branches/4.1.x/core/src/test/java/org/infinispan/replication/SyncReplLockingTest.java
===================================================================
--- branches/4.1.x/core/src/test/java/org/infinispan/replication/SyncReplLockingTest.java 2010-08-17 12:10:23 UTC (rev 2240)
+++ branches/4.1.x/core/src/test/java/org/infinispan/replication/SyncReplLockingTest.java 2010-08-17 15:01:45 UTC (rev 2241)
@@ -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));
@@ -99,8 +107,8 @@
}
public void testReplaceNonExistentKey() 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);
TransactionManager mgr = TestingUtil.getTransactionManager(cache1);
@@ -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