Author: mircea.markus
Date: 2009-01-08 08:33:22 -0500 (Thu, 08 Jan 2009)
New Revision: 7405
Modified:
core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesWithFailoverTest.java
Log:
kill the cache rather than using DISCARD
Modified:
core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesWithFailoverTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesWithFailoverTest.java 2009-01-08
13:09:38 UTC (rev 7404)
+++
core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesWithFailoverTest.java 2009-01-08
13:33:22 UTC (rev 7405)
@@ -12,6 +12,7 @@
import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.util.internals.replicationlisteners.ReplicationListener;
import org.jgroups.JChannel;
+import org.jgroups.Address;
import org.jgroups.protocols.DISCARD;
import static org.testng.AssertJUnit.*;
import static org.testng.AssertJUnit.assertEquals;
@@ -122,21 +123,24 @@
assertTrue("Value be true", cachePool.get(1).exists(backupFqn));
assertFalse("Should be false", cachePool.get(2).exists(backupFqn));
+ Address cacheOAddr = cachePool.get(0).getLocalAddress();
// forcefully kill data owner.
- amendDiscard(cachePool.get(0), cachePool.get(1), 2, true);
+ cachePool.get(0).stop();
+ cachePool.get(0).destroy();
+ TestingUtil.blockUntilViewsReceived(10000, cachePool.get(1), cachePool.get(2));
waitForSingleBuddy(cachePool.get(1), cachePool.get(2));
- TestingUtil.dumpCacheContents(cachePool);
+// TestingUtil.dumpCacheContents(cachePool);
// assert that the remaining cachePool have picked new buddies. Cache 1 should
have cache 2's backup data.
assert
cachePool.get(1).peek(fqnTransformer.getBackupRoot(cachePool.get(2).getLocalAddress()),
false) != null : "Should have new buddy's backup root.";
assert
cachePool.get(1).peek(fqnTransformer.getBackupRoot(cachePool.get(1).getLocalAddress()),
false) == null : "Should not have self as a backup root.";
- assert
cachePool.get(1).peek(fqnTransformer.getBackupRoot(cachePool.get(0).getLocalAddress()),
false) == null : "Should not have dead node as a backup root.";
- assert
cachePool.get(1).peek(Fqn.fromRelativeElements(fqnTransformer.getDeadBackupRoot(cachePool.get(0).getLocalAddress()),
1), false) != null : "Should have dead node as a defunct backup root.";
+ assert cachePool.get(1).peek(fqnTransformer.getBackupRoot(cacheOAddr), false) ==
null : "Should not have dead node as a backup root.";
+ assert
cachePool.get(1).peek(Fqn.fromRelativeElements(fqnTransformer.getDeadBackupRoot(cacheOAddr),
1), false) != null : "Should have dead node as a defunct backup root.";
assert
cachePool.get(2).peek(fqnTransformer.getBackupRoot(cachePool.get(2).getLocalAddress()),
false) == null : "Should not have self as a backup root.";
assert
cachePool.get(2).peek(fqnTransformer.getBackupRoot(cachePool.get(1).getLocalAddress()),
false) != null : "Should have new buddy's backup root.";
- assert
cachePool.get(2).peek(fqnTransformer.getBackupRoot(cachePool.get(0).getLocalAddress()),
false) == null : "Should not have dead node as a backup root.";
- assert
cachePool.get(2).peek(Fqn.fromRelativeElements(fqnTransformer.getDeadBackupRoot(cachePool.get(0).getLocalAddress()),
1), false) == null : "Should not have dead node as a defunct backup root.";
+ assert cachePool.get(2).peek(fqnTransformer.getBackupRoot(cacheOAddr), false) ==
null : "Should not have dead node as a backup root.";
+ assert
cachePool.get(2).peek(Fqn.fromRelativeElements(fqnTransformer.getDeadBackupRoot(cacheOAddr),
1), false) == null : "Should not have dead node as a defunct backup root.";
ReplicationListener replListener =
ReplicationListener.getReplicationListener(cachePool.get(1));
replListener.expect(DataGravitationCleanupCommand.class);
@@ -145,7 +149,7 @@
assertEquals("Value should have gravitated", value,
cachePool.get(2).get(fqn, key));
replListener.waitForReplicationToOccur();
- TestingUtil.dumpCacheContents(cachePool);
+// TestingUtil.dumpCacheContents(cachePool);
// now lets test the eviction part of gravitation
Fqn newBackupFqn = fqnTransformer.getBackupFqn(cachePool.get(2).getLocalAddress(),
fqn);
@@ -153,31 +157,18 @@
// use exists instead of get() to prevent going up the interceptor stack
assert
cachePool.get(1).peek(fqnTransformer.getBackupRoot(cachePool.get(2).getLocalAddress()),
false) != null : "Should have new buddy's backup root.";
assert
cachePool.get(1).peek(fqnTransformer.getBackupRoot(cachePool.get(1).getLocalAddress()),
false) == null : "Should not have self as a backup root.";
- assert
cachePool.get(1).peek(fqnTransformer.getBackupRoot(cachePool.get(0).getLocalAddress()),
false) == null : "Should not have dead node as a backup root.";
- assert
cachePool.get(1).peek(Fqn.fromRelativeElements(fqnTransformer.getDeadBackupRoot(cachePool.get(0).getLocalAddress()),
1), false) == null : "Should not have dead node as a defunct backup root.";
- assert
cachePool.get(1).peek(fqnTransformer.getDeadBackupRoot(cachePool.get(0).getLocalAddress()),
false) == null : "Should not have dead node as a defunct backup root.";
+ assert cachePool.get(1).peek(fqnTransformer.getBackupRoot(cacheOAddr), false) ==
null : "Should not have dead node as a backup root.";
+ assert
cachePool.get(1).peek(Fqn.fromRelativeElements(fqnTransformer.getDeadBackupRoot(cacheOAddr),
1), false) == null : "Should not have dead node as a defunct backup root.";
+ assert cachePool.get(1).peek(fqnTransformer.getDeadBackupRoot(cacheOAddr), false)
== null : "Should not have dead node as a defunct backup root.";
assert
cachePool.get(2).peek(fqnTransformer.getBackupRoot(cachePool.get(2).getLocalAddress()),
false) == null : "Should not have self as a backup root.";
assert
cachePool.get(2).peek(fqnTransformer.getBackupRoot(cachePool.get(1).getLocalAddress()),
false) != null : "Should have new buddy's backup root.";
- assert
cachePool.get(2).peek(fqnTransformer.getBackupRoot(cachePool.get(0).getLocalAddress()),
false) == null : "Should not have dead node as a backup root.";
- assert
cachePool.get(2).peek(Fqn.fromRelativeElements(fqnTransformer.getDeadBackupRoot(cachePool.get(0).getLocalAddress()),
1), false) == null : "Should not have dead node as a defunct backup root.";
+ assert cachePool.get(2).peek(fqnTransformer.getBackupRoot(cacheOAddr), false) ==
null : "Should not have dead node as a backup root.";
+ assert
cachePool.get(2).peek(Fqn.fromRelativeElements(fqnTransformer.getDeadBackupRoot(cacheOAddr),
1), false) == null : "Should not have dead node as a defunct backup root.";
assertTrue("Should be false", !cachePool.get(1).exists(fqn));
// the old backup should no longer exist
assertFalse("Should be null", cachePool.get(1).exists(backupFqn));
assertFalse("Should be null", cachePool.get(2).exists(backupFqn));
}
-
- private void amendDiscard(CacheSPI cacheToKill, CacheSPI anotherCache, int
finalExpectedClusterSize, boolean enable)
- {
- JChannel channel = (JChannel) cacheToKill.getRPCManager().getChannel();
- DISCARD discard = (DISCARD)
channel.getProtocolStack().findProtocol(DISCARD.class);
- if (discard != null)
- {
- discard.setDiscardAll(enable);
- TestingUtil.blockUntilViewReceived(anotherCache, finalExpectedClusterSize,
10000, false);
- // an extra second, for some reason we need this.
- TestingUtil.sleepThread(1000);
- }
- }
}