JBoss Cache SVN: r4601 - in core/branches/1.4.X: tests/functional/org/jboss/cache/buddyreplication and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: bstansberry(a)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;
+ }
+ }
+
+ }
+
+
}
16 years, 7 months
JBoss Cache SVN: r4600 - in core/trunk/src: main/java/org/jboss/cache/config and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2007-10-11 09:40:52 -0400 (Thu, 11 Oct 2007)
New Revision: 4600
Modified:
core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
core/trunk/src/main/java/org/jboss/cache/config/Configuration.java
core/trunk/src/test/java/org/jboss/cache/replicated/ExceptionTest.java
Log:
Added a delay to the test so that the SyncReplTimeout is guaranteed to be hit
Modified: core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2007-10-11 12:58:59 UTC (rev 4599)
+++ core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2007-10-11 13:40:52 UTC (rev 4600)
@@ -4138,27 +4138,6 @@
return marshaller_;
}
- /**
- * Returns the default JGroup properties.
- * Subclasses may wish to override this method.
- */
- protected String getDefaultProperties()
- {
- return "UDP(mcast_addr=224.0.0.36;mcast_port=55566;ip_ttl=32;" +
- "mcast_send_buf_size=150000;mcast_recv_buf_size=80000):" +
- "PING(timeout=1000;num_initial_members=2):" +
- "MERGE2(min_interval=5000;max_interval=10000):" +
- "FD_SOCK:" +
- "VERIFY_SUSPECT(timeout=1500):" +
- "pbcast.NAKACK(gc_lag=50;retransmit_timeout=600,1200,2400,4800):" +
- "UNICAST(timeout=600,1200,2400,4800):" +
- "pbcast.STABLE(desired_avg_gossip=20000):" +
- "FRAG(frag_size=8192):" +
- "pbcast.GMS(join_timeout=5000;join_retry_timeout=2000;" +
- "shun=false;print_local_addr=true):" +
- "pbcast.STATE_TRANSFER";
- }
-
private void initialiseCacheLoaderManager() throws CacheException
{
if (cacheLoaderManager == null)
@@ -4225,7 +4204,7 @@
if (configuration.getClusterConfig() == null)
{
log.debug("setting cluster properties to default value");
- configuration.setClusterConfig(getDefaultProperties());
+ configuration.setClusterConfig(configuration.getDefaultClusterConfig());
}
try
{
Modified: core/trunk/src/main/java/org/jboss/cache/config/Configuration.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/Configuration.java 2007-10-11 12:58:59 UTC (rev 4599)
+++ core/trunk/src/main/java/org/jboss/cache/config/Configuration.java 2007-10-11 13:40:52 UTC (rev 4600)
@@ -628,6 +628,27 @@
this.numberOfNotifierThreads = numberOfNotifierThreads;
}
+ /**
+ * Returns the default JGroup properties.
+ */
+ public String getDefaultClusterConfig()
+ {
+ return "UDP(mcast_addr=224.0.0.36;mcast_port=55566;ip_ttl=32;" +
+ "mcast_send_buf_size=150000;mcast_recv_buf_size=80000):" +
+ "PING(timeout=1000;num_initial_members=2):" +
+ "MERGE2(min_interval=5000;max_interval=10000):" +
+ "FD_SOCK:" +
+ "VERIFY_SUSPECT(timeout=1500):" +
+ "pbcast.NAKACK(gc_lag=50;retransmit_timeout=600,1200,2400,4800):" +
+ "UNICAST(timeout=600,1200,2400,4800):" +
+ "pbcast.STABLE(desired_avg_gossip=20000):" +
+ "FRAG(frag_size=8192):" +
+ "pbcast.GMS(join_timeout=5000;join_retry_timeout=2000;" +
+ "shun=false;print_local_addr=true):" +
+ "pbcast.STATE_TRANSFER";
+ }
+
+
// ------------------------------------------------------------------------------------------------------------
// HELPERS
// ------------------------------------------------------------------------------------------------------------
Modified: core/trunk/src/test/java/org/jboss/cache/replicated/ExceptionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/replicated/ExceptionTest.java 2007-10-11 12:58:59 UTC (rev 4599)
+++ core/trunk/src/test/java/org/jboss/cache/replicated/ExceptionTest.java 2007-10-11 13:40:52 UTC (rev 4600)
@@ -1,6 +1,7 @@
package org.jboss.cache.replicated;
import org.jboss.cache.Cache;
+import org.jboss.cache.CacheImpl;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.ReplicationException;
@@ -58,10 +59,19 @@
cache1.getConfiguration().setSyncReplTimeout(1); // 1ms. this is *bound* to fail.
cache2.getConfiguration().setSyncReplTimeout(1);
+ String jgroupsCfg = cache1.getConfiguration().getDefaultClusterConfig();
+ String delay = ":DELAY(in_delay=100;out_delay=100)";
+ String newCfg = jgroupsCfg.substring(0, jgroupsCfg.indexOf(":")) + delay + jgroupsCfg.substring(jgroupsCfg.indexOf(":"));
+
+ System.out.println("JG " + jgroupsCfg);System.out.println("NEW: " + newCfg);
+
+ cache1.getConfiguration().setClusterConfig(newCfg);
+ cache2.getConfiguration().setClusterConfig(newCfg);
+
cache1.start();
cache2.start();
- TestingUtil.blockUntilViewsReceived(10000, cache1, cache2);
+ TestingUtil.blockUntilViewsReceived(60000, cache1, cache2);
cache1.put(fqn, "k", "v");
}
16 years, 7 months
JBoss Cache SVN: r4599 - core/trunk/src/test/java/org/jboss/cache/loader.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2007-10-11 08:58:59 -0400 (Thu, 11 Oct 2007)
New Revision: 4599
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderWithReplicationTest.java
Log:
Prevent an inconsistency in tearDown() from killing the test
Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderWithReplicationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderWithReplicationTest.java 2007-10-11 12:25:57 UTC (rev 4598)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderWithReplicationTest.java 2007-10-11 12:58:59 UTC (rev 4599)
@@ -64,8 +64,15 @@
}
- loader1.remove(fqn);
- cache1.removeNode(fqn);
+ try
+ {
+ loader1.remove(fqn);
+ cache1.removeNode(fqn);
+ }
+ catch (Exception e)
+ {
+
+ }
cache1.stop();
cache1.destroy();
}
@@ -89,8 +96,15 @@
{
}
- loader2.remove(fqn);
- cache2.removeNode(fqn);
+ try
+ {
+ loader2.remove(fqn);
+ cache2.removeNode(fqn);
+ }
+ catch (Exception e)
+ {
+
+ }
cache2.stop();
cache2.destroy();
}
16 years, 7 months
JBoss Cache SVN: r4598 - in core/trunk/src/main/java/org/jboss/cache: interceptors and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2007-10-11 08:25:57 -0400 (Thu, 11 Oct 2007)
New Revision: 4598
Modified:
core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
Log:
Proper resetting of options passed in when overridden
Modified: core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2007-10-10 18:01:21 UTC (rev 4597)
+++ core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2007-10-11 12:25:57 UTC (rev 4598)
@@ -2747,9 +2747,11 @@
if (!configuration.isNodeLockingOptimistic()) return;
// create the node we need.
Map<K, V> m = Collections.emptyMap();
- getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
+ InvocationContext ic = getInvocationContext();
+ boolean origCacheModeLocal = ic.getOptionOverrides().isCacheModeLocal();
+ ic.getOptionOverrides().setCacheModeLocal(true);
put(fqn, m);
- getInvocationContext().getOptionOverrides().setCacheModeLocal(false);
+ ic.getOptionOverrides().setCacheModeLocal(origCacheModeLocal);
NodeSPI nodeSPI = (NodeSPI) root.getChild(fqn);
nodeSPI.setVersion(versionToInvalidate);
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2007-10-10 18:01:21 UTC (rev 4597)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2007-10-11 12:25:57 UTC (rev 4598)
@@ -1129,6 +1129,7 @@
// This is STILL remotely originating though and this needs to be made explicit here.
// this can be checked by inspecting the InvocationContext.isOriginLocal() at the time of registering the sync.
private boolean remoteLocal = false;
+ private Option originalOptions, transactionalOptions;
/**
* A Synchronization for locally originating txs.
@@ -1164,7 +1165,9 @@
}
// set any transaction wide options as current for this thread.
- ctx.setOptionOverrides(entry.getOption());
+ originalOptions = ctx.getOptionOverrides();
+ transactionalOptions = entry.getOption();
+ ctx.setOptionOverrides(transactionalOptions);
try
{
@@ -1207,6 +1210,7 @@
{
localRollbackOnly = false;
setTransactionalContext(null, null, ctx);
+ ctx.setOptionOverrides(originalOptions);
}
}
@@ -1216,7 +1220,15 @@
// could happen if a rollback is called and beforeCompletion() doesn't get called.
if (ctx == null) ctx = cache.getInvocationContext();
ctx.setLocalRollbackOnly(localRollbackOnly);
- super.afterCompletion(status);
+ ctx.setOptionOverrides(transactionalOptions);
+ try
+ {
+ super.afterCompletion(status);
+ }
+ finally
+ {
+ ctx.setOptionOverrides(originalOptions);
+ }
}
public String toString()
16 years, 7 months