[infinispan-commits] Infinispan SVN: r363 - in trunk/core/src/test/java/org/infinispan: test and 1 other directory.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Fri May 29 11:57:01 EDT 2009
Author: mircea.markus
Date: 2009-05-29 11:57:01 -0400 (Fri, 29 May 2009)
New Revision: 363
Modified:
trunk/core/src/test/java/org/infinispan/distribution/DistAsyncTxFuncTest.java
trunk/core/src/test/java/org/infinispan/distribution/DistSyncTxFuncTest.java
trunk/core/src/test/java/org/infinispan/test/ReplListener.java
Log:
more strict replication control
Modified: trunk/core/src/test/java/org/infinispan/distribution/DistAsyncTxFuncTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/distribution/DistAsyncTxFuncTest.java 2009-05-29 15:55:38 UTC (rev 362)
+++ trunk/core/src/test/java/org/infinispan/distribution/DistAsyncTxFuncTest.java 2009-05-29 15:57:01 UTC (rev 363)
@@ -2,13 +2,15 @@
import org.infinispan.Cache;
import org.infinispan.commands.VisitableCommand;
-import org.infinispan.commands.write.InvalidateCommand;
+import org.infinispan.commands.write.InvalidateL1Command;
import org.infinispan.test.ReplListener;
import org.testng.annotations.Test;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -40,21 +42,25 @@
@Override
protected void asyncWait(Object key, Class<? extends VisitableCommand> command, Cache<?, ?>... cachesOnWhichKeyShouldInval) {
+ if (cachesOnWhichKeyShouldInval == null) cachesOnWhichKeyShouldInval = new Cache[0];
+ List<Cache<?, ?>> cachesOnWhichKeyShouldInvalList = new ArrayList(Arrays.asList(cachesOnWhichKeyShouldInval));
if (key == null) {
// test all caches.
for (ReplListener rl : r) rl.expect(command);
for (ReplListener rl : r) rl.waitForRpc();
} else {
for (Cache<?, ?> c : getOwners(key)) {
- listenerLookup.get(c).expect(command);
+ if (cachesOnWhichKeyShouldInvalList.remove(c)) {
+ listenerLookup.get(c).expect(command, InvalidateL1Command.class);
+ } else {
+ listenerLookup.get(c).expect(command);
+ }
listenerLookup.get(c).waitForRpc();
}
- if (cachesOnWhichKeyShouldInval != null) {
- for (Cache<?, ?> c : cachesOnWhichKeyShouldInval) {
- listenerLookup.get(c).expect(InvalidateCommand.class);
- listenerLookup.get(c).waitForRpc();
- }
+ for (Cache<?, ?> c : cachesOnWhichKeyShouldInvalList) {
+ listenerLookup.get(c).expect(InvalidateL1Command.class);
+ listenerLookup.get(c).waitForRpc();
}
}
}
Modified: trunk/core/src/test/java/org/infinispan/distribution/DistSyncTxFuncTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/distribution/DistSyncTxFuncTest.java 2009-05-29 15:55:38 UTC (rev 362)
+++ trunk/core/src/test/java/org/infinispan/distribution/DistSyncTxFuncTest.java 2009-05-29 15:57:01 UTC (rev 363)
@@ -24,10 +24,10 @@
protected void init(MagicKey k1, MagicKey k2) {
// neither key maps on to c4
c2.put(k1, "value1");
- asyncWait(k1, PutKeyValueCommand.class);
+ asyncWait(k1, PutKeyValueCommand.class, c1, c3, c4);
c2.put(k2, "value2");
- asyncWait(k2, PutKeyValueCommand.class);
+ asyncWait(k2, PutKeyValueCommand.class, c1, c3, c4);
assertIsInContainerImmortal(c1, k1);
assertIsInContainerImmortal(c2, k1);
Modified: trunk/core/src/test/java/org/infinispan/test/ReplListener.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/test/ReplListener.java 2009-05-29 15:55:38 UTC (rev 362)
+++ trunk/core/src/test/java/org/infinispan/test/ReplListener.java 2009-05-29 15:57:01 UTC (rev 363)
@@ -130,8 +130,8 @@
this.expectedCommands = new LinkedList<Class<? extends VisitableCommand>>();
}
this.expectedCommands.addAll(Arrays.asList(expectedCommands));
- log.trace("Setting expected commands to {0}", this.expectedCommands);
- log.trace("Record eagerly is {0}, and eager commands are {1}", recordCommandsEagerly, eagerCommands);
+ info("Setting expected commands to " + this.expectedCommands);
+ info("Record eagerly is " + recordCommandsEagerly + ", and eager commands are " + eagerCommands);
if (recordCommandsEagerly) {
this.expectedCommands.removeAll(eagerCommands);
if (!eagerCommands.isEmpty()) sawAtLeastOneInvocation = true;
@@ -142,6 +142,10 @@
}
}
+ private void info(String str) {
+ log.info(" [" + c + "] " + str);
+ }
+
/**
* Blocks for a predefined amount of time (120 Seconds) until commands defined in any of the expect*() methods have
* been detected. If the commands have not been detected by this time, an exception is thrown.
@@ -156,7 +160,7 @@
public void waitForRpc(long time, TimeUnit unit) {
assert expectedCommands != null : "there are no replication expectations; please use ReplListener.expect() before calling this method";
try {
- log.trace("Expect Any is {0}, saw at least one? {1} Expected {2}", expectAny, sawAtLeastOneInvocation, expectedCommands);
+ info("Expect Any is " + expectAny + ", saw at least one? " + sawAtLeastOneInvocation + " Expected " + expectedCommands);
boolean successful = (expectAny && sawAtLeastOneInvocation) || (!expectAny && expectedCommands.isEmpty());
if (!successful && !latch.await(time, unit)) {
assert false : "Waiting for more than " + time + " " + unit + " and following commands did not replicate: " + expectedCommands + " on cache [" + c.getCacheManager().getAddress() + "]";
@@ -209,11 +213,16 @@
private void markAsVisited(VisitableCommand cmd) {
expectationSetupLock.lock();
try {
- log.info("Cache [" + c + "] saw command " + cmd);
+ info("ReplListener saw command " + cmd);
if (expectedCommands != null) {
- expectedCommands.remove(cmd.getClass());
+ if (expectedCommands.remove(cmd.getClass())) {
+ info("Successfully removed command: " + cmd.getClass());
+ }
sawAtLeastOneInvocation = true;
- if (expectedCommands.isEmpty()) latch.countDown();
+ if (expectedCommands.isEmpty()) {
+ info("Nothing to wait for, releasing latch");
+ latch.countDown();
+ }
} else {
if (recordCommandsEagerly) eagerCommands.add(cmd.getClass());
}
More information about the infinispan-commits
mailing list