JBoss Cache SVN: r5513 - in core/tags/2.1.1.GA: src/main/java/org/jboss/cache and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-07 10:46:32 -0400 (Mon, 07 Apr 2008)
New Revision: 5513
Modified:
core/tags/2.1.1.GA/pom.xml
core/tags/2.1.1.GA/src/main/java/org/jboss/cache/Version.java
Log:
GA
Modified: core/tags/2.1.1.GA/pom.xml
===================================================================
--- core/tags/2.1.1.GA/pom.xml 2008-04-07 14:43:56 UTC (rev 5512)
+++ core/tags/2.1.1.GA/pom.xml 2008-04-07 14:46:32 UTC (rev 5513)
@@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
- <jbosscache-core-version>2.1.1.CR1</jbosscache-core-version>
+ <jbosscache-core-version>2.1.1.GA</jbosscache-core-version>
</properties>
<parent>
<groupId>org.jboss.cache</groupId>
@@ -342,7 +342,7 @@
<activeByDefault>false</activeByDefault>
</activation>
<properties>
- <jbosscache-core-version>2.1.1.CR1-JBossAS</jbosscache-core-version>
+ <jbosscache-core-version>2.1.1.GA-JBossAS</jbosscache-core-version>
</properties>
<dependencies>
<dependency>
Modified: core/tags/2.1.1.GA/src/main/java/org/jboss/cache/Version.java
===================================================================
--- core/tags/2.1.1.GA/src/main/java/org/jboss/cache/Version.java 2008-04-07 14:43:56 UTC (rev 5512)
+++ core/tags/2.1.1.GA/src/main/java/org/jboss/cache/Version.java 2008-04-07 14:46:32 UTC (rev 5513)
@@ -11,10 +11,10 @@
@Immutable
public class Version
{
- public static final String version = "2.1.1.CR1";
+ public static final String version = "2.1.1.GA";
public static final String codename = "Alegrias";
//public static final String cvs = "$Id: Version.java 4592 2007-10-10 16:44:36Z manik.surtani(a)jboss.com $";
- static final byte[] version_id = {'0', '2', '1', '1', 'C'};
+ static final byte[] version_id = {'0', '2', '1', '1'};
private static final int MAJOR_SHIFT = 11;
private static final int MINOR_SHIFT = 6;
16 years, 9 months
JBoss Cache SVN: r5512 - core/tags.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-07 10:43:56 -0400 (Mon, 07 Apr 2008)
New Revision: 5512
Added:
core/tags/2.1.1.GA/
Log:
Copied: core/tags/2.1.1.GA (from rev 5511, core/tags/2.1.1.CR1)
16 years, 9 months
JBoss Cache SVN: r5511 - core/trunk/src/test/java/org/jboss/cache/factories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-07 08:55:22 -0400 (Mon, 07 Apr 2008)
New Revision: 5511
Modified:
core/trunk/src/test/java/org/jboss/cache/factories/ComponentRegistryFunctionalTest.java
core/trunk/src/test/java/org/jboss/cache/factories/LateConfigurationTest.java
Log:
Fixed tests
Modified: core/trunk/src/test/java/org/jboss/cache/factories/ComponentRegistryFunctionalTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/factories/ComponentRegistryFunctionalTest.java 2008-04-07 12:52:32 UTC (rev 5510)
+++ core/trunk/src/test/java/org/jboss/cache/factories/ComponentRegistryFunctionalTest.java 2008-04-07 12:55:22 UTC (rev 5511)
@@ -165,6 +165,8 @@
brc.setBuddyLocatorConfig(blc);
configuration.setBuddyReplicationConfig(brc);
+ // needs to be a non-LOCAL configuration
+ configuration.setCacheMode(Configuration.CacheMode.REPL_ASYNC);
BuddyManager bm = cr.getOrCreateComponent(null, componentToTest);
assert bm != null;
Modified: core/trunk/src/test/java/org/jboss/cache/factories/LateConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/factories/LateConfigurationTest.java 2008-04-07 12:52:32 UTC (rev 5510)
+++ core/trunk/src/test/java/org/jboss/cache/factories/LateConfigurationTest.java 2008-04-07 12:55:22 UTC (rev 5511)
@@ -90,8 +90,7 @@
c.getConfiguration().setBuddyReplicationConfig(brc);
c.start();
- assert c.getBuddyManager() != null;
- assert !c.getBuddyManager().isEnabled();
+ assert c.getBuddyManager() == null;
}
public void testBuddyManager()
16 years, 9 months
JBoss Cache SVN: r5510 - in core/tags/2.1.1.CR1: src/main/java/org/jboss/cache and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-07 08:52:32 -0400 (Mon, 07 Apr 2008)
New Revision: 5510
Modified:
core/tags/2.1.1.CR1/pom.xml
core/tags/2.1.1.CR1/src/main/java/org/jboss/cache/Version.java
Log:
Updated version info
Modified: core/tags/2.1.1.CR1/pom.xml
===================================================================
--- core/tags/2.1.1.CR1/pom.xml 2008-04-07 12:47:41 UTC (rev 5509)
+++ core/tags/2.1.1.CR1/pom.xml 2008-04-07 12:52:32 UTC (rev 5510)
@@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
- <jbosscache-core-version>2.1.1-SNAPSHOT</jbosscache-core-version>
+ <jbosscache-core-version>2.1.1.CR1</jbosscache-core-version>
</properties>
<parent>
<groupId>org.jboss.cache</groupId>
@@ -342,7 +342,7 @@
<activeByDefault>false</activeByDefault>
</activation>
<properties>
- <jbosscache-core-version>2.1.1-SNAPSHOT-JBossAS</jbosscache-core-version>
+ <jbosscache-core-version>2.1.1.CR1-JBossAS</jbosscache-core-version>
</properties>
<dependencies>
<dependency>
Modified: core/tags/2.1.1.CR1/src/main/java/org/jboss/cache/Version.java
===================================================================
--- core/tags/2.1.1.CR1/src/main/java/org/jboss/cache/Version.java 2008-04-07 12:47:41 UTC (rev 5509)
+++ core/tags/2.1.1.CR1/src/main/java/org/jboss/cache/Version.java 2008-04-07 12:52:32 UTC (rev 5510)
@@ -11,10 +11,10 @@
@Immutable
public class Version
{
- public static final String version = "2.1.1-SNAPSHOT";
+ public static final String version = "2.1.1.CR1";
public static final String codename = "Alegrias";
//public static final String cvs = "$Id: Version.java 4592 2007-10-10 16:44:36Z manik.surtani(a)jboss.com $";
- static final byte[] version_id = {'0', '2', '1', '1', 'S'};
+ static final byte[] version_id = {'0', '2', '1', '1', 'C'};
private static final int MAJOR_SHIFT = 11;
private static final int MINOR_SHIFT = 6;
16 years, 9 months
JBoss Cache SVN: r5509 - core/tags.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-07 08:47:41 -0400 (Mon, 07 Apr 2008)
New Revision: 5509
Added:
core/tags/2.1.1.CR1/
Log:
Tagged CR1
Copied: core/tags/2.1.1.CR1 (from rev 5508, core/branches/2.1.X)
16 years, 9 months
JBoss Cache SVN: r5508 - core/branches/2.1.X/src/test/java/org/jboss/cache/factories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-07 08:46:11 -0400 (Mon, 07 Apr 2008)
New Revision: 5508
Modified:
core/branches/2.1.X/src/test/java/org/jboss/cache/factories/ComponentRegistryFunctionalTest.java
core/branches/2.1.X/src/test/java/org/jboss/cache/factories/LateConfigurationTest.java
Log:
Updated tests
Modified: core/branches/2.1.X/src/test/java/org/jboss/cache/factories/ComponentRegistryFunctionalTest.java
===================================================================
--- core/branches/2.1.X/src/test/java/org/jboss/cache/factories/ComponentRegistryFunctionalTest.java 2008-04-07 11:27:27 UTC (rev 5507)
+++ core/branches/2.1.X/src/test/java/org/jboss/cache/factories/ComponentRegistryFunctionalTest.java 2008-04-07 12:46:11 UTC (rev 5508)
@@ -165,6 +165,9 @@
brc.setBuddyLocatorConfig(blc);
configuration.setBuddyReplicationConfig(brc);
+ // Cache mode should NOT be local for a buddy manager to be constructed
+ configuration.setCacheMode(Configuration.CacheMode.REPL_ASYNC);
+
BuddyManager bm = cr.getOrCreateComponent(null, componentToTest);
assert bm != null;
Modified: core/branches/2.1.X/src/test/java/org/jboss/cache/factories/LateConfigurationTest.java
===================================================================
--- core/branches/2.1.X/src/test/java/org/jboss/cache/factories/LateConfigurationTest.java 2008-04-07 11:27:27 UTC (rev 5507)
+++ core/branches/2.1.X/src/test/java/org/jboss/cache/factories/LateConfigurationTest.java 2008-04-07 12:46:11 UTC (rev 5508)
@@ -90,8 +90,7 @@
c.getConfiguration().setBuddyReplicationConfig(brc);
c.start();
- assert c.getBuddyManager() != null;
- assert !c.getBuddyManager().isEnabled();
+ assert c.getBuddyManager() == null;
}
public void testBuddyManager()
16 years, 9 months
JBoss Cache SVN: r5507 - in core/trunk/src: test/java/org/jboss/cache/buddyreplication and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-07 07:27:27 -0400 (Mon, 07 Apr 2008)
New Revision: 5507
Modified:
core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyGroupAssignmentTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/GravitationCleanupTest.java
core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java
Log:
JBCACHE-1258: Cleanup of backup regions
Modified: core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-04-07 09:51:48 UTC (rev 5506)
+++ core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-04-07 11:27:27 UTC (rev 5507)
@@ -118,12 +118,14 @@
case LOCAL:
log.debug("cache mode is local, will not create the channel");
isInLocalMode = true;
+ isUsingBuddyReplication = false;
break;
case REPL_SYNC:
case REPL_ASYNC:
case INVALIDATION_ASYNC:
case INVALIDATION_SYNC:
isInLocalMode = false;
+ isUsingBuddyReplication = configuration.getBuddyReplicationConfig() != null && configuration.getBuddyReplicationConfig().isEnabled();
if (log.isDebugEnabled()) log.debug("Cache mode is " + configuration.getCacheMode());
initialiseChannelAndRpcDispatcher();
@@ -171,8 +173,6 @@
}
if (log.isInfoEnabled()) log.info("Cache local address is " + getLocalAddress());
}
-
- isUsingBuddyReplication = configuration.getBuddyReplicationConfig() != null && configuration.getBuddyReplicationConfig().isEnabled();
}
public void disconnect()
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyGroupAssignmentTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyGroupAssignmentTest.java 2008-04-07 09:51:48 UTC (rev 5506)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyGroupAssignmentTest.java 2008-04-07 11:27:27 UTC (rev 5507)
@@ -9,7 +9,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Cache;
-import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
import org.jboss.cache.misc.TestingUtil;
import org.jboss.cache.util.CachePrinter;
import org.testng.annotations.Test;
@@ -29,11 +29,6 @@
log.debug("Running testSingleBuddy");
caches = createCaches(3, false);
- for (CacheSPI cache : caches)
- {
- printBuddyGroup(cache);
- }
-
System.out.println("*** Testing cache 0:");
assertIsBuddy(caches.get(0), caches.get(1), true);
System.out.println("*** Testing cache 1:");
@@ -129,4 +124,61 @@
assertIsBuddy(caches.get(3), caches.get(2), false);
assertNoLocks(caches);
}
+
+ public void testAddingNewCaches() throws Exception
+ {
+ log.debug("Running testAddingNewCaches");
+ caches = createCaches(2, false);
+
+ // get some data in there.
+
+ caches.get(0).put("/cache0", "k", "v");
+ caches.get(1).put("/cache1", "k", "v");
+
+ System.out.println("*** Testing cache 0:");
+ assertIsBuddy(caches.get(0), caches.get(1), true);
+ System.out.println("*** Testing cache 1:");
+ assertIsBuddy(caches.get(1), caches.get(0), true);
+
+ assert caches.get(0).peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE, BuddyManager.getGroupNameFromAddress(caches.get(0).getLocalAddress())), false) == null : "Should not have backup region for self";
+ assert caches.get(0).peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE, BuddyManager.getGroupNameFromAddress(caches.get(1).getLocalAddress())), false) != null : "Should have backup region for buddy";
+
+ assert caches.get(1).peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE, BuddyManager.getGroupNameFromAddress(caches.get(0).getLocalAddress())), false) != null : "Should have backup region for buddy";
+ assert caches.get(1).peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE, BuddyManager.getGroupNameFromAddress(caches.get(1).getLocalAddress())), false) == null : "Should not have backup region for self";
+
+ caches.add(createCache(1, null));
+
+ TestingUtil.blockUntilViewsReceived(60000, caches);
+
+ System.out.println("*** Testing cache 0:");
+ assertIsBuddy(caches.get(0), caches.get(1), true);
+ System.out.println("*** Testing cache 1:");
+ assertIsBuddy(caches.get(1), caches.get(2), true);
+ System.out.println("*** Testing cache 2:");
+ assertIsBuddy(caches.get(2), caches.get(0), true);
+
+
+ System.out.println("0 Lock info: " + CachePrinter.printCacheLockingInfo(caches.get(0)));
+ System.out.println("1 Lock info: " + CachePrinter.printCacheLockingInfo(caches.get(1)));
+ System.out.println("2 Lock info: " + CachePrinter.printCacheLockingInfo(caches.get(2)));
+
+ assert caches.get(0).peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE, BuddyManager.getGroupNameFromAddress(caches.get(0).getLocalAddress())), false) == null : "Should not have backup region for self";
+ assert caches.get(0).peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE, BuddyManager.getGroupNameFromAddress(caches.get(1).getLocalAddress())), false) == null : "Should have backup region for non-buddy";
+ assert caches.get(0).peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE, BuddyManager.getGroupNameFromAddress(caches.get(2).getLocalAddress())), false) != null : "Should have backup region for buddy";
+
+ assert caches.get(1).peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE, BuddyManager.getGroupNameFromAddress(caches.get(0).getLocalAddress())), false) != null : "Should have backup region for buddy";
+ assert caches.get(1).peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE, BuddyManager.getGroupNameFromAddress(caches.get(1).getLocalAddress())), false) == null : "Should not have backup region for self";
+ assert caches.get(1).peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE, BuddyManager.getGroupNameFromAddress(caches.get(2).getLocalAddress())), false) == null : "Should not have backup region for non-buddy";
+
+ assert caches.get(2).peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE, BuddyManager.getGroupNameFromAddress(caches.get(0).getLocalAddress())), false) == null : "Should not have backup region for non-buddy";
+ assert caches.get(2).peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE, BuddyManager.getGroupNameFromAddress(caches.get(1).getLocalAddress())), false) != null : "Should have backup region for buddy";
+ assert caches.get(2).peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE, BuddyManager.getGroupNameFromAddress(caches.get(2).getLocalAddress())), false) == null : "Should not have backup region for self";
+
+ // ensure no state transfer has happened!!
+ assert caches.get(2).peek(Fqn.fromString("/cache0"), false) == null : "Unnecessary state should not have been transferred!";
+ assert caches.get(2).peek(Fqn.fromString("/cache1"), false) == null : "Unnecessary state should not have been transferred!";
+
+ // ensure backup state has been transferred.
+ assert caches.get(2).peek(BuddyManager.getBackupFqn(caches.get(1).getLocalAddress(), Fqn.fromString("/cache1")), false) != null : "Backup state should have transferred!";
+ }
}
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java 2008-04-07 09:51:48 UTC (rev 5506)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java 2008-04-07 11:27:27 UTC (rev 5507)
@@ -127,7 +127,7 @@
protected CacheSPI<Object, Object> createCache(boolean optimisticLocks, int numBuddies, String buddyPoolName, boolean useDataGravitation, boolean removeOnFind, boolean start) throws Exception
{
- CacheSPI<Object, Object> c = (CacheSPI<Object, Object>) new DefaultCacheFactory().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), false);
+ CacheSPI<Object, Object> c = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), false);
c.getConfiguration().setClusterName("BuddyReplicationTest");
// basic config
String xmlString = "<config><buddyReplicationEnabled>true</buddyReplicationEnabled>\n" +
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/GravitationCleanupTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/GravitationCleanupTest.java 2008-04-07 09:51:48 UTC (rev 5506)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/GravitationCleanupTest.java 2008-04-07 11:27:27 UTC (rev 5507)
@@ -120,6 +120,5 @@
assert buddy.peek(fqn, false) == null : "Should not have data";
assert buddy.peek(fqn.getParent(), false) == null : "Should not have any part of the data";
assert buddy.peek(BuddyManager.getBackupFqn(dataOwner.getLocalAddress(), fqn), false) == null : "Should NOT have backup data";
-
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java 2008-04-07 09:51:48 UTC (rev 5506)
+++ core/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java 2008-04-07 11:27:27 UTC (rev 5507)
@@ -552,4 +552,9 @@
}
throw new RuntimeException("Timed out waiting for condition");
}
+
+ public static void blockUntilViewsReceived(int timeout, List caches)
+ {
+ blockUntilViewsReceived((Cache[]) caches.toArray(new Cache[]{}), timeout);
+ }
}
16 years, 9 months
JBoss Cache SVN: r5506 - core/branches/2.1.X/src/test/java/org/jboss/cache/lock.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-07 05:51:48 -0400 (Mon, 07 Apr 2008)
New Revision: 5506
Modified:
core/branches/2.1.X/src/test/java/org/jboss/cache/lock/LockReleaseTest.java
Log:
Improved inter-thread comms in test
Modified: core/branches/2.1.X/src/test/java/org/jboss/cache/lock/LockReleaseTest.java
===================================================================
--- core/branches/2.1.X/src/test/java/org/jboss/cache/lock/LockReleaseTest.java 2008-04-07 09:48:44 UTC (rev 5505)
+++ core/branches/2.1.X/src/test/java/org/jboss/cache/lock/LockReleaseTest.java 2008-04-07 09:51:48 UTC (rev 5506)
@@ -12,19 +12,14 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.NodeNotExistsException;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.transaction.TransactionSetup;
-import static org.testng.AssertJUnit.*;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.fail;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import javax.transaction.UserTransaction;
-import javax.transaction.Transaction;
-import javax.transaction.NotSupportedException;
-import javax.transaction.SystemException;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -35,7 +30,7 @@
* @author Bela Ban
* @version $Id$
*/
-@Test(groups = {"functional"})
+@Test(groups = "functional")
public class LockReleaseTest
{
CacheSPI<Object, Object> cache = null;
@@ -241,55 +236,51 @@
public void testNodeReleaseOnAcquisitionTimeout() throws Exception
{
cache = createCache(IsolationLevel.REPEATABLE_READ);
- cache.put("/a/b","key","value");
- cache.put("/c","key","value");
- final Object rLockAcquired = new Object();
- final Object wlTimeouted = new Object();
- final Object txLocksReleased = new Object();
- Thread thread = new Thread() {
+ cache.put("/a/b", "key", "value");
+ cache.put("/c", "key", "value");
+ final CountDownLatch rLockAcquired = new CountDownLatch(1);
+ final CountDownLatch wlTimeouted = new CountDownLatch(1);
+ final CountDownLatch txLocksReleased = new CountDownLatch(1);
+
+
+ Thread thread = new Thread()
+ {
public void run()
{
try
{
cache.getTransactionManager().begin();
cache.get("/a/b", "key"); //at this point we have an RL on /c and /c/d
- synchronized (rLockAcquired)
- {
- rLockAcquired.notify();
- }
- synchronized ( wlTimeouted)
- {
- wlTimeouted.wait(50000); //wait a long time but die eventually
- }
+ rLockAcquired.countDown();
+ wlTimeouted.await(60, TimeUnit.SECONDS); //wait a long time but die eventually
+
cache.getTransactionManager().commit();//here we are releasing locks
- synchronized (txLocksReleased)
- {
- txLocksReleased.notify();
- }
- }
- catch(Exception ex)
+
+ txLocksReleased.countDown();
+ }
+ catch (Exception ex)
{
ex.printStackTrace();
}
}
};
+
thread.start();
- synchronized (rLockAcquired) { rLockAcquired.wait(50000); }
+
+ rLockAcquired.await();
+
try
{
- cache.move("/a/b","c"); //acquired RL on /a and /a/b
+ cache.move("/a/b", "c"); //acquired RL on /a and /a/b
fail("expected timeout here");
- } catch (TimeoutException e)
- {
- synchronized (wlTimeouted)
- {
- wlTimeouted.notify();
- }
}
- synchronized (txLocksReleased)
+ catch (TimeoutException e)
{
- txLocksReleased.wait();//wait for tx locks to be released
+ wlTimeouted.countDown();
}
+
+ txLocksReleased.await(); //wait for tx locks to be released
+
assertEquals(0, cache.getNumberOfLocksHeld());
System.out.println("LockReleaseTest.testNodeReleaseOnAcquisitionTimeout finished!");
}
16 years, 9 months
JBoss Cache SVN: r5505 - core/trunk/src/test/java/org/jboss/cache/lock.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-07 05:48:44 -0400 (Mon, 07 Apr 2008)
New Revision: 5505
Modified:
core/trunk/src/test/java/org/jboss/cache/lock/LockReleaseTest.java
Log:
Improved test accuracy
Modified: core/trunk/src/test/java/org/jboss/cache/lock/LockReleaseTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/LockReleaseTest.java 2008-04-07 08:45:18 UTC (rev 5504)
+++ core/trunk/src/test/java/org/jboss/cache/lock/LockReleaseTest.java 2008-04-07 09:48:44 UTC (rev 5505)
@@ -12,19 +12,14 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.NodeNotExistsException;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.transaction.TransactionSetup;
-import static org.testng.AssertJUnit.*;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.fail;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import javax.transaction.UserTransaction;
-import javax.transaction.Transaction;
-import javax.transaction.NotSupportedException;
-import javax.transaction.SystemException;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -241,55 +236,51 @@
public void testNodeReleaseOnAcquisitionTimeout() throws Exception
{
cache = createCache(IsolationLevel.REPEATABLE_READ);
- cache.put("/a/b","key","value");
- cache.put("/c","key","value");
- final Object rLockAcquired = new Object();
- final Object wlTimeouted = new Object();
- final Object txLocksReleased = new Object();
- Thread thread = new Thread() {
+ cache.put("/a/b", "key", "value");
+ cache.put("/c", "key", "value");
+ final CountDownLatch rLockAcquired = new CountDownLatch(1);
+ final CountDownLatch wlTimeouted = new CountDownLatch(1);
+ final CountDownLatch txLocksReleased = new CountDownLatch(1);
+
+
+ Thread thread = new Thread()
+ {
public void run()
{
try
{
cache.getTransactionManager().begin();
cache.get("/a/b", "key"); //at this point we have an RL on /c and /c/d
- synchronized (rLockAcquired)
- {
- rLockAcquired.notify();
- }
- synchronized ( wlTimeouted)
- {
- wlTimeouted.wait(50000); //wait a long time but die eventually
- }
+ rLockAcquired.countDown();
+ wlTimeouted.await(60, TimeUnit.SECONDS); //wait a long time but die eventually
+
cache.getTransactionManager().commit();//here we are releasing locks
- synchronized (txLocksReleased)
- {
- txLocksReleased.notify();
- }
- }
- catch(Exception ex)
+
+ txLocksReleased.countDown();
+ }
+ catch (Exception ex)
{
ex.printStackTrace();
}
}
};
+
thread.start();
- synchronized (rLockAcquired) { rLockAcquired.wait(50000); }
+
+ rLockAcquired.await();
+
try
{
- cache.move("/a/b","c"); //acquired RL on /a and /a/b
+ cache.move("/a/b", "c"); //acquired RL on /a and /a/b
fail("expected timeout here");
- } catch (TimeoutException e)
- {
- synchronized (wlTimeouted)
- {
- wlTimeouted.notify();
- }
}
- synchronized (txLocksReleased)
+ catch (TimeoutException e)
{
- txLocksReleased.wait();//wait for tx locks to be released
+ wlTimeouted.countDown();
}
+
+ txLocksReleased.await(); //wait for tx locks to be released
+
assertEquals(0, cache.getNumberOfLocksHeld());
System.out.println("LockReleaseTest.testNodeReleaseOnAcquisitionTimeout finished!");
}
16 years, 9 months
JBoss Cache SVN: r5504 - in core/trunk/src: test/java/org/jboss/cache/buddyreplication and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-07 04:45:18 -0400 (Mon, 07 Apr 2008)
New Revision: 5504
Modified:
core/trunk/src/main/java/org/jboss/cache/factories/BuddyManagerFactory.java
core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationConfigTest.java
Log:
JBCACHE-1319: NPE with CacheMode.LOCAL and buddy replication enabled
Modified: core/trunk/src/main/java/org/jboss/cache/factories/BuddyManagerFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/BuddyManagerFactory.java 2008-04-07 08:44:57 UTC (rev 5503)
+++ core/trunk/src/main/java/org/jboss/cache/factories/BuddyManagerFactory.java 2008-04-07 08:45:18 UTC (rev 5504)
@@ -1,6 +1,7 @@
package org.jboss.cache.factories;
import org.jboss.cache.buddyreplication.BuddyManager;
+import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.annotations.DefaultFactoryFor;
/**
@@ -15,7 +16,7 @@
@Override
public <T> T construct(String componentName, Class<T> componentType)
{
- if (configuration.getBuddyReplicationConfig() != null && configuration.getBuddyReplicationConfig().isEnabled())
+ if (configuration.getBuddyReplicationConfig() != null && configuration.getBuddyReplicationConfig().isEnabled() && configuration.getCacheMode() != Configuration.CacheMode.LOCAL)
{
return super.construct(componentName, componentType);
}
Modified: core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java 2008-04-07 08:44:57 UTC (rev 5503)
+++ core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java 2008-04-07 08:45:18 UTC (rev 5504)
@@ -160,7 +160,7 @@
private boolean isUsingBuddyReplication()
{
- return configuration.getBuddyReplicationConfig() != null && configuration.getBuddyReplicationConfig().isEnabled();
+ return configuration.getBuddyReplicationConfig() != null && configuration.getBuddyReplicationConfig().isEnabled() && configuration.getCacheMode() != Configuration.CacheMode.LOCAL;
}
public Interceptor setFirstInterceptor(Class<? extends Interceptor> clazz) throws IllegalAccessException, InstantiationException
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationConfigTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationConfigTest.java 2008-04-07 08:44:57 UTC (rev 5503)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationConfigTest.java 2008-04-07 08:45:18 UTC (rev 5504)
@@ -8,6 +8,7 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
import org.jboss.cache.config.BuddyReplicationConfig;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.XmlConfigurationParser;
@@ -38,7 +39,7 @@
public void testNullConfig() throws Exception
{
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory().createCache(false);
+ cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
cache.getConfiguration().setBuddyReplicationConfig(null);
assertNull(cache.getBuddyManager());
}
@@ -48,7 +49,7 @@
String xmlConfig = "<config><buddyReplicationEnabled>false</buddyReplicationEnabled></config>";
Element element = XmlHelper.stringToElement(xmlConfig);
BuddyReplicationConfig config = XmlConfigurationParser.parseBuddyReplicationConfig(element);
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory().createCache(false);
+ cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
cache.getConfiguration().setBuddyReplicationConfig(config);
assertNull(cache.getBuddyManager());
}
@@ -58,7 +59,7 @@
String xmlConfig = "<config><buddyReplicationEnabled>true</buddyReplicationEnabled></config>";
Element element = XmlHelper.stringToElement(xmlConfig);
BuddyReplicationConfig config = XmlConfigurationParser.parseBuddyReplicationConfig(element);
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory().createCache(false);
+ cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
cache.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
cache.getConfiguration().setBuddyReplicationConfig(config);
cache.create();
@@ -75,7 +76,7 @@
public void testXmlConfig() throws Exception
{
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory().createCache(new XmlConfigurationParser().parseFile("META-INF/buddy-replication-cache-service.xml"), false);
+ cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(new XmlConfigurationParser().parseFile("META-INF/buddy-replication-cache-service.xml"), false);
cache.create();
cache.start();
BuddyManager bm = cache.getBuddyManager();
@@ -100,4 +101,19 @@
assertTrue("Should have a data gravitator!!", hasDG);
}
+
+ public void testLocalModeConfig() throws Exception
+ {
+ String xmlConfig = "<config><buddyReplicationEnabled>true</buddyReplicationEnabled></config>";
+ Element element = XmlHelper.stringToElement(xmlConfig);
+ BuddyReplicationConfig config = XmlConfigurationParser.parseBuddyReplicationConfig(element);
+ cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
+ cache.getConfiguration().setBuddyReplicationConfig(config);
+ cache.create();
+ cache.start();
+ assert cache.getBuddyManager() == null;
+
+ cache.getInvocationContext().getOptionOverrides().setForceDataGravitation(true);
+ cache.getNode(Fqn.fromString("/nonexistent")); // should not barf!
+ }
}
\ No newline at end of file
16 years, 9 months