Author: mircea.markus
Date: 2007-12-30 16:45:04 -0500 (Sun, 30 Dec 2007)
New Revision: 4927
Added:
cache-bench-fwk/trunk/src/org/cachebench/config/GenericParamsConfig.java
cache-bench-fwk/trunk/src/org/cachebench/tests/ReplicationOccursTest.java
Modified:
cache-bench-fwk/trunk/cache-products/coherence-3.2.2/src/org/cachebench/cachewrappers/CoherenceWrapper.java
cache-bench-fwk/trunk/cache-products/ehcache-1.2.4/src/org/cachebench/cachewrappers/EHCacheWrapper.java
cache-bench-fwk/trunk/cache-products/jbosscache-1.4.1/src/org/cachebench/cachewrappers/JBossCacheWrapper.java
cache-bench-fwk/trunk/cache-products/jbosscache-2.0.0/src/org/cachebench/cachewrappers/JBossCache200Wrapper.java
cache-bench-fwk/trunk/conf/cachebench.xml
cache-bench-fwk/trunk/conf/log4j.xml
cache-bench-fwk/trunk/runNode.sh
cache-bench-fwk/trunk/src/org/cachebench/CacheBenchmarkRunner.java
cache-bench-fwk/trunk/src/org/cachebench/CacheWrapper.java
cache-bench-fwk/trunk/src/org/cachebench/TestResult.java
cache-bench-fwk/trunk/src/org/cachebench/config/CacheWarmupConfig.java
cache-bench-fwk/trunk/src/org/cachebench/config/ConfigBuilder.java
cache-bench-fwk/trunk/src/org/cachebench/config/Configuration.java
cache-bench-fwk/trunk/src/org/cachebench/config/Report.java
cache-bench-fwk/trunk/src/org/cachebench/config/TestCase.java
cache-bench-fwk/trunk/src/org/cachebench/config/TestConfig.java
cache-bench-fwk/trunk/src/org/cachebench/reportgenerators/CSVReportGenerator.java
cache-bench-fwk/trunk/src/org/cachebench/tests/CacheTest.java
cache-bench-fwk/trunk/src/org/cachebench/tests/SimpleTest.java
Log:
enhanced - added a new test that checks that caches that replications occurs as expected
+ refactorings
Modified:
cache-bench-fwk/trunk/cache-products/coherence-3.2.2/src/org/cachebench/cachewrappers/CoherenceWrapper.java
===================================================================
---
cache-bench-fwk/trunk/cache-products/coherence-3.2.2/src/org/cachebench/cachewrappers/CoherenceWrapper.java 2007-12-30
08:13:49 UTC (rev 4926)
+++
cache-bench-fwk/trunk/cache-products/coherence-3.2.2/src/org/cachebench/cachewrappers/CoherenceWrapper.java 2007-12-30
21:45:04 UTC (rev 4927)
@@ -2,7 +2,7 @@
import org.cachebench.CacheWrapper;
-import java.util.Properties;
+import java.util.Map;
import com.tangosol.net.NamedCache;
import com.tangosol.net.CacheFactory;
@@ -18,7 +18,7 @@
{
NamedCache cache;
- public void init(Properties parameters) throws Exception
+ public void init(Map parameters) throws Exception
{
cache = CacheFactory.getReplicatedCache();
// cache = CacheFactory.getCache("VirtualCache");
@@ -57,4 +57,9 @@
{
return cache.keySet().toString();
}
+
+ public Object getReplicatedData(String key) throws Exception
+ {
+ return get(key);
+ }
}
Modified:
cache-bench-fwk/trunk/cache-products/ehcache-1.2.4/src/org/cachebench/cachewrappers/EHCacheWrapper.java
===================================================================
---
cache-bench-fwk/trunk/cache-products/ehcache-1.2.4/src/org/cachebench/cachewrappers/EHCacheWrapper.java 2007-12-30
08:13:49 UTC (rev 4926)
+++
cache-bench-fwk/trunk/cache-products/ehcache-1.2.4/src/org/cachebench/cachewrappers/EHCacheWrapper.java 2007-12-30
21:45:04 UTC (rev 4927)
@@ -1,9 +1,8 @@
package org.cachebench.cachewrappers;
-import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager;
+import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
-import net.sf.ehcache.Ehcache;
import net.sf.ehcache.config.Configuration;
import net.sf.ehcache.config.ConfigurationFactory;
import org.apache.commons.logging.Log;
@@ -12,7 +11,7 @@
import java.io.Serializable;
import java.net.URL;
-import java.util.Properties;
+import java.util.Map;
import java.util.StringTokenizer;
@@ -33,10 +32,10 @@
/* (non-Javadoc)
* @see org.cachebench.CacheWrapper#init(java.util.Properties)
*/
- public void init(Properties parameters) throws Exception
+ public void init(Map parameters) throws Exception
{
logger.debug("Initializing the cache with props " + parameters);
- URL url =
getClass().getClassLoader().getResource(parameters.getProperty("config"));
+ URL url = getClass().getClassLoader().getResource((String)
parameters.get("config"));
logger.debug("Config URL = " + url);
Configuration c = ConfigurationFactory.parseConfiguration(url);
c.setSource("URL of " + url);
@@ -157,4 +156,9 @@
{
return cache.getKeys().toString() + " remote peers: " +
manager.getCachePeerListener().getBoundCachePeers();
}
+
+ public Object getReplicatedData(String key) throws Exception
+ {
+ return get(key);
+ }
}
Modified:
cache-bench-fwk/trunk/cache-products/jbosscache-1.4.1/src/org/cachebench/cachewrappers/JBossCacheWrapper.java
===================================================================
---
cache-bench-fwk/trunk/cache-products/jbosscache-1.4.1/src/org/cachebench/cachewrappers/JBossCacheWrapper.java 2007-12-30
08:13:49 UTC (rev 4926)
+++
cache-bench-fwk/trunk/cache-products/jbosscache-1.4.1/src/org/cachebench/cachewrappers/JBossCacheWrapper.java 2007-12-30
21:45:04 UTC (rev 4927)
@@ -6,7 +6,7 @@
import org.jboss.cache.PropertyConfigurator;
import org.jboss.cache.TreeCache;
-import java.util.Properties;
+import java.util.Map;
import java.util.HashMap;
@@ -21,13 +21,13 @@
private TreeCache tree;
private Log log =
LogFactory.getLog("org.cachebench.cachewrappers.JBossCacheWrapper");
- public void init(Properties parameters) throws Exception
+ public void init(Map parameters) throws Exception
{
log.debug("Initializing the cache");
//parameters.
tree = new TreeCache();
PropertyConfigurator conf = new PropertyConfigurator();
- conf.configure( tree, parameters.getProperty("config") );
+ conf.configure( tree, (String)parameters.get("config") );
}
public void setUp() throws Exception
@@ -69,4 +69,10 @@
{
return tree.printDetails();
}
+
+ public Object getReplicatedData(String key)
+ {
+ return null;
+ }
+
}
Modified:
cache-bench-fwk/trunk/cache-products/jbosscache-2.0.0/src/org/cachebench/cachewrappers/JBossCache200Wrapper.java
===================================================================
---
cache-bench-fwk/trunk/cache-products/jbosscache-2.0.0/src/org/cachebench/cachewrappers/JBossCache200Wrapper.java 2007-12-30
08:13:49 UTC (rev 4926)
+++
cache-bench-fwk/trunk/cache-products/jbosscache-2.0.0/src/org/cachebench/cachewrappers/JBossCache200Wrapper.java 2007-12-30
21:45:04 UTC (rev 4927)
@@ -2,18 +2,21 @@
import org.cachebench.CacheWrapper;
import org.jboss.cache.Cache;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.buddyreplication.GravitateResult;
+import org.jboss.cache.marshall.NodeData;
-import java.util.Properties;
+import java.util.Map;
public class JBossCache200Wrapper implements CacheWrapper
{
private Cache cache;
- public void init(Properties parameters) throws Exception
+ public void init(Map parameters) throws Exception
{
- cache =
DefaultCacheFactory.getInstance().createCache(parameters.getProperty("config"));
+ cache =
DefaultCacheFactory.getInstance().createCache((String)parameters.get("config"));
}
public void setUp() throws Exception
@@ -54,4 +57,17 @@
return "Num direct children: " + cache.getRoot().getChildren().size();
}
+ public Object getReplicatedData(String key) throws Exception
+ {
+ CacheSPI cacheSpi = (CacheSPI) cache;
+ GravitateResult result = cacheSpi.gravitateData(new Fqn("test", key),
true);
+ if (!result.isDataFound())
+ {
+ //totall replication?
+ return get(key);
+ }
+ NodeData nodeData = result.getNodeData().get(0);
+ return nodeData.getAttributes().get(key);
+ }
+
}
Modified: cache-bench-fwk/trunk/conf/cachebench.xml
===================================================================
--- cache-bench-fwk/trunk/conf/cachebench.xml 2007-12-30 08:13:49 UTC (rev 4926)
+++ cache-bench-fwk/trunk/conf/cachebench.xml 2007-12-30 21:45:04 UTC (rev 4927)
@@ -7,7 +7,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="2000" gcBetweenTestsEnabled="true"
sleepBetweenTests="1000" emptyCacheBetweenTests="true"
numThreads="10">
+<cachebench sampleSize="10000" gcBetweenTestsEnabled="true"
sleepBetweenTests="1000" emptyCacheBetweenTests="true"
numThreads="10">
<!--
@@ -23,22 +23,16 @@
<member host="127.0.0.1" port="7800"/>
<member host="127.0.0.1" port="7801"/>
<member host="127.0.0.1" port="7802"/>
- <member host="127.0.0.1" port="7803"/>
- <member host="127.0.0.1" port="7804"/>
</cluster>
<!-- Each testcase represents either a single configuration or a cacheing product.
For example, WhirlyCache would be one test case. JBossCache-standalone could be
another, JBossCache-replicated could be yet another
+ testcase::stopOnFailure if set to true and one test in this testcase fails then the
process will exit
See the javadoc for org.cachebench.CacheWrapper for the cacheWrapper property
-->
- <!--
- Note that if you are using REPLICATED tests, using the "ant runSlave"
command, you can only run one test at a time.
- Otherwise, if you are using the test in standalone mode (testing a LOCAL cache),
you can add multiple "testcase" elements.
- -->
+ <!-- Make SURE you read the docs - especially when using Terracotta as this involves
some additional setup -->
- <!-- Make SURE you read the docs - especially when using Terracotta as this
involves some additional setup -->
-
<!-- Legacy stuff -->
<!--<testcase name="JBossCache140-Pessimistic-REPL_SYNC"
cacheWrapper="org.cachebench.cachewrappers.JBossCacheWrapper">-->
<!--<testcase name="EHCache124-replicated"
cacheWrapper="org.cachebench.cachewrappers.EHCacheWrapper">-->
@@ -46,23 +40,30 @@
<!--<testcase name="JBossCache2x-Pessimistic-REPL_SYNC_BR"
cacheWrapper="org.cachebench.cachewrappers.JBossCache200Wrapper">-->
- <!--<testcase name="JBossCache2x-Pessimistic-REPL_ASYNC"
cacheWrapper="org.cachebench.cachewrappers.JBossCache200Wrapper">-->
- <testcase name="JBossCache2.0"
cacheWrapper="org.cachebench.cachewrappers.TerracottaWrapper">
+ <testcase name="JBossCache2x-Pessimistic-REPL_ASYNC"
cacheWrapper="org.cachebench.cachewrappers.JBossCache200Wrapper"
stopOnFailure="true">
+ <!--<testcase name="JBossCache2.0"
cacheWrapper="org.cachebench.cachewrappers.TerracottaWrapper"
stopOnFailure="true">-->
-
<!-- warms up the cache by doing operation on it; simulates a real-world
environment. If no warmup is needed use
org.cachebench.warmup.NoCacheWarmup
-->
- <warmup warmupClass="org.cachebench.warmup.PutGetCacheWarmup">
+ <warmup warmupClass="org.cachebench.warmup.NoCacheWarmup">
<param name="operationCount" value="100"/>
</warmup>
<!--
+ 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>
+
+ <!--
* 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.StringTest" weight="2.0" />
+ <test name="Strings"
testClass="org.cachebench.tests.StringTest" weight="2.0" />
<!--
<test name="Primitive Wrappers"
testClass="org.cachebench.tests.PrimitiveTest" weight="1.0" />
Modified: cache-bench-fwk/trunk/conf/log4j.xml
===================================================================
--- cache-bench-fwk/trunk/conf/log4j.xml 2007-12-30 08:13:49 UTC (rev 4926)
+++ cache-bench-fwk/trunk/conf/log4j.xml 2007-12-30 21:45:04 UTC (rev 4927)
@@ -48,6 +48,12 @@
<appender-ref ref="CONSOLE"/>
</category>
+ <category name="org.cachebench.cluster"
additivity="false">
+ <priority value="INFO"/>
+ <appender-ref ref="FILE"/>
+ <appender-ref ref="CONSOLE"/>
+ </category>
+
<category name="org.cachebench.tests" additivity="false">
<priority value="INFO"/>
<appender-ref ref="CONSOLE"/>
@@ -72,10 +78,21 @@
<priority value="ERROR"/>
<appender-ref ref="FILE"/>
</category>
+
+ <category name="org.cachebench.tests.ReplicationOccursTest"
additivity="false">
+ <priority value="TRACE"/>
+ <appender-ref ref="CONSOLE"/>
+ </category>
+ <category name="org.jboss.cache">
+ <priority value="WARN"/>
+ <appender-ref ref="FILE"/>
+ <appender-ref ref="CONSOLE"/>
+ </category>
+
<!-- Here goes the root -->
<root>
- <priority value ="DEBU" />
+ <priority value ="INFO" />
<appender-ref ref="FILE" />
</root>
Modified: cache-bench-fwk/trunk/runNode.sh
===================================================================
--- cache-bench-fwk/trunk/runNode.sh 2007-12-30 08:13:49 UTC (rev 4926)
+++ cache-bench-fwk/trunk/runNode.sh 2007-12-30 21:45:04 UTC (rev 4927)
@@ -7,6 +7,18 @@
CACHE_DEBUG=true
preferIPv4Stack=true
+if [ -z $1]
+then
+ echo "Usage:"
+ echo " ./runNode.sh currentNodeIndex testConfig [other params]"
+ echo "currentNodeIndex : the index of this node in the list of nodes in the
cluster, zero based"
+ echo "testConfig : must be on of the directories form cache products"
+ echo "other params : this will be passed as argument to the cache benchmark
class."
+ echo " Might be used, for e.g. to pass -D arguments to the custom
plugins"
+ echo " configured in cachebench.xml"
+ exit 0
+fi
+
export SYS_PROPS="-Dbind.address=$BIND_ADDRESS -DcurrentIndex=$1
-Dorg.cachebench.debug=$CACHE_DEBUG -Djava.net.preferIPv4Stack=$preferIPv4Stack"
#libraries needed by the fwk, add them to the classpath
Modified: cache-bench-fwk/trunk/src/org/cachebench/CacheBenchmarkRunner.java
===================================================================
--- cache-bench-fwk/trunk/src/org/cachebench/CacheBenchmarkRunner.java 2007-12-30 08:13:49
UTC (rev 4926)
+++ cache-bench-fwk/trunk/src/org/cachebench/CacheBenchmarkRunner.java 2007-12-30 21:45:04
UTC (rev 4927)
@@ -139,7 +139,7 @@
CacheWarmupConfig warmupConfig = test.getCacheWarmupConfig();
logger.trace("Warmup config is: " + warmupConfig);
CacheWarmup warmup = (CacheWarmup)
Instantiator.getInstance().createClass(warmupConfig.getWarmupClass());
- warmup.setConfigParams(warmupConfig.getConfigParams());
+ warmup.setConfigParams(warmupConfig.getParams());
warmup.warmup(cache);
}
@@ -184,7 +184,7 @@
List<TestResult> results = new ArrayList<TestResult>();
for (TestConfig testConfig: testCase.getTests())
{
- CacheTest testConfigClass = getCacheTestWrapper(testConfig);
+ CacheTest testConfigClass = getCacheTest(testConfig);
if (testConfigClass != null)
{
TestResult result;
@@ -192,7 +192,7 @@
String testCaseName = testCase.getName();
try
{
- result = testConfigClass.doTest(testCaseName, cache, testName,
conf.getSampleSize(), conf.getNumThreads());
+ result = testConfigClass.doTest(testName, cache, testCaseName,
conf.getSampleSize(), conf.getNumThreads());
}
catch (Exception e)
{
@@ -204,11 +204,19 @@
result.setTestPassed(false);
result.setErrorMsg("Failed to Execute - See logs for details : "
+ e.getMessage());
- logger.warn("Test case : " + testCaseName + ", Test :
" + testName + " - Failed");
+ logger.warn("Test case : " + testCaseName + ", Test :
" + testName + " - Failed", e);
errorLogger.error("Test case : " + testCaseName + ", Test :
" + testName + " - Failed : " + e.getMessage(), e);
}
+ if (!result.isTestPassed() && testCase.isStopOnFailure())
+ {
+ logger.warn("The test '" + testCase + "/" +
testName + "' failed, exiting...");
+ System.exit(1);
+ }
executeTestTasks(cache, result);
- results.add(result);
+ if (!result.isSkipReport())
+ {
+ results.add(result);
+ }
}
}
return results;
@@ -282,13 +290,13 @@
}
- private CacheTest getCacheTestWrapper(TestConfig testConfig)
+ private CacheTest getCacheTest(TestConfig testConfig)
{
CacheTest cacheTestClass = null;
try
{
cacheTestClass = (CacheTest)
Instantiator.getInstance().createClass(testConfig.getTestClass());
-
+ cacheTestClass.setConfiguration(conf);
}
catch (Exception e)
{
Modified: cache-bench-fwk/trunk/src/org/cachebench/CacheWrapper.java
===================================================================
--- cache-bench-fwk/trunk/src/org/cachebench/CacheWrapper.java 2007-12-30 08:13:49 UTC
(rev 4926)
+++ cache-bench-fwk/trunk/src/org/cachebench/CacheWrapper.java 2007-12-30 21:45:04 UTC
(rev 4927)
@@ -1,6 +1,7 @@
package org.cachebench;
import java.util.Properties;
+import java.util.Map;
/**
@@ -21,7 +22,7 @@
*
* @param parameters
*/
- void init(Properties parameters) throws Exception;
+ void init(Map parameters) throws Exception;
/**
* setUp() is called immediately after init(), and usually involves instantiating
@@ -70,4 +71,11 @@
* @return Some info about the cache contents, perhaps just a count of objects.
*/
String getInfo();
+
+ /**
+ * Some caches (e.g. JBossCache with buddy replication) do not store replicated data
directlly in the main
+ * structure, but use some additional structure to do this (replication tree, in the
case of buddy replication).
+ * This method is a hook for handling this situations.
+ */
+ public Object getReplicatedData(String key) throws Exception;
}
Modified: cache-bench-fwk/trunk/src/org/cachebench/TestResult.java
===================================================================
--- cache-bench-fwk/trunk/src/org/cachebench/TestResult.java 2007-12-30 08:13:49 UTC (rev
4926)
+++ cache-bench-fwk/trunk/src/org/cachebench/TestResult.java 2007-12-30 21:45:04 UTC (rev
4927)
@@ -23,6 +23,7 @@
private int throughputBytesPerSecond;
private int numMembers;
private int numThreads;
+ private boolean skipReport;
public DescriptiveStatistics getGetData()
{
@@ -171,4 +172,17 @@
", numThreads=" + numThreads +
'}';
}
+
+ /**
+ * If set to true, no reports will be generated from this test result.
+ */
+ public boolean isSkipReport()
+ {
+ return skipReport;
+ }
+
+ public void setSkipReport(boolean skipReport)
+ {
+ this.skipReport = skipReport;
+ }
}
Modified: cache-bench-fwk/trunk/src/org/cachebench/config/CacheWarmupConfig.java
===================================================================
--- cache-bench-fwk/trunk/src/org/cachebench/config/CacheWarmupConfig.java 2007-12-30
08:13:49 UTC (rev 4926)
+++ cache-bench-fwk/trunk/src/org/cachebench/config/CacheWarmupConfig.java 2007-12-30
21:45:04 UTC (rev 4927)
@@ -6,17 +6,10 @@
/**
* @author Mircea.Markus(a)jboss.com
*/
-public class CacheWarmupConfig
+public class CacheWarmupConfig extends GenericParamsConfig
{
private String warmupClass;
- private Map<String, String> configParams = new HashMap<String, String>();
-
- public void addConfigParam(NVPair nvPair)
- {
- configParams.put(nvPair.getName(), nvPair.getValue());
- }
-
public String getWarmupClass()
{
return warmupClass;
@@ -26,9 +19,4 @@
{
this.warmupClass = warmupClass;
}
-
- public Map<String, String> getConfigParams()
- {
- return configParams;
- }
}
Modified: cache-bench-fwk/trunk/src/org/cachebench/config/ConfigBuilder.java
===================================================================
--- cache-bench-fwk/trunk/src/org/cachebench/config/ConfigBuilder.java 2007-12-30 08:13:49
UTC (rev 4926)
+++ cache-bench-fwk/trunk/src/org/cachebench/config/ConfigBuilder.java 2007-12-30 21:45:04
UTC (rev 4927)
@@ -70,12 +70,15 @@
digester.addObjectCreate("cachebench/testcase/warmup/param",
"org.cachebench.config.NVPair");
digester.addSetProperties("cachebench/testcase/warmup/param");
- digester.addSetNext("cachebench/testcase/warmup/param",
"addConfigParam", "org.cachebench.config.NVPair");
+ digester.addSetNext("cachebench/testcase/warmup/param",
"addParam", "org.cachebench.config.NVPair");
digester.addSetNext("cachebench/testcase/warmup",
"setCacheWarmupConfig", "org.cachebench.config.CacheWarmupConfig");
digester.addObjectCreate("cachebench/testcase/test",
"org.cachebench.config.TestConfig");
digester.addSetProperties("cachebench/testcase/test");
+ digester.addObjectCreate("cachebench/testcase/test/param",
"org.cachebench.config.NVPair");
+ digester.addSetProperties("cachebench/testcase/test/param");
+ digester.addSetNext("cachebench/testcase/test/param",
"addParam", "org.cachebench.config.NVPair");
digester.addSetNext("cachebench/testcase/test", "addTest",
"org.cachebench.config.TestConfig");
digester.addObjectCreate("cachebench/testcase/param",
"org.cachebench.config.NVPair");
Modified: cache-bench-fwk/trunk/src/org/cachebench/config/Configuration.java
===================================================================
--- cache-bench-fwk/trunk/src/org/cachebench/config/Configuration.java 2007-12-30 08:13:49
UTC (rev 4926)
+++ cache-bench-fwk/trunk/src/org/cachebench/config/Configuration.java 2007-12-30 21:45:04
UTC (rev 4927)
@@ -102,4 +102,16 @@
{
this.clusterConfig = clusterConfig;
}
+
+ public TestCase getTestCase(String testCaseName)
+ {
+ for (TestCase testCase : getTestCases())
+ {
+ if (testCaseName.equalsIgnoreCase(testCase.getName()))
+ {
+ return testCase;
+ }
+ }
+ return null;
+ }
}
Added: cache-bench-fwk/trunk/src/org/cachebench/config/GenericParamsConfig.java
===================================================================
--- cache-bench-fwk/trunk/src/org/cachebench/config/GenericParamsConfig.java
(rev 0)
+++ cache-bench-fwk/trunk/src/org/cachebench/config/GenericParamsConfig.java 2007-12-30
21:45:04 UTC (rev 4927)
@@ -0,0 +1,34 @@
+package org.cachebench.config;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * Configuration that allows specifying a variable number of key value pairs.
+ *
+ * @author Mircea.Markus(a)jboss.com
+ */
+public class GenericParamsConfig
+{
+ private Map<String, String> configParams = new HashMap<String, String>();
+
+ public void addParam(NVPair nvPair)
+ {
+ configParams.put(nvPair.getName(), nvPair.getValue());
+ }
+
+ public Map<String, String> getParams()
+ {
+ return configParams;
+ }
+
+ public boolean existsParam(String name)
+ {
+ return configParams.get(name) != null;
+ }
+
+ public String getParamValue(String name)
+ {
+ return configParams.get(name);
+ }
+}
Modified: cache-bench-fwk/trunk/src/org/cachebench/config/Report.java
===================================================================
--- cache-bench-fwk/trunk/src/org/cachebench/config/Report.java 2007-12-30 08:13:49 UTC
(rev 4926)
+++ cache-bench-fwk/trunk/src/org/cachebench/config/Report.java 2007-12-30 21:45:04 UTC
(rev 4927)
@@ -1,30 +1,15 @@
package org.cachebench.config;
-import java.util.Map;
-import java.util.HashMap;
-
-
-public class Report
+public class Report extends GenericParamsConfig
{
private String generator;
private String outputFile;
- private Map<String, String> params= new HashMap<String, String>();
public String getGenerator()
{
return generator;
}
- public void addParam(NVPair nvPair)
- {
- params.put(nvPair.getName(), nvPair.getValue());
- }
-
- public Map<String, String> getParams()
- {
- return params;
- }
-
public void setGenerator(String generator)
{
this.generator = generator;
Modified: cache-bench-fwk/trunk/src/org/cachebench/config/TestCase.java
===================================================================
--- cache-bench-fwk/trunk/src/org/cachebench/config/TestCase.java 2007-12-30 08:13:49 UTC
(rev 4926)
+++ cache-bench-fwk/trunk/src/org/cachebench/config/TestCase.java 2007-12-30 21:45:04 UTC
(rev 4927)
@@ -1,18 +1,16 @@
package org.cachebench.config;
-import org.cachebench.warmup.CacheWarmup;
-
import java.util.ArrayList;
import java.util.List;
-import java.util.Properties;
-public class TestCase
+public class TestCase extends GenericParamsConfig
{
private String name;
private String cacheWrapper;
- private Properties params = new Properties();
+ private boolean stopOnFailure;
+
private List<TestConfig> tests = new ArrayList<TestConfig>();
private CacheWarmupConfig cacheWarmupConfig;
@@ -38,16 +36,6 @@
this.name = name;
}
- public Properties getParams()
- {
- return params;
- }
-
- public void addParam(NVPair nvPair)
- {
- params.put(nvPair.getName(), nvPair.getValue());
- }
-
/**
* @return Returns the cacheWrapper.
*/
@@ -73,4 +61,26 @@
{
tests.add(test);
}
+
+ public boolean isStopOnFailure()
+ {
+ return stopOnFailure;
+ }
+
+ public void setStopOnFailure(boolean stopOnFailure)
+ {
+ this.stopOnFailure = stopOnFailure;
+ }
+
+ public TestConfig getTest(String testName)
+ {
+ for (TestConfig config : getTests())
+ {
+ if (testName.equals(config.getName()))
+ {
+ return config;
+ }
+ }
+ return null;
+ }
}
\ No newline at end of file
Modified: cache-bench-fwk/trunk/src/org/cachebench/config/TestConfig.java
===================================================================
--- cache-bench-fwk/trunk/src/org/cachebench/config/TestConfig.java 2007-12-30 08:13:49
UTC (rev 4926)
+++ cache-bench-fwk/trunk/src/org/cachebench/config/TestConfig.java 2007-12-30 21:45:04
UTC (rev 4927)
@@ -1,7 +1,7 @@
package org.cachebench.config;
-public class TestConfig
+public class TestConfig extends GenericParamsConfig
{
private String name;
private String testClass;
Modified:
cache-bench-fwk/trunk/src/org/cachebench/reportgenerators/CSVReportGenerator.java
===================================================================
---
cache-bench-fwk/trunk/src/org/cachebench/reportgenerators/CSVReportGenerator.java 2007-12-30
08:13:49 UTC (rev 4926)
+++
cache-bench-fwk/trunk/src/org/cachebench/reportgenerators/CSVReportGenerator.java 2007-12-30
21:45:04 UTC (rev 4927)
@@ -54,10 +54,6 @@
* The method checkes whether the result is passed or failed. And based on the status
would generate the report with
* appropriate content. The method also checks whether the report has any foot notes
attached to the test case. If
* any foot note is found, then its added to the <code>footNotes</code>
ArrayList for later processing.
- *
- * @param result
- * @param writer
- * @throws IOException
*/
private void writeTestResult(TestResult result, BufferedWriter writer) throws
IOException
{
Modified: cache-bench-fwk/trunk/src/org/cachebench/tests/CacheTest.java
===================================================================
--- cache-bench-fwk/trunk/src/org/cachebench/tests/CacheTest.java 2007-12-30 08:13:49 UTC
(rev 4926)
+++ cache-bench-fwk/trunk/src/org/cachebench/tests/CacheTest.java 2007-12-30 21:45:04 UTC
(rev 4927)
@@ -2,6 +2,7 @@
import org.cachebench.CacheWrapper;
import org.cachebench.TestResult;
+import org.cachebench.config.Configuration;
/**
@@ -10,6 +11,9 @@
*/
public interface CacheTest
{
+
+ public void setConfiguration(Configuration configuration);
+
/**
* Performs the benchmarking on the given tese.
*
Added: cache-bench-fwk/trunk/src/org/cachebench/tests/ReplicationOccursTest.java
===================================================================
--- cache-bench-fwk/trunk/src/org/cachebench/tests/ReplicationOccursTest.java
(rev 0)
+++ cache-bench-fwk/trunk/src/org/cachebench/tests/ReplicationOccursTest.java 2007-12-30
21:45:04 UTC (rev 4927)
@@ -0,0 +1,124 @@
+package org.cachebench.tests;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.cachebench.CacheWrapper;
+import org.cachebench.TestResult;
+import org.cachebench.cluster.ClusterBarrier;
+import org.cachebench.config.Configuration;
+import org.cachebench.config.TestConfig;
+import org.cachebench.config.TestCase;
+
+import java.net.SocketAddress;
+import java.util.Map;
+
+/**
+ * For tests that stress cluster replication, this check whether a put in this node is
replicated across the cluster.
+ * The purpose of this is to ensure that nodes are configured correctly (they have
replication enabled and it works).
+ *
+ * @author Mircea.Markus(a)jboss.com
+ */
+public class ReplicationOccursTest implements CacheTest
+{
+ public static final Log log = LogFactory.getLog(ReplicationOccursTest.class);
+
+ private Configuration conf;
+ private static final String PREFIX = "_ReplicationOccursTest_";
+
+ public void setConfiguration(Configuration configuration)
+ {
+ this.conf = configuration;
+ }
+
+ public TestResult 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");
+ Thread.sleep(2000);//just to make sure that prev barrier closed its sockets etc
+
+ boolean allNodesReplicated = nodesReplicated(cache, testCaseName, testName);
+
+ Map<SocketAddress, Object> receivedValues =
broadcastReplicationResult(allNodesReplicated);
+ cache.empty();
+ return allReplicatedFine(receivedValues);
+ }
+
+ private Map<SocketAddress, Object> broadcastReplicationResult(boolean
allNodesReplicated)
+ throws Exception
+ {
+ ClusterBarrier barrier = new ClusterBarrier();
+ barrier.setConfig(conf.getClusterConfig());
+ barrier.barrier(String.valueOf(allNodesReplicated));
+ Map<SocketAddress,Object> receivedValues = barrier.getReceivedMessages();
+ log.info("Recieved following responses from barrier:" + receivedValues);
+ return receivedValues;
+ }
+
+ private void barrierBeforeReplicationTest()
+ throws Exception
+ {
+ ClusterBarrier barrier = new ClusterBarrier();
+ barrier.setAcknowledge(true);
+ barrier.setConfig(conf.getClusterConfig());
+ barrier.barrier("BEFORE_REPLICATION_OCCURS_BARRIER");
+ }
+
+ private TestResult allReplicatedFine(Map<SocketAddress, Object> receivedValues)
+ {
+ TestResult result = new TestResult();
+ result.setSkipReport(true);
+ for (Object value: receivedValues.values())
+ {
+ if (!"true".equals(value))
+ {
+ log.info("Replication was not successull on the entire cluster!");
+ result.setTestPassed(false);
+ return result;
+ }
+ }
+ result.setTestPassed(true);
+ log.info("Replication test successfully passed.");
+ return result;
+ }
+
+ 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
+ {
+ int clusterSize = conf.getClusterConfig().getClusterSize();
+ int replicaCount = 0;
+ for (int i = 0; i < clusterSize; i++)
+ {
+ int currentNodeIndex = conf.getClusterConfig().getCurrentNodeIndex();
+ if (i == currentNodeIndex)
+ {
+ continue;
+ }
+ Object data = cache.getReplicatedData(PREFIX + i);
+ if (data == null || !"true".equals(data))
+ {
+ log.trace("Cache with index " + i + " did *NOT*
replicate");
+ }
+ else
+ {
+ log.trace("Cache with index " + i + " replicated here
");
+ replicaCount++;
+ }
+ }
+ log.info("Number of caches that replicated here is " + replicaCount);
+ if (isPartialReplication(testCaseName, testName))
+ {
+ return replicaCount > 0;
+ }
+ return replicaCount == conf.getClusterConfig().getClusterSize() - 1;
+ }
+}
Modified: cache-bench-fwk/trunk/src/org/cachebench/tests/SimpleTest.java
===================================================================
--- cache-bench-fwk/trunk/src/org/cachebench/tests/SimpleTest.java 2007-12-30 08:13:49 UTC
(rev 4926)
+++ cache-bench-fwk/trunk/src/org/cachebench/tests/SimpleTest.java 2007-12-30 21:45:04 UTC
(rev 4927)
@@ -6,6 +6,7 @@
import org.cachebench.CacheWrapper;
import org.cachebench.SerializableCacheWrapper;
import org.cachebench.TestResult;
+import org.cachebench.config.Configuration;
import java.io.Serializable;
import java.io.ByteArrayOutputStream;
@@ -28,6 +29,7 @@
protected long elapsedSecondsForAllPuts = 0;
protected ExecutorService executor;
private static final int EXECUTOR_SHUTDOWN_TIMEOUT_POLL_SECS = 60;
+ protected Configuration configuration;
protected TestResult performTestWithObjectType(String testCaseName, CacheWrapper
cache, Class valueClass, String testName, int sampleSize, int numThreads) throws
Exception
{
@@ -277,4 +279,9 @@
return "";
}
}
+
+ public void setConfiguration(Configuration configuration)
+ {
+ this.configuration = configuration;
+ }
}