[jbosscache-commits] JBoss Cache SVN: r7429 - core/trunk/src/test/java/org/jboss/cache/integration/websession.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Fri Jan 9 10:27:29 EST 2009
Author: mircea.markus
Date: 2009-01-09 10:27:29 -0500 (Fri, 09 Jan 2009)
New Revision: 7429
Modified:
core/trunk/src/test/java/org/jboss/cache/integration/websession/BuddyReplicationFailoverTest.java
Log:
more strict replication controll
Modified: core/trunk/src/test/java/org/jboss/cache/integration/websession/BuddyReplicationFailoverTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/integration/websession/BuddyReplicationFailoverTest.java 2009-01-09 15:01:53 UTC (rev 7428)
+++ core/trunk/src/test/java/org/jboss/cache/integration/websession/BuddyReplicationFailoverTest.java 2009-01-09 15:27:29 UTC (rev 7429)
@@ -29,6 +29,7 @@
import org.jboss.cache.buddyreplication.BuddyReplicationTestsBase;
import org.jboss.cache.commands.write.PutDataMapCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
+import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
import org.jboss.cache.integration.websession.util.*;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.FileCacheLoaderConfig;
@@ -55,6 +56,7 @@
public static final String FILE_CL_ROOT_DIR = "./testFiles/BuddyReplicationFailoverTest";
private static int FOLDER_INDEX = 0;
+ ReplicationListener[] replListeners;
@Override
protected String getCacheConfigName()
@@ -78,12 +80,15 @@
public void beforeClass() throws Exception
{
super.beforeClass();
+
+ replListeners = new ReplicationListener[getNumCacheManagers()];
/* Make sure that the buddy group is formed before starting the tests */
List<Cache> createdCaches = new ArrayList<Cache>();
- for (CacheManager cacheMngr : getCacheManagers())
+ for (int i = 0; i < getCacheManagers().size(); i++)
{
- Cache cache = cacheMngr.getCache(getCacheConfigName(), false);
+ Cache cache = getCacheManagers().get(i).getCache(getCacheConfigName(), false);
createdCaches.add(cache);
+ replListeners[i] = ReplicationListener.getReplicationListener(cache);
}
BuddyReplicationTestsBase.waitForSingleBuddy(createdCaches);
}
@@ -124,12 +129,11 @@
// Create the session
SetAttributesServlet sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
- ReplicationListener replListener1 = getReplicationListener(mgr1.getCache());
- replListener1.expectWithTx(PutDataMapCommand.class);
+ replListeners[1].expectWithTx(PutDataMapCommand.class);
Request req = new Request(mgr0, null, sas);
req.execute();
- replListener1.waitForReplicationToOccur();
+ replListeners[1].waitForReplicationToOccur();
String sessionId = sas.getSessionId();
assert sessionId != null : "session id is null";
@@ -138,23 +142,25 @@
// Modify the session
sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
- replListener1.expectWithTx(PutDataMapCommand.class);
+ replListeners[1].expectWithTx(PutDataMapCommand.class);
req = new Request(mgr0, sessionId, sas);
req.execute();
- replListener1.waitForReplicationToOccur();
+ replListeners[1].waitForReplicationToOccur();
// Fail over; request reads the session and then modifies the session
GetAttributesServlet gas = new GetAttributesServlet(Collections.singleton(KEY));
sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
MultipleActionServlet mas = new MultipleActionServlet(gas, sas);
- ReplicationListener replListener0 = getReplicationListener(mgr0.getCache());
- replListener0.expectWithTx(PutDataMapCommand.class);
+ replListeners[0].expectWithTx(PutDataMapCommand.class);
+ replListeners[0].expect(DataGravitationCleanupCommand.class);
+ replListeners[1].expect(DataGravitationCleanupCommand.class);
req = new Request(mgr3, sessionId, mas);
- req.execute();
- replListener0.waitForReplicationToOccur();
-
+ req.execute();
+ replListeners[0].waitForReplicationToOccur();
+ replListeners[1].waitForReplicationToOccur();
+
assert sessionId.equals(mas.getSessionId()) : "wrong session id; expected " + sessionId + " got " + mas.getSessionId();
Integer integer = (Integer) gas.getReadAttributes().get(KEY);
assert integer != null : "null attribute value";
@@ -165,11 +171,11 @@
// Invalidate the session
InvalidationServlet invs = new InvalidationServlet();
- replListener0.expectWithTx(RemoveNodeCommand.class);
+ replListeners[0].expectWithTx(RemoveNodeCommand.class);
req = new Request(mgr3, sessionId, invs);
- req.execute();
- replListener0.waitForReplicationToOccur();
+ req.execute();
+ replListeners[0].waitForReplicationToOccur();
BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr0.getCache());
BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr1.getCache());
@@ -190,12 +196,11 @@
// Create the session
SetAttributesServlet sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
- ReplicationListener replListener2 = getReplicationListener(mgr2.getCache());
- replListener2.expectWithTx(PutDataMapCommand.class);
+ replListeners[2].expectWithTx(PutDataMapCommand.class);
Request req = new Request(mgr1, null, sas);
req.execute();
- replListener2.waitForReplicationToOccur();
+ replListeners[2].waitForReplicationToOccur();
String sessionId = sas.getSessionId();
assert sessionId != null : "session id is null";
@@ -204,23 +209,25 @@
// Modify the session
sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
- replListener2.expectWithTx(PutDataMapCommand.class);
+ replListeners[2].expectWithTx(PutDataMapCommand.class);
req = new Request(mgr1, sessionId, sas);
req.execute();
- replListener2.waitForReplicationToOccur();
+ replListeners[2].waitForReplicationToOccur();
// Fail over; request reads the session and then modifies the session
GetAttributesServlet gas = new GetAttributesServlet(Collections.singleton(KEY));
sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
MultipleActionServlet mas = new MultipleActionServlet(gas, sas);
- ReplicationListener replListener1 = getReplicationListener(mgr1.getCache());
- replListener1.expectWithTx(PutDataMapCommand.class);
-
+ replListeners[1].expectWithTx(PutDataMapCommand.class);
+ replListeners[1].expect(DataGravitationCleanupCommand.class);//data is removed from owner
+ replListeners[2].expect(DataGravitationCleanupCommand.class);//backup tree is removed
+
req = new Request(mgr0, sessionId, mas);
req.execute();
- replListener1.waitForReplicationToOccur();
-
+ replListeners[1].waitForReplicationToOccur();
+ replListeners[2].waitForReplicationToOccur();
+
assert sessionId.equals(mas.getSessionId()) : "wrong session id; expected " + sessionId + " got " + mas.getSessionId();
Integer integer = (Integer) gas.getReadAttributes().get(KEY);
assert integer != null : "null attribute value";
@@ -231,11 +238,11 @@
// Invalidate the session
InvalidationServlet invs = new InvalidationServlet();
- replListener1.expectWithTx(RemoveNodeCommand.class);
-
+ replListeners[1].expectWithTx(RemoveNodeCommand.class);
+
req = new Request(mgr0, sessionId, invs);
req.execute();
- replListener1.waitForReplicationToOccur();
+ replListeners[1].waitForReplicationToOccur();
BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr0.getCache());
BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr1.getCache());
@@ -256,12 +263,11 @@
// Create the session
SetAttributesServlet sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
- ReplicationListener replListener1 = getReplicationListener(mgr1.getCache());
- replListener1.expectWithTx(PutDataMapCommand.class);
+ replListeners[1].expectWithTx(PutDataMapCommand.class);
Request req = new Request(mgr0, null, sas);
req.execute();
- replListener1.waitForReplicationToOccur();
+ replListeners[1].waitForReplicationToOccur();
String sessionId = sas.getSessionId();
assert sessionId != null : "session id is null";
@@ -270,23 +276,25 @@
// Modify the session
sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
- replListener1.expectWithTx(PutDataMapCommand.class);
+ replListeners[1].expectWithTx(PutDataMapCommand.class);
req = new Request(mgr0, sessionId, sas);
req.execute();
- replListener1.waitForReplicationToOccur();
+ replListeners[1].waitForReplicationToOccur();
// Fail over; request reads the session and then modifies the session
GetAttributesServlet gas = new GetAttributesServlet(Collections.singleton(KEY));
sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
MultipleActionServlet mas = new MultipleActionServlet(gas, sas);
- ReplicationListener replListener0 = getReplicationListener(mgr0.getCache());
- replListener0.expectWithTx(PutDataMapCommand.class);
-
+ replListeners[0].expectWithTx(PutDataMapCommand.class);
+ replListeners[0].expect(DataGravitationCleanupCommand.class);
+ replListeners[1].expect(DataGravitationCleanupCommand.class);
+
req = new Request(mgr3, sessionId, mas);
req.execute();
- replListener0.waitForReplicationToOccur();
-
+ replListeners[0].waitForReplicationToOccur();
+ replListeners[1].waitForReplicationToOccur();
+
assert sessionId.equals(mas.getSessionId()) : "wrong session id; expected " + sessionId + " got " + mas.getSessionId();
Integer integer = (Integer) gas.getReadAttributes().get(KEY);
assert integer != null : "null attribute value";
@@ -297,19 +305,19 @@
// Modify the session again
sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
- replListener0.expectWithTx(PutDataMapCommand.class);
+ replListeners[0].expectWithTx(PutDataMapCommand.class);
req = new Request(mgr3, sessionId, sas);
req.execute();
- replListener0.waitForReplicationToOccur();
+ replListeners[0].waitForReplicationToOccur();
// Invalidate the session
InvalidationServlet invs = new InvalidationServlet();
- replListener0.expectWithTx(RemoveNodeCommand.class);
+ replListeners[0].expectWithTx(RemoveNodeCommand.class);
req = new Request(mgr3, sessionId, invs);
req.execute();
- replListener0.waitForReplicationToOccur();
+ replListeners[0].waitForReplicationToOccur();
BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr0.getCache());
BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr1.getCache());
@@ -330,12 +338,11 @@
// Create the session
SetAttributesServlet sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
- ReplicationListener replListener2 = getReplicationListener(mgr2.getCache());
- replListener2.expectWithTx(PutDataMapCommand.class);
+ replListeners[2].expectWithTx(PutDataMapCommand.class);
Request req = new Request(mgr1, null, sas);
req.execute();
- replListener2.waitForReplicationToOccur();
+ replListeners[2].waitForReplicationToOccur();
String sessionId = sas.getSessionId();
assert sessionId != null : "session id is null";
@@ -344,23 +351,24 @@
// Modify the session
sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
- replListener2.expectWithTx(PutDataMapCommand.class);
+ replListeners[2].expectWithTx(PutDataMapCommand.class);
req = new Request(mgr1, sessionId, sas);
req.execute();
- replListener2.waitForReplicationToOccur();
+ replListeners[2].waitForReplicationToOccur();
// Fail over; request reads the session and then modifies the session
GetAttributesServlet gas = new GetAttributesServlet(Collections.singleton(KEY));
sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
MultipleActionServlet mas = new MultipleActionServlet(gas, sas);
- ReplicationListener replListener1 = getReplicationListener(mgr1.getCache());
- replListener1.expectWithTx(PutDataMapCommand.class);
-
+ replListeners[1].expectWithTx(PutDataMapCommand.class);
+ replListeners[2].expect(DataGravitationCleanupCommand.class);
+
req = new Request(mgr0, sessionId, mas);
req.execute();
- replListener1.waitForReplicationToOccur();
-
+ replListeners[1].waitForReplicationToOccur();
+ replListeners[2].waitForReplicationToOccur();
+
assert sessionId.equals(mas.getSessionId()) : "wrong session id; expected " + sessionId + " got " + mas.getSessionId();
Integer integer = (Integer) gas.getReadAttributes().get(KEY);
assert integer != null : "null attribute value";
@@ -371,19 +379,19 @@
// Modify the session again
sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
- replListener1.expectWithTx(PutDataMapCommand.class);
+ replListeners[1].expectWithTx(PutDataMapCommand.class);
req = new Request(mgr0, sessionId, sas);
req.execute();
- replListener1.waitForReplicationToOccur();
+ replListeners[1].waitForReplicationToOccur();
// Invalidate the session
InvalidationServlet invs = new InvalidationServlet();
- replListener1.expectWithTx(RemoveNodeCommand.class);
+ replListeners[1].expectWithTx(RemoveNodeCommand.class);
req = new Request(mgr0, sessionId, invs);
req.execute();
- replListener1.waitForReplicationToOccur();
+ replListeners[1].waitForReplicationToOccur();
BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr0.getCache());
BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr1.getCache());
@@ -404,38 +412,44 @@
// Create the session
SetAttributesServlet sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
- ReplicationListener replListener1 = getReplicationListener(mgr1.getCache());
- replListener1.expectWithTx(PutDataMapCommand.class);
+ replListeners[1].expectWithTx(PutDataMapCommand.class);
Request req = new Request(mgr0, null, sas);
req.execute();
- replListener1.waitForReplicationToOccur();
-
+ replListeners[1].waitForReplicationToOccur();
+ System.out.println("First put on 0, attr=" + attr);
+ TestingUtil.dumpCacheContents(mgr0.getCache(), mgr1.getCache(), mgr2.getCache(), mgr3.getCache());
+
String sessionId = sas.getSessionId();
assert sessionId != null : "session id is null";
// validate cache contents
BuddyReplicationAssertions.assertBuddyBackup(contextHostName, sessionId, mgr0.getCache(), mgr1.getCache());
BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr2.getCache());
BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr3.getCache());
-
+
// Modify the session
sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
- replListener1.expectWithTx(PutDataMapCommand.class);
+ replListeners[1].expectWithTx(PutDataMapCommand.class);
req = new Request(mgr0, sessionId, sas);
req.execute();
- replListener1.waitForReplicationToOccur();
-
+ replListeners[1].waitForReplicationToOccur();
+ System.out.println("Second put on 0, attr=" + attr);
+ TestingUtil.dumpCacheContents(mgr0.getCache(), mgr1.getCache(), mgr2.getCache(), mgr3.getCache());
+
// Fail over; request reads the session and then modifies the session
GetAttributesServlet gas = new GetAttributesServlet(Collections.singleton(KEY));
sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
MultipleActionServlet mas = new MultipleActionServlet(gas, sas);
- ReplicationListener replListener0 = getReplicationListener(mgr0.getCache());
- replListener0.expectWithTx(PutDataMapCommand.class);
+ replListeners[0].expectWithTx(PutDataMapCommand.class);
+ replListeners[1].expect(DataGravitationCleanupCommand.class);
req = new Request(mgr3, sessionId, mas);
req.execute();
- replListener0.waitForReplicationToOccur();
+ replListeners[0].waitForReplicationToOccur();
+ replListeners[1].waitForReplicationToOccur();
+ System.out.println("First put on 3, attr=" + attr);
+ TestingUtil.dumpCacheContents(mgr0.getCache(), mgr1.getCache(), mgr2.getCache(), mgr3.getCache());
assert sessionId.equals(mas.getSessionId()) : "wrong session id; expected " + sessionId + " got " + mas.getSessionId();
Integer integer = (Integer) gas.getReadAttributes().get(KEY);
@@ -448,22 +462,24 @@
// Modify the session again
sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
- replListener0.expectWithTx(PutDataMapCommand.class);
+ replListeners[0].expectWithTx(PutDataMapCommand.class);
req = new Request(mgr3, sessionId, sas);
req.execute();
- replListener0.waitForReplicationToOccur();
+ replListeners[0].waitForReplicationToOccur();
// Fail back; request reads the session and then modifies the session
gas = new GetAttributesServlet(Collections.singleton(KEY));
sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
mas = new MultipleActionServlet(gas, sas);
- replListener1.expectWithTx(PutDataMapCommand.class);
-
+ replListeners[1].expectWithTx(PutDataMapCommand.class);
+ replListeners[3].expect(DataGravitationCleanupCommand.class);
+
req = new Request(mgr0, sessionId, mas);
req.execute();
- replListener1.waitForReplicationToOccur();
-
+ replListeners[1].waitForReplicationToOccur();
+ replListeners[3].waitForReplicationToOccur();
+
assert sessionId.equals(mas.getSessionId()) : "wrong session id; expected " + sessionId + " got " + mas.getSessionId();
integer = (Integer) gas.getReadAttributes().get(KEY);
assert integer != null : "null attribute value";
@@ -475,11 +491,11 @@
// Invalidate the session
InvalidationServlet invs = new InvalidationServlet();
- replListener1.expectWithTx(RemoveNodeCommand.class);
+ replListeners[1].expectWithTx(RemoveNodeCommand.class);
req = new Request(mgr0, sessionId, invs);
req.execute();
- replListener1.waitForReplicationToOccur();
+ replListeners[1].waitForReplicationToOccur();
BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr0.getCache());
BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr1.getCache());
@@ -523,7 +539,7 @@
req = new Request(mgr3, sessionId, sas);
req.execute();
replListener0.waitForReplicationToOccur();
-
+
// Passivate the session
mgr0.passivate(sessionId);
mgr1.passivate(sessionId);
@@ -535,7 +551,7 @@
replListener0.expectWithTx(PutDataMapCommand.class);
req = new Request(mgr3, sessionId, sas);
- req.execute();
+ req.execute();
replListener0.waitForReplicationToOccur();
// Invalidate the session
@@ -544,11 +560,14 @@
MultipleActionServlet mas = new MultipleActionServlet(sas, invs);
ReplicationListener replListener1 = getReplicationListener(mgr1.getCache());
replListener1.expectWithTx(PutDataMapCommand.class, RemoveNodeCommand.class);
-
+ replListener1.expect(DataGravitationCleanupCommand.class);
+
req = new Request(mgr0, sessionId, mas);
req.execute();
replListener1.waitForReplicationToOccur();
+ TestingUtil.dumpCacheContents(mgr0.getCache(), mgr1.getCache(), mgr2.getCache(), mgr3.getCache());
+
BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr0.getCache());
BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr1.getCache());
BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr2.getCache());
More information about the jbosscache-commits
mailing list