[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/buddyreplication ...
Manik Surtani
msurtani at jboss.com
Fri Nov 10 15:32:52 EST 2006
User: msurtani
Date: 06/11/10 15:32:52
Modified: tests/functional/org/jboss/cache/buddyreplication
BuddyReplicationTestsBase.java
BuddyReplicationWithCacheLoaderTest.java
BuddyReplicationWithTransactionsTest.java
BuddyReplicationFailoverTest.java
Log:
Fixed BR deadlock issue on startup
Revision Changes Path
1.32 +22 -19 JBossCache/tests/functional/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: BuddyReplicationTestsBase.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- BuddyReplicationTestsBase.java 25 Oct 2006 04:50:21 -0000 1.31
+++ BuddyReplicationTestsBase.java 10 Nov 2006 20:32:52 -0000 1.32
@@ -7,17 +7,18 @@
package org.jboss.cache.buddyreplication;
import junit.framework.TestCase;
-import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
import org.jboss.cache.TreeCache;
import org.jboss.cache.config.BuddyReplicationConfig;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.XmlConfigurationParser;
+import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.misc.TestingUtil;
import org.jboss.cache.xml.XmlHelper;
import org.w3c.dom.Element;
+import javax.transaction.TransactionManager;
import java.io.File;
/**
@@ -173,7 +174,7 @@
return caches;
}
- protected void cleanup(TreeCache[] caches)
+ protected void cleanup(TreeCache[] caches) throws Exception
{
System.out.println("*** cleaning up");
@@ -183,27 +184,29 @@
{
if (caches[i] != null)
{
- try
+ destroyCache(caches[i]);
+ caches[i] = null;
+ }
+ }
+ }
+ }
+
+ private void destroyCache(TreeCache c) throws Exception
{
- try
+ TransactionManager tm = c.getTransactionManager();
+ if (tm != null && tm.getTransaction() != null)
{
- caches[i].getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
- caches[i].remove(Fqn.ROOT);
- }
- catch (CacheException e)
+ try
{
- e.printStackTrace(System.out);
- }
- caches[i].stop();
+ tm.rollback();
}
catch (Exception e)
{
- e.printStackTrace(System.out);
- }
- caches[i] = null;
- }
}
}
+ CacheLoader cl = c.getCacheLoader();
+ if (cl != null) cl.remove(Fqn.ROOT);
+ c.stop();
}
protected void printBuddyGroup(TreeCache cache)
1.5 +124 -125 JBossCache/tests/functional/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: BuddyReplicationWithCacheLoaderTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- BuddyReplicationWithCacheLoaderTest.java 25 May 2006 16:36:54 -0000 1.4
+++ BuddyReplicationWithCacheLoaderTest.java 10 Nov 2006 20:32:52 -0000 1.5
@@ -28,7 +28,7 @@
{
CacheLoader[] retVal = new CacheLoader[caches.length];
- for (int i=0; i<retVal.length; i++)
+ for (int i = 0; i < retVal.length; i++)
{
retVal[i] = caches[i].getCacheLoader();
}
@@ -50,16 +50,16 @@
CacheLoader[] loaders = getLoaders(caches);
// cleanup
- for (int i=0; i<3; i++) loaders[i].remove(Fqn.ROOT);
+ for (int i = 0; i < 3; i++) loaders[i].remove(Fqn.ROOT);
- for (int i=0;i<3; i++) System.out.println(i + ": " + loaders[i].get(fqn));
+ for (int i = 0; i < 3; i++) System.out.println(i + ": " + loaders[i].get(fqn));
// put stuff in cache0
caches[0].put(fqn, key, value);
// make sure there are no locks.
assertNoLocks(caches);
- for (int i=0;i<3; i++) System.out.println(i + ": " + loaders[i].get(fqn));
+ for (int i = 0; i < 3; i++) System.out.println(i + ": " + loaders[i].get(fqn));
dumpCacheContents(caches);
@@ -67,11 +67,10 @@
assertEquals(value, caches[2].get(fqn, key));
assertNoLocks(caches);
- for (int i=0;i<3; i++) System.out.println(i + ": " + loaders[i].get(fqn));
+ for (int i = 0; i < 3; i++) System.out.println(i + ": " + loaders[i].get(fqn));
dumpCacheContents(caches);
-
// test that data does not exist in cache0
assertTrue("should not exist in cache0", !caches[0].exists(fqn));
@@ -90,8 +89,8 @@
// test that data does exist in loader2
assertTrue("should exist in loader2", passivation ? !loaders[2].exists(fqn) : loaders[2].exists(fqn));
- Fqn b1 = new Fqn( new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, BuddyManager.getGroupNameFromAddress(caches[0].getLocalAddress())), fqn.peekElements() );
- Fqn b2 = new Fqn( new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, BuddyManager.getGroupNameFromAddress(caches[2].getLocalAddress())), fqn.peekElements() );
+ Fqn b1 = new Fqn(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, BuddyManager.getGroupNameFromAddress(caches[0].getLocalAddress())), fqn.peekElements());
+ Fqn b2 = new Fqn(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, BuddyManager.getGroupNameFromAddress(caches[2].getLocalAddress())), fqn.peekElements());
// test that bkup does exist in cache0
assertTrue("should not exist in cache0", !caches[0].exists(b1));
@@ -154,13 +153,13 @@
assertTrue("should exist in loader0", loaders[0].exists(fqn));
// test that data does not exist in loader1
- assertTrue("should not exist in loader1", passivation ? loaders[1].exists(fqn) : !loaders[1].exists(fqn));
+ assertTrue("should not exist in loader1", !loaders[1].exists(fqn));
// test that data does exist in loader2
assertTrue("should exist in loader2", passivation ? !loaders[2].exists(fqn) : loaders[2].exists(fqn));
- Fqn b1 = new Fqn( new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, BuddyManager.getGroupNameFromAddress(caches[0].getLocalAddress())), fqn.peekElements() );
- Fqn b2 = new Fqn( new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, BuddyManager.getGroupNameFromAddress(caches[2].getLocalAddress())), fqn.peekElements() );
+ Fqn b1 = new Fqn(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, BuddyManager.getGroupNameFromAddress(caches[0].getLocalAddress())), fqn.peekElements());
+ Fqn b2 = new Fqn(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, BuddyManager.getGroupNameFromAddress(caches[2].getLocalAddress())), fqn.peekElements());
// test that bkup does exist in cache0
assertTrue("should not exist in cache0", !caches[0].exists(b1));
@@ -175,7 +174,7 @@
assertTrue("should not exist in cache2", !caches[2].exists(b2));
// test that bkup does exist in loader0
- assertTrue("should not exist in loader0", passivation ? loaders[0].exists(b1) : !loaders[0].exists(b1));
+ assertTrue("should not exist in loader0", !loaders[0].exists(b1));
assertTrue("should exist in loader0", passivation ? !loaders[0].exists(b2) : loaders[0].exists(b2));
// test that bkup does not exist in loader1
1.4 +1 -1 JBossCache/tests/functional/org/jboss/cache/buddyreplication/BuddyReplicationWithTransactionsTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: BuddyReplicationWithTransactionsTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/buddyreplication/BuddyReplicationWithTransactionsTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- BuddyReplicationWithTransactionsTest.java 30 Aug 2006 18:39:42 -0000 1.3
+++ BuddyReplicationWithTransactionsTest.java 10 Nov 2006 20:32:52 -0000 1.4
@@ -22,7 +22,7 @@
private String value = "value";
private TreeCache[] caches;
- protected void tearDown()
+ protected void tearDown() throws Exception
{
if (caches != null)
{
1.18 +1 -1 JBossCache/tests/functional/org/jboss/cache/buddyreplication/BuddyReplicationFailoverTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: BuddyReplicationFailoverTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/buddyreplication/BuddyReplicationFailoverTest.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- BuddyReplicationFailoverTest.java 7 Sep 2006 15:42:16 -0000 1.17
+++ BuddyReplicationFailoverTest.java 10 Nov 2006 20:32:52 -0000 1.18
@@ -22,7 +22,7 @@
private String value = "value";
private TreeCache[] caches;
- protected void tearDown()
+ protected void tearDown() throws Exception
{
if (caches != null)
{
More information about the jboss-cvs-commits
mailing list