Author: mircea.markus
Date: 2008-04-30 12:24:51 -0400 (Wed, 30 Apr 2008)
New Revision: 5777
Modified:
benchmarks/benchmark-fwk/trunk/conf/cachebench.xml
benchmarks/benchmark-fwk/trunk/src/org/cachebench/CacheBenchmarkRunner.java
benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/ReplicationOccursTest.java
Log:
added 2.2.0 bench support
Modified: benchmarks/benchmark-fwk/trunk/conf/cachebench.xml
===================================================================
--- benchmarks/benchmark-fwk/trunk/conf/cachebench.xml 2008-04-30 16:22:10 UTC (rev 5776)
+++ benchmarks/benchmark-fwk/trunk/conf/cachebench.xml 2008-04-30 16:24:51 UTC (rev 5777)
@@ -8,8 +8,7 @@
emptyCacheBetweenTests - again, use if you're running out of mem.
numThreads - the number of executor threads to use to perform the required number of
operations.
-->
-<cachebench sampleSize="10000" gcBetweenTestsEnabled="true"
sleepBetweenTests="1000" emptyCacheBetweenTests="true"
- numThreads="10">
+<cachebench sampleSize="10000" gcBetweenTestsEnabled="true"
sleepBetweenTests="1000" emptyCacheBetweenTests="true"
numThreads="10">
<!--
@@ -19,17 +18,17 @@
- for each node instance socket address is specified. You can make sure that
addresses are available by using
checkClusterAddresses ant target
-->
- <cluster>
- <member host="cluster01" port="17900"/>
- <member host="cluster02" port="17900"/>
- <member host="cluster03" port="17900"/>
- <member host="cluster04" port="17900"/>
- <member host="cluster05" port="17900"/>
- <member host="cluster06" port="17900"/>
- <member host="cluster07" port="17900"/>
- <member host="cluster08" port="17900"/>
- <member host="cluster09" port="17900"/>
- <member host="cluster10" port="17900"/>
+ <cluster bindAddress="127.0.0.1">
+ <member host="127.0.0.1" port="7901"/>
+ <member host="127.0.0.1" port="7902"/>
+ <member host="127.0.0.1" port="7903"/>
+ <member host="127.0.0.1" port="7904"/>
+ <member host="127.0.0.1" port="7905"/>
+ <member host="127.0.0.1" port="7906"/>
+ <member host="127.0.0.1" port="7907"/>
+ <member host="127.0.0.1" port="7908"/>
+ <member host="127.0.0.1" port="7909"/>
+ <member host="127.0.0.1" port="7910"/>
</cluster>
<!--
@@ -38,7 +37,7 @@
testcase. By default set to true.
-->
- <testcase name="WebSessionReplicationTest"
stopOnFailure="true">
+ <testcase name="WebSessionReplicationTest"
stopOnFailure="true">
<!-- org.cachebench.warmup.PutGetCacheWarmup warms up the cache by doing
operation on it; simulates a real-world environment.
If no warmup is needed use org.cachebench.warmup.NoCacheWarmup
@@ -51,48 +50,48 @@
validates that replication is enabled and works. If repl does not occur and the
stopOnFailure is set to true then exists.
Should be used to make sure that replication is enabled; see javadoc for more
details
-->
- <!--
- <test name="replicationOccurrsTest"
testClass="org.cachebench.tests.ReplicationOccursTest">
- <param name="partialReplication" value="true"/>
- </test>
+ <!--
+ <test name="replicationOccurrsTest"
testClass="org.cachebench.tests.ReplicationOccursTest">
+ <param name="partialReplication" value="true"/>
+ </test>
- -->
+-->
<!--
* The "name" attrib is just used for display in the reports.
* You can write your own custom testClass.
* weight is currently unused.
-->
- <!--<test name="Strings"
testClass="org.cachebench.tests.simpletests.StringTest" weight="2.0"
/>-->
+ <!--<test name="Strings"
testClass="org.cachebench.tests.simpletests.StringTest" weight="2.0"
/>-->
+
+ <test name="SessionSimulator"
testClass="org.cachebench.tests.SessionSimulatorTest" weight="2.0"
>
+ <param name="numberOfRequest" value="100000"/>
+ <param name="numberOfAttributes" value="100"/>
+ <param name="writePercentage" value="20"/>
+ <param name="sizeOfAnAttribute" value="1000"/>
+ </test>
- <test name="SessionSimulator"
testClass="org.cachebench.tests.SessionSimulatorTest"
weight="2.0">
- <param name="numberOfRequest" value="100000"/>
- <param name="numberOfAttributes" value="100"/>
- <param name="writePercentage" value="20"/>
- <param name="sizeOfAnAttribute" value="1000"/>
- </test>
+ <!--
+ <test name="Primitive Wrappers"
testClass="org.cachebench.tests.simpletests.PrimitiveTest"
weight="1.0" />
+ <test name="Custom Class Types"
testClass="org.cachebench.tests.simpletests.CustomClassTest"
weight="1.0" />
+ <test name="Custom Subclasses of Abstracts"
testClass="org.cachebench.tests.simpletests.SubclassTest" weight="1.5"
/>
+ <test name="Custom Types With Transients"
testClass="org.cachebench.tests.simpletests.TransientTest"
weight="1.0" />
+ <test name="Custom Types With Statics"
testClass="org.cachebench.tests.simpletests.StaticsTest" weight="1.5"
/>
+ <test name="Custom Types With Associations"
testClass="org.cachebench.tests.simpletests.AssociationsTest"
weight="2.0" />
+ -->
- <!--
- <test name="Primitive Wrappers"
testClass="org.cachebench.tests.simpletests.PrimitiveTest"
weight="1.0" />
- <test name="Custom Class Types"
testClass="org.cachebench.tests.simpletests.CustomClassTest"
weight="1.0" />
- <test name="Custom Subclasses of Abstracts"
testClass="org.cachebench.tests.simpletests.SubclassTest" weight="1.5"
/>
- <test name="Custom Types With Transients"
testClass="org.cachebench.tests.simpletests.TransientTest"
weight="1.0" />
- <test name="Custom Types With Statics"
testClass="org.cachebench.tests.simpletests.StaticsTest" weight="1.5"
/>
- <test name="Custom Types With Associations"
testClass="org.cachebench.tests.simpletests.AssociationsTest"
weight="2.0" />
- -->
-
- <!-- WARNING - Configuration file name is now DEPRECATED and will be ignored.
Please pass in your cache config
-file name that you wish to use with the -DcacheBenchFwk.cacheConfigFile JVM parameter.
The runNode.sh
-and cluster.sh scripts will also do this for you. -->
+ <!-- WARNING - Configuration file name is now DEPRECATED and will be ignored.
Please pass in your cache config
+ file name that you wish to use with the
-DcacheBenchFwk.cacheConfigFile JVM parameter. The runNode.sh
+ and cluster.sh scripts will also do this for you. -->
</testcase>
- <!--
- Available generators are: CSVReportGenerator and ClusterReportGenerator.
- See javadocs for org.cachebench.reportgenerators.ReportGenerator for writing your
- own report generators such as XML generators, graphic generators, etc
+ <!--
+ Available generators are: CSVReportGenerator and ClusterReportGenerator.
+ See javadocs for org.cachebench.reportgenerators.ReportGenerator for writing your
+ own report generators such as XML generators, graphic generators, etc
-->
<!-- The CSV report generated can be plugged in to a spreadsheet to generate
graphs. If 'outputFile is set to
- '-generic-' then the name would be generated as follows:
'data_<cache-product>_<configuration>_<cluster-size>.csv'
-->
+ '-generic-' then the name would be generated as follows:
'performance-<nodeIndexInCluster>.csv' -->
<report outputFile="-generic-"
generator="org.cachebench.reportgenerators.ClusterReportGenerator"/>
</cachebench>
Modified: benchmarks/benchmark-fwk/trunk/src/org/cachebench/CacheBenchmarkRunner.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/src/org/cachebench/CacheBenchmarkRunner.java 2008-04-30
16:22:10 UTC (rev 5776)
+++ benchmarks/benchmark-fwk/trunk/src/org/cachebench/CacheBenchmarkRunner.java 2008-04-30
16:24:51 UTC (rev 5777)
@@ -243,7 +243,7 @@
result.setTestPassed(false);
result.setErrorMsg("Failed to Execute - See logs for details : "
+ e.getMessage());
- logger.warn("Test case : " + testCaseName + ", Test :
" + testName + " - Failed", e);
+ logger.warn("Test case : " + testCaseName + ", Test :
" + testName + " - Failed due to", e);
errorLogger.error("Test case : " + testCaseName + ", Test :
" + testName + " - Failed : " + e.getMessage(), e);
}
if (!result.isTestPassed() && testCase.isStopOnFailure())
Modified:
benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/ReplicationOccursTest.java
===================================================================
---
benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/ReplicationOccursTest.java 2008-04-30
16:22:10 UTC (rev 5776)
+++
benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/ReplicationOccursTest.java 2008-04-30
16:24:51 UTC (rev 5777)
@@ -19,8 +19,7 @@
*
* @author Mircea.Markus(a)jboss.com
*/
-public class ReplicationOccursTest implements CacheTest
-{
+public class ReplicationOccursTest implements CacheTest {
public static final Log log = LogFactory.getLog(ReplicationOccursTest.class);
private Configuration conf;
@@ -28,22 +27,19 @@
private static final int REPLICATION_TRY_COUNT = 5;
private static final int REPLICATION_TRY_SLEEP = 2000;
- public void setConfiguration(Configuration configuration)
- {
+ public void setConfiguration(Configuration configuration) {
this.conf = configuration;
}
- public StatisticTestResult doTest(String testName, CacheWrapper cache, String
testCaseName, int sampleSize, int numThreads) throws Exception
- {
+ public StatisticTestResult doTest(String testName, CacheWrapper cache, String
testCaseName, int sampleSize, int numThreads) throws Exception {
log.trace("TestCase = '" + testCaseName + "', TestName =
" + testName);
barrierBeforeReplicationTest();
Integer currentNodeIndex = conf.getClusterConfig().getCurrentNodeIndex();
- cache.put(PREFIX + currentNodeIndex, "true");
+ tryToPut(cache, currentNodeIndex);
Thread.sleep(REPLICATION_TRY_SLEEP);//just to make sure that prev barrier closed
its sockets etc
- if (conf.getClusterConfig().getClusterSize() == 1)
- {
+ if (conf.getClusterConfig().getClusterSize() == 1) {
log.info("Cluster size is one, no replication expected");
StatisticTestResult result = new StatisticTestResult();
result.setTestPassed(true);
@@ -54,23 +50,39 @@
boolean allNodesReplicated = checkReplicationSeveralTimes(testName, cache,
testCaseName);
Map<SocketAddress, Object> receivedValues =
broadcastReplicationResult(allNodesReplicated);
- cache.empty();
+ try {
+ cache.empty();
+ } catch (Throwable e)
+ {
+ log.warn("Fail to cleanup cache after replication test", e);
+ }
return allReplicatedFine(receivedValues);
}
+ private void tryToPut(CacheWrapper cache, Integer currentNodeIndex) throws Exception
{
+ int tryCount = 0;
+ while (tryCount < 5) {
+ try {
+ cache.put(PREFIX + currentNodeIndex, "true");
+ return;
+ }
+ catch (Throwable e) {
+ log.warn("Error while trying to put data: ", e);
+ tryCount++;
+ }
+ }
+ }
+
/**
* 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))
- {
+ throws Exception {
+ for (int i = 0; i < REPLICATION_TRY_COUNT; i++) {
+ if (nodesReplicated(cache, testCaseName, testName)) {
return true;
}
- log.info("Replication test failed, " + (i+1) + " tries so far.
Sleeping for " + REPLICATION_TRY_SLEEP
+ log.info("Replication test failed, " + (i + 1) + " tries so far.
Sleeping for " + REPLICATION_TRY_SLEEP
+ " millis then try again");
Thread.sleep(REPLICATION_TRY_SLEEP);
}
@@ -78,8 +90,7 @@
}
private Map<SocketAddress, Object> broadcastReplicationResult(boolean
allNodesReplicated)
- throws Exception
- {
+ throws Exception {
ClusterBarrier barrier = new ClusterBarrier();
barrier.setConfig(conf.getClusterConfig());
barrier.barrier(String.valueOf(allNodesReplicated));
@@ -89,22 +100,18 @@
}
private void barrierBeforeReplicationTest()
- throws Exception
- {
+ throws Exception {
ClusterBarrier barrier = new ClusterBarrier();
barrier.setAcknowledge(true);
barrier.setConfig(conf.getClusterConfig());
barrier.barrier("BEFORE_REPLICATION_OCCURS_BARRIER");
}
- private StatisticTestResult allReplicatedFine(Map<SocketAddress, Object>
receivedValues)
- {
+ private StatisticTestResult allReplicatedFine(Map<SocketAddress, Object>
receivedValues) {
StatisticTestResult result = new StatisticTestResult();
result.setSkipReport(true);
- for (Object value : receivedValues.values())
- {
- if (!"true".equals(value))
- {
+ for (Object value : receivedValues.values()) {
+ if (!"true".equals(value)) {
log.info("Replication was not successful on the entire cluster!");
result.setTestPassed(false);
return result;
@@ -115,66 +122,68 @@
return result;
}
- private boolean isPartialReplication(String testCaseName, String testName)
- {
+ private boolean isPartialReplication(String testCaseName, String testName) {
TestCase testCase = conf.getTestCase(testCaseName);
TestConfig thisConfig = testCase.getTest(testName);
return thisConfig.existsParam("partialReplication") &&
"true".equalsIgnoreCase(thisConfig.getParamValue("partialReplication"));
}
- private boolean nodesReplicated(CacheWrapper cache, String testCaseName, String
testName) throws Exception
- {
+ private boolean nodesReplicated(CacheWrapper cache, String testCaseName, String
testName) throws Exception {
int clusterSize = conf.getClusterConfig().getClusterSize();
int replicaCount = 0;
- for (int i = 0; i < clusterSize; i++)
- {
+ for (int i = 0; i < clusterSize; i++) {
int currentNodeIndex = conf.getClusterConfig().getCurrentNodeIndex();
- if (i == currentNodeIndex)
- {
+ if (i == currentNodeIndex) {
continue;
}
- Object data = cache.getReplicatedData(PREFIX + i);
- if (data == null || !"true".equals(data))
- {
+ Object data = tryGet(cache, i);
+ if (data == null || !"true".equals(data)) {
log.trace("Cache with index " + i + " did *NOT*
replicate");
- }
- else
- {
+ } else {
log.trace("Cache with index " + i + " replicated here
");
replicaCount++;
}
}
log.info("Number of caches that replicated here is " + replicaCount);
- if (isPartialReplication(testCaseName, testName))
- {
+ if (isPartialReplication(testCaseName, testName)) {
return verifyClusterReplication(replicaCount);
}
return replicaCount == conf.getClusterConfig().getClusterSize() - 1;
}
+ private Object tryGet(CacheWrapper cache, int i) throws Exception {
+ int tryCont = 0;
+ while (tryCont < 5)
+ {
+ try {
+ return cache.getReplicatedData(PREFIX + i);
+ } catch (Throwable e) {
+ tryCont ++;
+ }
+ }
+ return null;
+ }
+
/**
* Checks whether the sum of replciations across the cluster is bigger than the number
of nodes in the cluster, in
* other words each node replicated at least once.
*/
- private boolean verifyClusterReplication(int replicaCount) throws Exception
- {
+ private boolean verifyClusterReplication(int replicaCount) throws Exception {
ClusterBarrier barrier = new ClusterBarrier();
barrier.setConfig(conf.getClusterConfig());
barrier.barrier(replicaCount);
Collection recievedValues = barrier.getReceivedMessages().values();
log.trace("Recieved the following repilcation counts: " +
recievedValues);
int totalValue = 0;
- for (Object val : recievedValues)
- {
+ for (Object val : recievedValues) {
totalValue += Integer.valueOf(val.toString());
}
log.info("********** Overall replication count is: " + totalValue);
//this means SOME replication occurred. This does not mean, though, that all nodes
replicated successfuly.
//correct condition would be >= this.conf.getClusterConfig().getClusterSize()
//todo/FIXME - this seem not to work with all the products, so we will accept
'some replication'
- if (totalValue < this.conf.getClusterConfig().getClusterSize())
- {
+ if (totalValue < this.conf.getClusterConfig().getClusterSize()) {
log.warn("The replication was not total, but partial!!");
}
boolean isReplicationSuccess = totalValue > 0;