[jbosscache-commits] JBoss Cache SVN: r4843 - in cache-bench-fwk/trunk: cache-products/terracotta-2.4.8/src/org/cachebench/cachewrappers and 4 other directories.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Wed Dec 12 10:22:27 EST 2007
Author: mircea.markus
Date: 2007-12-12 10:22:27 -0500 (Wed, 12 Dec 2007)
New Revision: 4843
Added:
cache-bench-fwk/trunk/src/org/cachebench/reportgenerators/ClusterReportGenerator.java
Modified:
cache-bench-fwk/trunk/build.xml
cache-bench-fwk/trunk/cache-products/terracotta-2.4.8/src/org/cachebench/cachewrappers/TerracottaWrapper.java
cache-bench-fwk/trunk/conf/cachebench.xml
cache-bench-fwk/trunk/src/org/cachebench/CacheBenchmarkRunner.java
cache-bench-fwk/trunk/src/org/cachebench/CacheBenchmarkSlave.java
cache-bench-fwk/trunk/src/org/cachebench/TestResult.java
cache-bench-fwk/trunk/src/org/cachebench/config/Report.java
cache-bench-fwk/trunk/src/org/cachebench/reportgenerators/AbstractReportGenerator.java
cache-bench-fwk/trunk/src/org/cachebench/reportgenerators/CSVReportGenerator.java
cache-bench-fwk/trunk/src/org/cachebench/reportgenerators/ReportGenerator.java
Log:
enhance the framework so that all nodes are able to insert data into cache
Modified: cache-bench-fwk/trunk/build.xml
===================================================================
--- cache-bench-fwk/trunk/build.xml 2007-12-12 14:41:07 UTC (rev 4842)
+++ cache-bench-fwk/trunk/build.xml 2007-12-12 15:22:27 UTC (rev 4843)
@@ -283,7 +283,7 @@
<delete dir="${coherence322-plugin.testoutput.dir}"/>
</target>
- <!-- Module terracotta-2.3.0 -->
+ <!-- Module terracotta-2.4.8 -->
<dirname property="module.terracotta-plugin.basedir" file="${ant.file}"/>
@@ -291,18 +291,18 @@
<property name="compiler.args.terracotta-plugin" value="${compiler.args}"/>
- <property name="terracotta-plugin.output.dir" value="${module.terracotta-plugin.basedir}/classes/production/terracotta-2.3.0"/>
- <property name="terracotta-plugin.testoutput.dir" value="${module.terracotta-plugin.basedir}/classes/test/terracotta-2.3.0"/>
+ <property name="terracotta-plugin.output.dir" value="${module.terracotta-plugin.basedir}/classes/production/terracotta-2.4.8"/>
+ <property name="terracotta-plugin.testoutput.dir" value="${module.terracotta-plugin.basedir}/classes/test/terracotta-2.4.8"/>
<path id="terracotta-plugin.module.bootclasspath">
<!-- Paths to be included in compilation bootclasspath -->
</path>
<path id="terracotta-plugin.module.classpath">
- <pathelement location="${module.terracotta-plugin.basedir}/cache-products/terracotta-2.3.0/conf"/>
+ <pathelement location="${module.terracotta-plugin.basedir}/cache-products/terracotta-2.4.8/conf"/>
<pathelement location="${framework.output.dir}"/>
<pathelement location="${framework.testoutput.dir}"/>
- <fileset dir="${module.terracotta-plugin.basedir}/cache-products/terracotta-2.3.0/lib" includes="*.jar" />
+ <fileset dir="${module.terracotta-plugin.basedir}/cache-products/terracotta-2.4.8/lib" includes="*.jar" />
<pathelement location="${terracotta-plugin.output.dir}" />
</path>
@@ -316,15 +316,15 @@
</patternset>
<path id="terracotta-plugin.module.sourcepath">
- <dirset dir="${module.terracotta-plugin.basedir}/cache-products/terracotta-2.3.0">
+ <dirset dir="${module.terracotta-plugin.basedir}/cache-products/terracotta-2.4.8">
<include name="src"/>
</dirset>
</path>
- <target name="compile.module.terracotta-plugin" depends="compile.module.terracotta-plugin.production,compile.module.terracotta-plugin.tests" description="Compile module terracotta-2.3.0"/>
+ <target name="compile.module.terracotta-plugin" depends="compile.module.terracotta-plugin.production,compile.module.terracotta-plugin.tests" description="Compile module terracotta-2.4.8"/>
- <target name="compile.module.terracotta-plugin.production" depends="compile.module.framework" description="Compile module terracotta-2.3.0; production classes">
+ <target name="compile.module.terracotta-plugin.production" depends="compile.module.framework" description="Compile module terracotta-2.4.8; production classes">
<mkdir dir="${terracotta-plugin.output.dir}"/>
<javac destdir="${terracotta-plugin.output.dir}" debug="${compiler.debug}" nowarn="${compiler.generate.no.warnings}" memorymaximumsize="${compiler.max.memory}" fork="true">
<compilerarg line="${compiler.args.terracotta-plugin}"/>
@@ -335,14 +335,14 @@
</javac>
<copy todir="${terracotta-plugin.output.dir}">
- <fileset dir="${module.terracotta-plugin.basedir}/cache-products/terracotta-2.3.0/src">
+ <fileset dir="${module.terracotta-plugin.basedir}/cache-products/terracotta-2.4.8/src">
<patternset refid="compiler.resources"/>
<type type="file"/>
</fileset>
</copy>
</target>
- <target name="compile.module.terracotta-plugin.tests" depends="compile.module.terracotta-plugin.production" description="compile module terracotta-2.3.0; test classes" unless="skip.tests"/>
+ <target name="compile.module.terracotta-plugin.tests" depends="compile.module.terracotta-plugin.production" description="compile module terracotta-2.4.8; test classes" unless="skip.tests"/>
<target name="clean.module.terracotta-plugin" description="cleanup module">
<delete dir="${terracotta-plugin.output.dir}"/>
@@ -528,10 +528,11 @@
<java classname="${runtime.classname}" fork="${jvm.fork}" maxmemory="${jvm.maxmem}" clonevm="true">
<!--<bootclasspath>-->
- <!--<pathelement location="./cache-products/terracotta-2.3.0/lib/bootstrap/boot.jar" />-->
+ <!--<pathelement location="./cache-products/terracotta-2.4.8/lib/bootstrap/boot.jar" />-->
<!--</bootclasspath>-->
<sysproperty key="bind.address" value="${bind.address}" />
<sysproperty key="tangosol.coherence.localhost" value="${tangosol.coherence.localhost}" />
+ <sysproperty key="cluterReportGenerator" value="${cluterReportGenerator}" />
<sysproperty key="org.cachebench.debug" value="${org.cachebench.debug}" />
<sysproperty key="java.net.preferIPv4Stack" value="${java.net.preferIPv4Stack}" />
<classpath refid="framework.module.classpath" />
@@ -541,13 +542,15 @@
<target name="runSlave">
<antcall target="run">
- <param name="runtime.classname" value="org.cachebench.CacheBenchmarkSlave" />
+ <param name="runtime.classname" value="org.cachebench.CacheBenchmarkRunner" />
+ <param name="cluterReportGenerator" value="false"/>
</antcall>
</target>
<target name="runMaster">
<antcall target="run">
<param name="runtime.classname" value="org.cachebench.CacheBenchmarkRunner" />
+ <param name="cluterReportGenerator" value="true"/>
</antcall>
</target>
Modified: cache-bench-fwk/trunk/cache-products/terracotta-2.4.8/src/org/cachebench/cachewrappers/TerracottaWrapper.java
===================================================================
--- cache-bench-fwk/trunk/cache-products/terracotta-2.4.8/src/org/cachebench/cachewrappers/TerracottaWrapper.java 2007-12-12 14:41:07 UTC (rev 4842)
+++ cache-bench-fwk/trunk/cache-products/terracotta-2.4.8/src/org/cachebench/cachewrappers/TerracottaWrapper.java 2007-12-12 15:22:27 UTC (rev 4843)
@@ -16,7 +16,7 @@
public class TerracottaWrapper implements CacheWrapper
{
// Since terracotta
- private Map cache;
+ private Map cache = new HashMap();
public void init(Properties parameters) throws Exception
{
@@ -24,13 +24,14 @@
public void setUp() throws Exception
{
- cache = new HashMap();
}
public void tearDown() throws Exception
{
- cache.clear();
- cache = null;
+ synchronized(cache)
+ {
+ cache.clear();
+ }
}
public void put(Object key, Object value) throws Exception
@@ -64,6 +65,9 @@
public String getInfo()
{
- return "There are " + cache.size() + " objects in cache";
+ synchronized(cache)
+ {
+ return "There are " + cache.size() + " objects in cache";
+ }
}
}
Modified: cache-bench-fwk/trunk/conf/cachebench.xml
===================================================================
--- cache-bench-fwk/trunk/conf/cachebench.xml 2007-12-12 14:41:07 UTC (rev 4842)
+++ cache-bench-fwk/trunk/conf/cachebench.xml 2007-12-12 15:22:27 UTC (rev 4843)
@@ -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="1000000" gcBetweenTestsEnabled="true" sleepBetweenTests="1000" emptyCacheBetweenTests="true" numThreads="10">
+<cachebench sampleSize="10000" gcBetweenTestsEnabled="true" sleepBetweenTests="1000" emptyCacheBetweenTests="true" numThreads="10">
<!-- Each testcase represents either a single configuration or a cacheing product.
@@ -31,7 +31,7 @@
<!--<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="Coherence-3.x" cacheWrapper="org.cachebench.cachewrappers.CoherenceWrapper">
+ <testcase name="JBossCache2.0" cacheWrapper="org.cachebench.cachewrappers.JBossCache200Wrapper">
<!--
* The "name" attrib is just used for display in the reports.
@@ -62,12 +62,17 @@
</testcase>
- <!-- Currently we only have a CSVReportGenerator. 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, cluster size is
+ needed so that the . -->
+ <report outputFile="performance.csv" generator="org.cachebench.reportgenerators.ClusterReportGenerator">
+ <param name="clusterSize" value="3"/>
+ <param name="masterHost" value="127.0.0.1"/>
+ <param name="masterPort" value="54334"/>
+ </report>
- <!-- The CSV report generated can be plugged in to a spreadsheet to generate graphs, etc. -->
- <report
- outputFile="performance.csv"
- generator="org.cachebench.reportgenerators.CSVReportGenerator" />
-
</cachebench>
Modified: cache-bench-fwk/trunk/src/org/cachebench/CacheBenchmarkRunner.java
===================================================================
--- cache-bench-fwk/trunk/src/org/cachebench/CacheBenchmarkRunner.java 2007-12-12 14:41:07 UTC (rev 4842)
+++ cache-bench-fwk/trunk/src/org/cachebench/CacheBenchmarkRunner.java 2007-12-12 15:22:27 UTC (rev 4843)
@@ -114,6 +114,11 @@
digester.addObjectCreate("cachebench/report", "org.cachebench.config.Report");
digester.addSetProperties("cachebench/report");
+
+ digester.addObjectCreate("cachebench/report/param", "org.cachebench.config.NVPair");
+ digester.addSetProperties("cachebench/report/param");
+ digester.addSetNext("cachebench/report/param", "addParam", "org.cachebench.config.NVPair");
+
digester.addSetNext("cachebench/report", "addReport", "org.cachebench.config.Report");
return (Configuration) digester.parse(url.openStream());
}
@@ -230,13 +235,14 @@
ReportGenerator generator;
try
{
- generator = getReportWrapper(report);
+ generator = getReportGenerator(report);
if (generator != null)
{
+ generator.setConfigParams(report.getParams());
generator.setResults(results);
generator.setOutputFile(new File(report.getOutputFile()));
generator.generate();
- logger.info("Report Generation Complted");
+ logger.info("Report Generation Completed");
}
else
{
@@ -301,7 +307,7 @@
return cache;
}
- private ReportGenerator getReportWrapper(Report reportClass)
+ private ReportGenerator getReportGenerator(Report reportClass)
{
ReportGenerator report = null;
try
Modified: cache-bench-fwk/trunk/src/org/cachebench/CacheBenchmarkSlave.java
===================================================================
--- cache-bench-fwk/trunk/src/org/cachebench/CacheBenchmarkSlave.java 2007-12-12 14:41:07 UTC (rev 4842)
+++ cache-bench-fwk/trunk/src/org/cachebench/CacheBenchmarkSlave.java 2007-12-12 15:22:27 UTC (rev 4843)
@@ -18,6 +18,7 @@
/**
* @author Manik Surtani (manik at surtani.org)
* @version $Id: CacheBenchmarkSlave.java,v 1.8 2007/05/21 16:30:00 msurtani Exp $
+ * @deprecated all tests should run in server mode, as all the test are putting data into the test
*/
public class CacheBenchmarkSlave
{
Modified: cache-bench-fwk/trunk/src/org/cachebench/TestResult.java
===================================================================
--- cache-bench-fwk/trunk/src/org/cachebench/TestResult.java 2007-12-12 14:41:07 UTC (rev 4842)
+++ cache-bench-fwk/trunk/src/org/cachebench/TestResult.java 2007-12-12 15:22:27 UTC (rev 4843)
@@ -2,6 +2,7 @@
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics;
+import java.io.Serializable;
import java.util.Date;
@@ -9,7 +10,7 @@
* @author Manik Surtani (manik at surtani.org)
* @version $Id: TestResult.java,v 1.4 2007/04/18 19:09:30 msurtani Exp $
*/
-public class TestResult
+public class TestResult implements Serializable
{
private String testName;
private String testType;
@@ -152,4 +153,22 @@
{
this.numThreads = numThreads;
}
+
+ public String toString()
+ {
+ return "TestResult{" +
+ "testName='" + testName + '\'' +
+ ", testType='" + testType + '\'' +
+ ", testTime=" + testTime +
+ ", putData=" + putData +
+ ", getData=" + getData +
+ ", testPassed=" + testPassed +
+ ", errorMsg='" + errorMsg + '\'' +
+ ", footNote='" + footNote + '\'' +
+ ", throughputTransactionsPerSecond=" + throughputTransactionsPerSecond +
+ ", throughputBytesPerSecond=" + throughputBytesPerSecond +
+ ", numMembers=" + numMembers +
+ ", numThreads=" + numThreads +
+ '}';
+ }
}
Modified: cache-bench-fwk/trunk/src/org/cachebench/config/Report.java
===================================================================
--- cache-bench-fwk/trunk/src/org/cachebench/config/Report.java 2007-12-12 14:41:07 UTC (rev 4842)
+++ cache-bench-fwk/trunk/src/org/cachebench/config/Report.java 2007-12-12 15:22:27 UTC (rev 4843)
@@ -1,16 +1,30 @@
package org.cachebench.config;
+import java.util.Map;
+import java.util.HashMap;
+
public class Report
{
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/reportgenerators/AbstractReportGenerator.java
===================================================================
--- cache-bench-fwk/trunk/src/org/cachebench/reportgenerators/AbstractReportGenerator.java 2007-12-12 14:41:07 UTC (rev 4842)
+++ cache-bench-fwk/trunk/src/org/cachebench/reportgenerators/AbstractReportGenerator.java 2007-12-12 15:22:27 UTC (rev 4843)
@@ -1,13 +1,11 @@
package org.cachebench.reportgenerators;
-import org.cachebench.TestResult;
import org.apache.commons.logging.Log;
+import org.cachebench.TestResult;
import java.io.File;
import java.util.List;
-import java.util.Enumeration;
-import java.net.NetworkInterface;
-import java.net.InetAddress;
+import java.util.Map;
/**
* Base implementation of {@link org.cachebench.reportgenerators.ReportGenerator}
Modified: cache-bench-fwk/trunk/src/org/cachebench/reportgenerators/CSVReportGenerator.java
===================================================================
--- cache-bench-fwk/trunk/src/org/cachebench/reportgenerators/CSVReportGenerator.java 2007-12-12 14:41:07 UTC (rev 4842)
+++ cache-bench-fwk/trunk/src/org/cachebench/reportgenerators/CSVReportGenerator.java 2007-12-12 15:22:27 UTC (rev 4843)
@@ -11,6 +11,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
/**
@@ -161,4 +162,9 @@
}
log.debug("Complted the Footnotes");
}
+
+ public void setConfigParams(Map configParams)
+ {
+ //we are not intereseted in any params, yet (e.g. may be we want to change separator from comma to tab)
+ }
}
Added: cache-bench-fwk/trunk/src/org/cachebench/reportgenerators/ClusterReportGenerator.java
===================================================================
--- cache-bench-fwk/trunk/src/org/cachebench/reportgenerators/ClusterReportGenerator.java (rev 0)
+++ cache-bench-fwk/trunk/src/org/cachebench/reportgenerators/ClusterReportGenerator.java 2007-12-12 15:22:27 UTC (rev 4843)
@@ -0,0 +1,152 @@
+package org.cachebench.reportgenerators;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.cachebench.TestResult;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.net.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Gathers info from all the nodes executing tests.
+ * Merges all the gathered information and generates an CSV file based on that.
+ *
+ * @author Mircea.Markus at jboss.com
+ * @version 2.2
+ */
+public class ClusterReportGenerator extends AbstractReportGenerator
+{
+ private static Log log = LogFactory.getLog(ClusterReportGenerator.class);
+
+ private int clusterSize;
+
+ private int masterPort;
+
+ private String masterHost;
+
+ public void setConfigParams(Map<String, String> configParams)
+ {
+ log.trace("Received config params: " + configParams);
+ this.clusterSize = Integer.parseInt(configParams.get("clusterSize"));
+ this.masterPort = Integer.parseInt(configParams.get("masterPort"));
+ this.masterHost = configParams.get("masterHost");
+ }
+
+ public void generate() throws Exception
+ {
+ try
+ {
+ log.trace("Cluster report generator property value: " + System.getProperty("cluterReportGenerator"));
+ boolean isGeneratorNode = System.getProperty("cluterReportGenerator") != null
+ && "true".equalsIgnoreCase(System.getProperty("cluterReportGenerator"));
+ log.trace(" Starting generating. Is master? " + isGeneratorNode);
+ if (isGeneratorNode)
+ {
+ generateReport();
+ }
+ else
+ {
+ submitReportInfo();
+ }
+ } catch (Exception e)
+ {
+ log.error("Error while generating report!", e);
+ }
+ }
+
+ /**
+ * If not a master, sends report data to master.
+ */
+ private void submitReportInfo() throws IOException, ClassNotFoundException
+ {
+ log.trace("Sending the following results to master: " + results);
+ boolean connected = false;
+ Socket socket = null;
+ while (!connected)
+ {
+ try
+ {
+ log.trace("Connecting to master on " + masterHost + ":" + masterPort + "...");
+ socket = new Socket(masterHost, masterPort);
+ log.trace("Connected");
+ connected = true;
+ } catch (IOException e)
+ {
+ log.trace("Failed to connect(" + e.getMessage() + "), trying again..." );
+ connected = false;
+ }
+ }
+ ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());
+ oos.writeObject(this.results);
+ oos.close();
+ socket.close();
+ log.trace("Following results were sent to server: " + results);
+ }
+
+ private void generateReport() throws Exception
+ {
+ List<List<TestResult>> results = retrieveResultsFromClients();
+ List<TestResult> mergedResults = mergerTestResultsAndGenerateReport(results);
+ generateReportFile(mergedResults);
+ }
+
+ @SuppressWarnings(value = "unchecked")
+ private List<List<TestResult>> retrieveResultsFromClients()
+ throws IOException, ClassNotFoundException
+ {
+ ServerSocket socket = new ServerSocket(masterPort);
+ List<List<TestResult>> results = new ArrayList<List<TestResult>>();
+ results.add(this.results);
+ //we go expect cluster size-1 because this is also a node, ant it does not sent report info
+ for (int i = 0; i < clusterSize - 1; i++)
+ {
+ log.trace("Expecting " + (clusterSize - i - 1) + " more client(s)");
+ log.trace(" Waiting for client to conect...");
+ Socket client = socket.accept();
+ log.trace("Client connected: " + client.getInetAddress());
+ ObjectInputStream ois = new ObjectInputStream(client.getInputStream());
+ List<TestResult> testResults = (List<TestResult>) ois.readObject();
+ results.add(testResults);
+ log.trace("Received following resullts from client: " + testResults);
+ ois.close();
+ client.close();
+ }
+ socket.close();
+ return results;
+ }
+
+
+ private void generateReportFile(List<TestResult> mergedResults) throws Exception
+ {
+ CSVReportGenerator generator = new CSVReportGenerator();
+ generator.setResults(mergedResults);
+ generator.setOutputFile(output);
+ generator.generate();
+ }
+
+ private List<TestResult> mergerTestResultsAndGenerateReport(List<List<TestResult>> results)
+ {
+ List<TestResult> mergedResults = new ArrayList<TestResult>();
+ for (int i = 0; i < results.get(0).size(); i++)
+ {
+ for (int j = 0; j < results.size(); j++)
+ {
+ //if one servers sent us more results that the other(s) fail!
+ if (j > 0 && results.get(j).size() != results.get(j - 1).size())
+ {
+ //not effcient as it gets execute each time but not really matters
+ throw new RuntimeException("Not all servers send the same number of responses. I.e. not all severs run the same number of tests!!!");
+ }
+ mergedResults.add(results.get(j).get(i));
+ }
+ }
+ log.trace("Merged tests are: " + mergedResults);
+ return mergedResults;
+ }
+
+}
Modified: cache-bench-fwk/trunk/src/org/cachebench/reportgenerators/ReportGenerator.java
===================================================================
--- cache-bench-fwk/trunk/src/org/cachebench/reportgenerators/ReportGenerator.java 2007-12-12 14:41:07 UTC (rev 4842)
+++ cache-bench-fwk/trunk/src/org/cachebench/reportgenerators/ReportGenerator.java 2007-12-12 15:22:27 UTC (rev 4843)
@@ -4,6 +4,7 @@
import java.io.File;
import java.util.List;
+import java.util.Map;
/**
@@ -12,6 +13,8 @@
*/
public interface ReportGenerator
{
+ public abstract void setConfigParams(Map<String, String> configParams);
+
public void setOutputFile(File output);
public void setResults(List<TestResult> results);
More information about the jbosscache-commits
mailing list