Author: mircea.markus
Date: 2008-01-16 07:24:13 -0500 (Wed, 16 Jan 2008)
New Revision: 5147
Modified:
benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/ReplicationOccursTest.java
Log:
Modified:
benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/ReplicationOccursTest.java
===================================================================
---
benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/ReplicationOccursTest.java 2008-01-16
10:58:53 UTC (rev 5146)
+++
benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/ReplicationOccursTest.java 2008-01-16
12:24:13 UTC (rev 5147)
@@ -25,6 +25,8 @@
private Configuration conf;
private static final String PREFIX = "_ReplicationOccursTest_";
+ private static final int REPLICATION_TRY_COUNT = 5;
+ private static final int REPLICATION_TRY_SLEEP = 2000;
public void setConfiguration(Configuration configuration)
{
@@ -38,7 +40,7 @@
Integer currentNodeIndex = conf.getClusterConfig().getCurrentNodeIndex();
cache.put(PREFIX + currentNodeIndex, "true");
- Thread.sleep(2000);//just to make sure that prev barrier closed its sockets etc
+ Thread.sleep(REPLICATION_TRY_SLEEP);//just to make sure that prev barrier closed
its sockets etc
if (conf.getClusterConfig().getClusterSize() == 1)
{
@@ -49,13 +51,32 @@
return result;
}
- boolean allNodesReplicated = nodesReplicated(cache, testCaseName, testName);
+ boolean allNodesReplicated = checkReplicationSeveralTimes(testName, cache,
testCaseName);
Map<SocketAddress, Object> receivedValues =
broadcastReplicationResult(allNodesReplicated);
cache.empty();
return allReplicatedFine(receivedValues);
}
+ /**
+ * If caches replicate async, then try several times.
+ */
+ private boolean checkReplicationSeveralTimes(String testName, CacheWrapper cache,
String testCaseName)
+ throws Exception
+ {
+ for (int i =0; i < REPLICATION_TRY_COUNT; i++)
+ {
+ if (nodesReplicated(cache, testCaseName, testName))
+ {
+ return true;
+ }
+ log.info("Replication test faild, " + (i+1) + " tries so far.
Sleeping for " + REPLICATION_TRY_SLEEP
+ + " millies then try again");
+ Thread.sleep(REPLICATION_TRY_SLEEP);
+ }
+ return false;
+ }
+
private Map<SocketAddress, Object> broadcastReplicationResult(boolean
allNodesReplicated)
throws Exception
{
Show replies by date