[jbosscache-commits] JBoss Cache SVN: r4601 - in core/branches/1.4.X: tests/functional/org/jboss/cache/buddyreplication and 1 other directory.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Thu Oct 11 13:19:15 EDT 2007
Author: bstansberry at jboss.com
Date: 2007-10-11 13:19:15 -0400 (Thu, 11 Oct 2007)
New Revision: 4601
Modified:
core/branches/1.4.X/src/org/jboss/cache/interceptors/DataGravitatorInterceptor.java
core/branches/1.4.X/tests/functional/org/jboss/cache/buddyreplication/BuddyReplicationFailoverTest.java
Log:
[JBCACHE-1194] Delayed response from backup node should not prevent successful data gravitation
Modified: core/branches/1.4.X/src/org/jboss/cache/interceptors/DataGravitatorInterceptor.java
===================================================================
--- core/branches/1.4.X/src/org/jboss/cache/interceptors/DataGravitatorInterceptor.java 2007-10-11 13:40:52 UTC (rev 4600)
+++ core/branches/1.4.X/src/org/jboss/cache/interceptors/DataGravitatorInterceptor.java 2007-10-11 17:19:15 UTC (rev 4601)
@@ -339,7 +339,8 @@
Boolean searchSubtrees = (buddyManager.isDataGravitationSearchBackupTrees() ? Boolean.TRUE : Boolean.FALSE);
Boolean marshal = cache.getUseRegionBasedMarshalling() ? Boolean.TRUE : Boolean.FALSE;
MethodCall dGrav = MethodCallFactory.create(MethodDeclarations.dataGravitationMethod, new Object[]{fqn, searchSubtrees, marshal});
- List resps = cache.callRemoteMethods(mbrs, dGrav, GroupRequest.GET_FIRST, true, buddyManager.getBuddyCommunicationTimeout());
+ // JBCACHE-1194 This must be GET_ALL, not GET_FIRST
+ List resps = cache.callRemoteMethods(mbrs, dGrav, GroupRequest.GET_ALL, true, buddyManager.getBuddyCommunicationTimeout());
if (resps == null)
{
log.error("No replies to call " + dGrav + ". Perhaps we're alone in the cluster?");
Modified: core/branches/1.4.X/tests/functional/org/jboss/cache/buddyreplication/BuddyReplicationFailoverTest.java
===================================================================
--- core/branches/1.4.X/tests/functional/org/jboss/cache/buddyreplication/BuddyReplicationFailoverTest.java 2007-10-11 13:40:52 UTC (rev 4600)
+++ core/branches/1.4.X/tests/functional/org/jboss/cache/buddyreplication/BuddyReplicationFailoverTest.java 2007-10-11 17:19:15 UTC (rev 4601)
@@ -6,6 +6,10 @@
*/
package org.jboss.cache.buddyreplication;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.cache.AbstractTreeCacheListener;
import org.jboss.cache.TreeCache;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Option;
@@ -208,4 +212,79 @@
assertNoLocks(caches);
}
+
+ /**
+ * Checks that adding a data gravitation delay to the nodes that
+ * actually have the data doesn't prevent successful gravitation.
+ * Test for JBCACHE-1194.
+ *
+ * FIXME This test is currently meaningless because JBCACHE-1192 means
+ * the delaying mechanism doesn't actually work. Test checks for this
+ * and fails at the end with a "known issue" message. Once JBCACHE-1192
+ * is fixed, this test should start working.
+ *
+ * @throws Exception
+ */
+ public void testDelayedResponse() throws Exception
+ {
+ caches = createCaches(4, false, false, optimisticLocks);
+
+ Fqn fqn = Fqn.fromString("/test");
+ Fqn buddyFqn = Fqn.fromString("/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + BuddyManager.getGroupNameFromAddress(caches[0].getLocalAddress()));
+ Fqn backupFqn = new Fqn(buddyFqn, fqn);
+
+ dumpCacheContents(caches);
+
+ caches[0].put(fqn, key, value);
+
+ dumpCacheContents(caches);
+
+ assertEquals("Value should exist on node0", value, caches[0].get(fqn, key));
+ assertNull("Value should not exist on node1", caches[1].get(fqn, key));
+ assertEquals("Backup should exist on node1", value, caches[1].get(backupFqn, key));
+ assertNull("Value should not exist on node2", caches[2].get(fqn, key));
+ assertNull("Backup should not exist on node2", caches[2].get(backupFqn, key));
+ assertNull("Value should not exist on node3", caches[3].get(fqn, key));
+ assertNull("Backup should not exist on node3", caches[3].get(backupFqn, key));
+
+ // Add a listener that will delay data gravitation from node0
+ BlockingListener listener0 = new BlockingListener();
+ caches[1].addTreeCacheListener(listener0);
+
+ // Add a listener that will delay data gravitation from node1
+ BlockingListener listener1 = new BlockingListener();
+ caches[1].addTreeCacheListener(listener1);
+
+ Option opt = new Option();
+ opt.setForceDataGravitation(true);
+ assertEquals("Gravitation to node4 successful", value, caches[3].get(fqn, key, opt));
+
+ // Just double-check the listeners worked as expected
+ assertNull("Listener0 saw no exception", listener0.exception);
+ assertNull("Listener1 saw no exception", listener1.exception);
+ assertTrue("Known issue JBCACHE-1192: listener0 blocked " + fqn, listener0.visited.contains(fqn));
+ assertTrue("Known issue JBCACHE-1192: listener1 blocked " + backupFqn, listener1.visited.contains(backupFqn));
+ }
+
+ private class BlockingListener extends AbstractTreeCacheListener
+ {
+ Exception exception = null;
+ Set visited = new HashSet();
+
+ public void nodeVisited(Fqn fqn)
+ {
+ try
+ {
+ Thread.sleep(2000);
+ visited.add(fqn);
+ }
+ catch (Exception e)
+ {
+ exception = e;
+ }
+ }
+
+ }
+
+
}
More information about the jbosscache-commits
mailing list