[jboss-svn-commits] JBL Code SVN: r37075 - in labs/jbosstm/trunk/qa/tests/product: lib and 5 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Jun 8 14:59:25 EDT 2011
Author: mmusgrov
Date: 2011-06-08 14:59:25 -0400 (Wed, 08 Jun 2011)
New Revision: 37075
Added:
labs/jbosstm/trunk/qa/tests/product/lib/btm/
labs/jbosstm/trunk/qa/tests/product/src/org/
labs/jbosstm/trunk/qa/tests/product/src/org/narayana/
labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/
labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/
labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/AtomikosWorkerTask.java
labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/BitronixWorkerTask.java
labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/DummyTransaction.java
labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/DummyTransactionManager.java
labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/JotmWorkerTask.java
labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/NarayanaWorkerTask.java
labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/TxnPerformanceTest.java
labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/WorkerTask.java
labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/XAResourceImpl.java
Removed:
labs/jbosstm/trunk/qa/tests/product/src/com/
Modified:
labs/jbosstm/trunk/qa/tests/product/build.xml
Log:
[JBTM-395] Remove XA resource testing. Improve the performance test harness
Modified: labs/jbosstm/trunk/qa/tests/product/build.xml
===================================================================
--- labs/jbosstm/trunk/qa/tests/product/build.xml 2011-06-08 10:42:42 UTC (rev 37074)
+++ labs/jbosstm/trunk/qa/tests/product/build.xml 2011-06-08 18:59:25 UTC (rev 37075)
@@ -4,64 +4,39 @@
1. Download required jars
=========================
-To test a product download the relevant libraries and put them on the classpath.
-The required libraries for the following products
- atomikos
- bitronix
- jbossts
- jotm
- simplejta
-are listed below but, with the exception of jbossts, you will need to download them.
-The compile ant target below currently excludes all products (except JBossTS) - once
-you have the available jars for a product remember to remove the exclude line.
+To test a product download the relevant libraries and put them in the lib directory:
-2. Download required dbs
-========================
-The tests operate against XA resources.
-The required libraries for the following databases
- H2
- Derby
- Mysql
-are listed below but, with the exception of H2, you will need to download them.
+Atomikos release 3.7.0
+lib/atomikos/transactions-osgi.jar
-Thus a test of the JBossTS product with 2 H2 XA resources should work out of the box.
+Bitronix release 2.1.0
+lib/btm/btm-2.1.0.jar
+lib/btm/lib/slf4j-api-1.6.0.jar
+lib/btm/lib/slf4j-log4j12-1.6.0.jar
+lib/btm/lib/log4j-1.2.14.jar
-[If mysql or derby support is required then uncomment the appropriate data source
-initialisation methods in class com.arjuna.ats.tools.perftest.DbWrapper]
+JOTM release 2.2.1
+Copy the contents of the lib dir from JOTM distribution to
+lib/jotm
+JBossTS jars are sourced from the build
+
+The compile ant target below currently excludes all products (except JBossTS) - once
+you have the available jars for a product remember to remove the exclude line.
+
3. Adding suport for a new product
==================================
The following steps are needed to integrate a new transaction product:
- obtain the required jars and add them to the classpath
-- write a class that extends com.arjuna.ats.tools.perftest.product.Product
- implement all the abstract methods
- you may override any accessible methods in the base class if required
- (take a look at any of the existing sub-classes of Product to see what's available).
-- put any required configuration files in the resources directory ${res.dir} make sure
- they are accessible when running a target (see the run target below for examples)
+- write a class that extends the abstract class org.narayana.tools.perf.WorkerTask
4. Testing a product
====================
-To test a particular product add it to the following ant property:
- <property name="products" value="class name of the Product subclass, other products to test" />
+To test particular products specify them on the command line with a -p flag (comma separated). For example:
-You can control various parameters by passing args to the JVM (or use xargs=arg1%arg2%... to bundle args together):
- tx.count=<no of txns>
- db.user=<comma separated list of db users>
- db.password=<comma separated list of db passwords>
- db.url=<comma separated list of db urls>
+ ant -Dargs="-p org.narayana.tools.perf.AtomikosWorkerTask,org.narayana.tools.perf.NarayanaWorkerTask,org.narayana.tools.perf.BitronixWorkerTask,org.narayana.tools.perf.JotmWorkerTask -i 100 -t 5"
-When testing the JBossTS project you can tweek parameters via its properties file by setting the ant propery
- <property name="propfile" value="path to jbossts property file"/>
-
-Test run output is stored in files controlled by two ant properties called result.file and csv.file
-
-You can override some properties from the command line:
- ant -Dxargs=... -Dproducts=... -Dpropfile=...
-
-for example to use a property file called newproperties.xml with the JBossTS product, perhaps for testing
-different object store implementations, the command would be
- ant -Dpropfile=newproperties.xml
+will test Atomikos, JBossTS, Bitronix and JOTM and commit 100 transactions using 5 threads for each product.
-->
<project name="JBoss" default="run" basedir=".">
@@ -69,7 +44,7 @@
<property name="lib.dir" value="${basedir}/lib" />
<property name="build.dir" value="${basedir}/build" />
<property name="build.classes.dir" value="${build.dir}/classes" />
- <property name="jbossts.home" value="../../../install" />
+ <property name="jbossts.install" value="../../../install" />
<!--
location of resources needed by the various products
-->
@@ -77,83 +52,51 @@
<property name="log.dir" value="logs" />
<property name="suspend" value="n" />
- <!-- Atomikos: http://www.atomikos.com/Main/TransactionsEssentials -->
- <path id="classpath.atomikos">
- <pathelement location="${lib.dir}/atomikos/transactions-essentials-all.jar" />
- </path>
- <!-- Bitronix: http://docs.codehaus.org/display/BTM/Download -->
+ <!-- Bitronix: http://docs.codehaus.org/display/BTM/Download release 2.1.0 -->
<path id="classpath.bitronix">
- <pathelement location="${lib.dir}/btm/btm-1.2.jar" />
- <pathelement location="${lib.dir}/btm/slf4j-api-1.4.3.jar" />
- <pathelement location="${lib.dir}/btm/slf4j-jdk14-1.4.3.jar" />
+ <pathelement location="${lib.dir}/btm/btm-2.1.0.jar" />
+ <pathelement location="${lib.dir}/btm/lib/slf4j-api-1.6.0.jar" />
+ <pathelement location="${lib.dir}/btm/lib/slf4j-log4j12-1.6.0.jar" />
+ <pathelement location="${lib.dir}/btm/lib/log4j-1.2.14.jar" />
</path>
- <!-- JBossTS: http://www.jboss.org/download/ -->
- <path id="classpath.jbossts">
- <pathelement location="${jbossts.home}/lib/ext/jbossts-common.jar" />
-
-<!--
- <fileset dir="${lib.dir}">
- <include name="**/*.jar"/>
- </fileset>
--->
- <pathelement location="${jbossts.home}/lib/jbossjta.jar" />
- <pathelement location="${jbossts.home}/lib/jbossjts.jar" />
-
- <pathelement location="${lib.dir}/jbossts/fscontext.jar" />
- <pathelement location="${lib.dir}/jbossts/providerutil.jar" />
+ <!-- Atomikos: http://www.atomikos.com/Main/TransactionsEssentials release 3.7.0 -->
+ <path id="classpath.atomikos">
+ <pathelement location="${lib.dir}/atomikos/transactions-osgi.jar" />
</path>
- <!-- apache logging -->
- <path id="classpath.common">
- <pathelement location="${jbossts.home}/lib/ext/log4j-1.2.14.jar" />
- </path>
- <!-- JOTM: http://jotm.objectweb.org/download/index.html -->
+ <!-- JOTM: http://jotm.objectweb.org/download/index.html release 2.2.1 -->
<path id="classpath.jotm">
- <pathelement location="${lib.dir}/jotm/connector-1_5.jar" />
+ <pathelement location="${lib.dir}/jotm/ow2-connector-1.5-spec.jar" />
<pathelement location="${lib.dir}/jotm/howl.jar" />
- <pathelement location="${lib.dir}/jotm/jotm_iiop_stubs.jar" />
- <pathelement location="${lib.dir}/jotm/jotm.jar" />
- <pathelement location="${lib.dir}/jotm/jotm_jrmp_stubs.jar" />
- <pathelement location="${lib.dir}/jotm/ow_carol.jar" />
+ <pathelement location="${lib.dir}/jotm/jotm-standalone.jar" />
+ <pathelement location="${lib.dir}/jotm/carol.jar" />
<pathelement location="${lib.dir}/jotm/xapool.jar" />
+ <pathelement location="${lib.dir}/jotm/jotm-core.jar" />
+ <pathelement location="${lib.dir}/jotm/jotm-client.jar" />
</path>
+ <!-- JBossTS: http://www.jboss.org/download/ the current build -->
+ <path id="classpath.jbossts">
+ <pathelement location="${jbossts.install}/lib/jbossjta.jar" />
+ <pathelement location="${jbossts.install}/../build/extlib/netty.jar" />
+ <pathelement location="${jbossts.install}/lib/ext/hornetq-core.jar" />
+ <pathelement location="${jbossts.install}/lib/ext/jboss-logging.jar" />
+ </path>
<!-- SimpleJTA: https://simple-jta.dev.java.net/servlets/ProjectDocumentList -->
<path id="classpath.simplejta">
<pathelement location="${lib.dir}/simplejta/simplejta-1.07.jar" />
</path>
-
- <path id="classpath.j2ee">
- <fileset dir="${jbossts.home}/lib/ext" includes="jta-1_1-classes.zip"/>
+ <!-- common dependencies -->
+ <path id="classpath.common">
+ <pathelement location="${build.classes.dir}"/>
+ <pathelement location="${res.dir}"/>
</path>
- <!-- http://db.apache.org/derby/index.html -->
- <!-- or http://mvnrepository.com/artifact/org.apache.derby -->
- <path id="classpath.derby">
- <pathelement location="${lib.dir}/common/db/derby/derbyclient.jar" />
- <pathelement location="${lib.dir}/common/db/derby/derby.jar" />
- <pathelement location="${lib.dir}/common/db/derby/derbynet.jar" />
- <pathelement location="${lib.dir}/common/db/derby/derbyrun.jar" />
- <pathelement location="${lib.dir}/common/db/derby/derbytools.jar" />
- </path>
- <!-- http://www.h2database.com/html/download.html -->
- <!-- http://dev.mysql.com/downloads/ (get the XA driver) -->
- <path id="classpath.driver">
- <pathelement location="${lib.dir}/common/db/driver/h2.jar" />
- <pathelement location="${lib.dir}/common/db/driver/mysql-connector-java-5.0.8-bin.jar" />
- </path>
<!-- Build classpath -->
<path id="classpath">
- <pathelement location="${res.dir}"/>
- <pathelement location="${build.classes.dir}"/>
-
- <path refid="classpath.atomikos" />
- <path refid="classpath.bitronix" />
- <path refid="classpath.jbossts" />
- <path refid="classpath.common"/>
- <path refid="classpath.jotm"/>
- <path refid="classpath.simplejta"/>
- <path refid="classpath.j2ee"/>
- <path refid="classpath.derby"/>
- <path refid="classpath.driver"/>
+ <path refid="classpath.bitronix"/>
+ <path refid="classpath.atomikos"/>
+ <path refid="classpath.jotm"/>
+ <path refid="classpath.jbossts"/>
+ <path refid="classpath.common"/>
</path>
<!--
@@ -163,8 +106,6 @@
-->
<target name="init">
- <available file="${jbossts.home}/lib/jbossjta.jar" property="is.jta" />
- <fail message="The tests only build on JTA version of JBossTS" unless="is.jta" />
<mkdir dir="${build.dir}"/>
<mkdir dir="${build.classes.dir}"/>
<mkdir dir="${log.dir}"/>
@@ -175,59 +116,37 @@
destdir="${build.classes.dir}"
debug="on"
deprecation="on"
- optimize="off"
+ optimize="on"
includes="**">
<classpath refid="classpath"/>
- <exclude name="com/arjuna/ats/tools/perftest/product/AtomikosProduct.java" />
- <exclude name="com/arjuna/ats/tools/perftest/product/BitronixProduct.java"/>
+
+ <exclude name="org/narayana/tools/perf/AtomikosWorkerTask.java" />
+ <exclude name="org/narayana/tools/perf/BitronixWorkerTask.java" />
+ <exclude name="org/narayana/tools/perf/JotmWorkerTask.java" />
+
<!--
- <exclude name="com/arjuna/ats/tools/perftest/product/JBossTSProduct.java" />
+ <compilerarg value="-Xlint"/>
-->
- <exclude name="com/arjuna/ats/tools/perftest/product/JOTMProduct.java" />
- <exclude name="com/arjuna/ats/tools/perftest/product/SimpleJTAProduct.java" />
</javac>
</target>
- <target name="init.products" unless="products">
- <property name="products" value="com.arjuna.ats.tools.perftest.product.NonXAProduct,com.arjuna.ats.tools.perftest.product.XAProduct,com.arjuna.ats.tools.perftest.product.JBossTSProduct,com.arjuna.ats.tools.perftest.product.BitronixProduct,com.arjuna.ats.tools.perftest.product.AtomikosProduct"/>
- </target>
+ <property name="args.all" value="-p org.narayana.tools.perf.AtomikosWorkerTask,org.narayana.tools.perf.NarayanaWorkerTask,org.narayana.tools.perf.BitronixWorkerTask,org.narayana.tools.perf.JotmWorkerTask -i 100 -t 5" />
+ <property name="args" value="-p org.narayana.tools.perf.NarayanaWorkerTask -i 100 -t 5" />
- <target name="init.xargs" unless="xargs">
- <property name="xargs" value="tx.count=100%thread.count=1%db.user=user1,user2%db.password=user1,user2%db.url=jdbc:h2:db1%db.url=jdbc:h2:db2"/>
- </target>
+ <target name="run" depends="compile">
+ <java classname="org.narayana.tools.perf.TxnPerformanceTest" fork="yes" dir=".">
- <target name="init.propfile" unless="propfile">
- <available file="${jbossts.home}/etc/jbossjta-properties.xml" property="propfile"
- value="${jbossts.home}/etc/jbossjta-properties.xml" />
- <available file="${jbossts.home}/etc/jbossjts-properties.xml" property="propfile"
- value="${jbossts.home}/etc/jbossjts-properties.xml" />
- </target>
-
- <target name="jar" depends="compile">
- <jar destfile="${build.dir}/harness.jar">
- <fileset dir="${build.classes.dir}">
- </fileset>
- </jar>
- </target>
-
- <target name="run" depends="compile,init.products,init.xargs,init.propfile">
- <java classname="com.arjuna.ats.tools.perftest.product.Product" fork="yes" dir=".">
<classpath refid="classpath"/>
- <!-- a list of products to be compared -->
- <sysproperty key="products" value="${products}" />
- <!-- test run arguments -->
- <sysproperty key="xargs" value="${xargs}" />
-
<!-- config files for each supported product -->
+ <!--
<sysproperty key="com.arjuna.ats.arjuna.common.propertiesFile" value="${propfile}" />
+ -->
<sysproperty key="jotm.base" value="${res.dir}" />
<jvmarg value="-Dcom.atomikos.icatch.file=${res.dir}/atomikos.properties"/>
<jvmarg value="-Dbitronix.tm.configuration=${res.dir}/btm.properties"/>
- <sysproperty key="h2.baseDir" value="${log.dir}" />
- <!-- location of output files -->
- <arg value="result.file=${log.dir}/result.log"/>
- <arg value="csv.file=${log.dir}/result.csv"/>
+ <!-- commandline args -->
+ <arg value="${args}" />
<!--
<jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=${suspend},address=5005" />
<jvmarg value="-Dcom.sun.management.jmxremote.authenticate=false" />
@@ -241,5 +160,7 @@
<target name="clean">
<delete dir="${build.dir}"/>
<delete dir="${log.dir}"/>
+ <delete dir="ObjectStore"/>
+ <delete file="transaction.log"/>
</target>
</project>
Added: labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/AtomikosWorkerTask.java
===================================================================
--- labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/AtomikosWorkerTask.java (rev 0)
+++ labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/AtomikosWorkerTask.java 2011-06-08 18:59:25 UTC (rev 37075)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and/or its affiliates,
+ * and individual contributors as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2011,
+ * @author JBoss, by Red Hat.
+ */
+package org.narayana.tools.perf;
+
+import com.atomikos.datasource.xa.AcceptAllXATransactionalResource;
+import com.atomikos.icatch.jta.UserTransactionManager;
+import com.atomikos.icatch.system.Configuration;
+
+import javax.transaction.TransactionManager;
+import javax.transaction.xa.XAResource;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.atomic.AtomicInteger;
+
+class AtomikosWorkerTask extends WorkerTask {
+ private UserTransactionManager tm;
+
+ protected AtomikosWorkerTask(CyclicBarrier cyclicBarrier, AtomicInteger count, int batch_size) {
+ super(cyclicBarrier, count, batch_size);
+
+ tm = new UserTransactionManager();
+
+ for (XAResource xar : resources.values()) {
+ AcceptAllXATransactionalResource rr = new AcceptAllXATransactionalResource(xar.toString());
+ Configuration.addResource(rr);
+ }
+ }
+
+ @Override
+ protected TransactionManager getTransactionManager() {
+ return tm;
+ }
+}
Added: labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/BitronixWorkerTask.java
===================================================================
--- labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/BitronixWorkerTask.java (rev 0)
+++ labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/BitronixWorkerTask.java 2011-06-08 18:59:25 UTC (rev 37075)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and/or its affiliates,
+ * and individual contributors as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2011,
+ * @author JBoss, by Red Hat.
+ */
+package org.narayana.tools.perf;
+
+import bitronix.tm.BitronixTransactionManager;
+import javax.transaction.TransactionManager;
+import javax.transaction.xa.XAResource;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.atomic.AtomicInteger;
+
+class BitronixWorkerTask extends WorkerTask {
+
+ protected BitronixWorkerTask(CyclicBarrier cyclicBarrier, AtomicInteger count, int batch_size) {
+ super(cyclicBarrier, count, batch_size);
+ }
+
+ @Override
+ protected TransactionManager getTransactionManager() {
+ return new BitronixTransactionManager();
+ }
+
+ protected void registerResource(String name, XAResource res) {
+ bitronix.tm.resource.ehcache.EhCacheXAResourceProducer.registerXAResource(name, res);
+ }
+
+ protected void unregisterResource(String name, XAResource res) {
+ bitronix.tm.resource.ehcache.EhCacheXAResourceProducer.unregisterXAResource(name, res);
+ }
+
+ public static void main(String[] args) {
+ XAResource res = new XAResourceImpl("x", 0);
+ bitronix.tm.resource.ehcache.EhCacheXAResourceProducer.registerXAResource("rm1", res);
+ }
+}
Added: labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/DummyTransaction.java
===================================================================
--- labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/DummyTransaction.java (rev 0)
+++ labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/DummyTransaction.java 2011-06-08 18:59:25 UTC (rev 37075)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and/or its affiliates,
+ * and individual contributors as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2011,
+ * @author JBoss, by Red Hat.
+ */
+package org.narayana.tools.perf;
+
+import javax.transaction.*;
+import javax.transaction.xa.XAResource;
+
+public class DummyTransaction implements Transaction {
+ public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, SystemException {
+ }
+
+ public void rollback() throws IllegalStateException, SystemException {
+ }
+
+ public void setRollbackOnly() throws IllegalStateException, SystemException {
+ }
+
+ public int getStatus() throws SystemException {
+ return 0;
+ }
+
+ public boolean enlistResource(XAResource xaResource) throws RollbackException, IllegalStateException, SystemException {
+ return false;
+ }
+
+ public boolean delistResource(XAResource xaResource, int i) throws IllegalStateException, SystemException {
+ return false;
+ }
+
+ public void registerSynchronization(Synchronization synchronization) throws RollbackException, IllegalStateException, SystemException {
+ }
+}
Added: labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/DummyTransactionManager.java
===================================================================
--- labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/DummyTransactionManager.java (rev 0)
+++ labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/DummyTransactionManager.java 2011-06-08 18:59:25 UTC (rev 37075)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and/or its affiliates,
+ * and individual contributors as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2011,
+ * @author JBoss, by Red Hat.
+ */
+package org.narayana.tools.perf;
+
+import javax.transaction.*;
+
+public class DummyTransactionManager implements TransactionManager {
+ public void begin() throws NotSupportedException, SystemException {
+ }
+
+ public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException {
+ }
+
+ public void rollback() throws IllegalStateException, SecurityException, SystemException {
+ }
+
+ public void setRollbackOnly() throws IllegalStateException, SystemException {
+ }
+
+ public int getStatus() throws SystemException {
+ return 0;
+ }
+
+ public Transaction getTransaction() throws SystemException {
+ return null;
+ }
+
+ public void setTransactionTimeout(int i) throws SystemException {
+ }
+
+ public Transaction suspend() throws SystemException {
+ return null;
+ }
+
+ public void resume(Transaction transaction) throws InvalidTransactionException, IllegalStateException, SystemException {
+ }
+}
Added: labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/JotmWorkerTask.java
===================================================================
--- labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/JotmWorkerTask.java (rev 0)
+++ labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/JotmWorkerTask.java 2011-06-08 18:59:25 UTC (rev 37075)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and/or its affiliates,
+ * and individual contributors as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2011,
+ * @author JBoss, by Red Hat.
+ */
+package org.narayana.tools.perf;
+
+import javax.naming.NamingException;
+import javax.transaction.TransactionManager;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class JotmWorkerTask extends WorkerTask {
+ protected JotmWorkerTask(CyclicBarrier cyclicBarrier, AtomicInteger count, int batch_size) {
+ super(cyclicBarrier, count, batch_size);
+ try {
+ jotm = new org.objectweb.jotm.Jotm(true, false);
+ } catch (NamingException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ @Override
+ protected void fini() {
+ super.fini();
+ org.objectweb.jotm.TimerManager.stop();
+ if (jotm != null)
+ jotm.stop();
+ jotm = null;
+ }
+
+ @Override
+ protected TransactionManager getTransactionManager() {
+ return jotm.getTransactionManager();
+ }
+
+ private org.objectweb.jotm.Jotm jotm;
+}
Added: labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/NarayanaWorkerTask.java
===================================================================
--- labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/NarayanaWorkerTask.java (rev 0)
+++ labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/NarayanaWorkerTask.java 2011-06-08 18:59:25 UTC (rev 37075)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and/or its affiliates,
+ * and individual contributors as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2011,
+ * @author JBoss, by Red Hat.
+ */
+package org.narayana.tools.perf;
+
+import com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean;
+import com.arjuna.ats.arjuna.objectstore.StoreManager;
+import com.arjuna.ats.internal.arjuna.objectstore.hornetq.HornetqJournalEnvironmentBean;
+import com.arjuna.common.internal.util.propertyservice.BeanPopulator;
+
+import javax.transaction.TransactionManager;
+import java.io.File;
+import java.io.IOException;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class NarayanaWorkerTask extends WorkerTask {
+ protected NarayanaWorkerTask(CyclicBarrier cyclicBarrier, AtomicInteger count, int batch_size) {
+ super(cyclicBarrier, count, batch_size);
+ }
+
+ protected void init() {
+ String objectStoreBaseDirBaseName = System.getProperty("ObjectStoreBaseDir", "logs");
+ File directory = new File(objectStoreBaseDirBaseName);
+ File hornetqStoreDir = new File(directory, "HornetQStore");
+
+ try {
+ BeanPopulator.getDefaultInstance(HornetqJournalEnvironmentBean.class)
+ .setStoreDir(hornetqStoreDir.getCanonicalPath());
+ } catch (IOException e) {
+ throw new IllegalArgumentException(e);
+ }
+ BeanPopulator.getDefaultInstance(ObjectStoreEnvironmentBean.class)
+ .setObjectStoreType("com.arjuna.ats.internal.arjuna.objectstore.hornetq.HornetqObjectStoreAdaptor");
+ }
+
+ @Override
+ protected void fini() {
+ super.fini();
+ StoreManager.shutdown();
+ }
+
+ @Override
+ protected TransactionManager getTransactionManager() {
+ return com.arjuna.ats.jta.TransactionManager.transactionManager();
+ }
+}
Added: labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/TxnPerformanceTest.java
===================================================================
--- labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/TxnPerformanceTest.java (rev 0)
+++ labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/TxnPerformanceTest.java 2011-06-08 18:59:25 UTC (rev 37075)
@@ -0,0 +1,176 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and/or its affiliates,
+ * and individual contributors as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2011,
+ * @author JBoss, by Red Hat.
+ */
+package org.narayana.tools.perf;
+
+import java.lang.reflect.Constructor;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import java.util.Date;
+
+public class TxnPerformanceTest
+{
+ private static final String syntax = "-p <product> | -i <iterations> -t <threads>: ";
+
+ public static void main(String[] args) throws Exception {
+ int iterations = 200000;
+ int threads = 100;
+ String opt;
+ String products[] = {
+ "org.narayana.tools.perf.BitronixWorkerTask",
+ "org.narayana.tools.perf.AtomikosWorkerTask",
+ "org.narayana.tools.perf.JotmWorkerTask",
+ "org.narayana.tools.perf.NarayanaWorkerTask",
+ };
+
+ if (args.length != 0) {
+ String[] opts = args[0].trim().split("\\s+");
+/*
+ for (int i = 0; i < opts.length; i++) {
+ if (opts[i].startsWith("-")) {
+ opt = opts[i++];
+
+ if (i < opts.length) {
+ if ("-p".equals(opt))
+ products = opts[i].split(",");
+ else if ("-i".equals(opt))
+ iterations = Integer.valueOf(opts[i]);
+ else if ("-t".equals(opt))
+ threads = Integer.valueOf(opts[i]);
+ else
+ fatal("Syntax error: ");
+ } else {
+ fatal("Syntax error: ");
+ }
+ } else {
+ fatal("Syntax error: ");
+ }
+ }*/
+
+ for (int i = 0; i < opts.length; i++) {
+ if (opts[i].startsWith("-")) {
+ opt = opts[i++];
+
+ if (i < opts.length) {
+ if ("-p".equals(opt)) {
+ products = opts[i].split(",");
+ continue;
+ } else if ("-i".equals(opt)) {
+ iterations = Integer.valueOf(opts[i]);
+ continue;
+ } else if ("-t".equals(opt)) {
+ threads = Integer.valueOf(opts[i]);
+ continue;
+ }
+ }
+ }
+
+ System.out.println("Syntax error: " + syntax);
+ System.exit(1);
+ }
+ }
+
+ TaskResult results[] = new TaskResult[products.length];
+
+ System.out.println(iterations+ " transactions, " + threads + " threads");
+
+ for (int i = 0; i < products.length; i++)
+ results[i] = testLoop(products[i], iterations, threads);
+
+ for (int i = 0; i < products.length; i++)
+ System.out.println(results[i].toString());
+ }
+
+ private static WorkerTask newWorker(
+ String className, CyclicBarrier cyclicBarrier, AtomicInteger count, int batch_size) throws Exception {
+
+ Class classDef = Class.forName(className);
+ Constructor constructor = classDef.getDeclaredConstructor(
+ new Class[]{CyclicBarrier.class, AtomicInteger.class, int.class});
+ Object[] args = {cyclicBarrier, count, batch_size};
+
+ return (WorkerTask) constructor.newInstance(args);
+ }
+
+ private static TaskResult testLoop(String workerClassName, int iterations, int threads) throws Exception {
+ int NUM_TX = iterations;
+ int BATCH_SIZE = 100;
+ AtomicInteger count = new AtomicInteger(NUM_TX/BATCH_SIZE);
+ final int nThreads = threads;
+ CyclicBarrier cyclicBarrier = new CyclicBarrier(nThreads +1); // workers + self
+ ExecutorService executorService = Executors.newCachedThreadPool();
+ WorkerTask task = TxnPerformanceTest.newWorker(workerClassName, cyclicBarrier, count, BATCH_SIZE);
+
+ task.init();
+
+ for(int i = 0; i < nThreads; i++) {
+ executorService.execute(task);
+ }
+
+ System.out.print(new Date() + " " + workerClassName);
+ long start = System.nanoTime();
+ cyclicBarrier.await();
+ cyclicBarrier.await();
+
+ long end = System.nanoTime();
+ long duration_ms = (end - start) / 1000000L;
+
+ executorService.shutdown();
+ task.fini();
+
+ return new TaskResult(workerClassName, iterations, threads, duration_ms);
+ }
+
+ static class TaskResult {
+ String product;
+ long duration_ms;
+ int iterations;
+ int threads;
+
+ TaskResult(String product, int iterations, int threads, long duration_ms) {
+ this.product = product;
+ this.iterations = iterations;
+ this.threads = threads;
+ this.duration_ms = duration_ms;
+ }
+
+ public StringBuilder toString(StringBuilder sb) {
+ sb.append(product);
+ sb.append("\n total time (ms): ").append(duration_ms);
+ sb.append("\naverage time (ms): ").append((1.0*duration_ms)/iterations);
+ sb.append("\ntx / second: ").append((1000.0/((1.0*duration_ms)/iterations)));
+ sb.append('\n').append(threads).append(" threads").append('\n');
+
+ return sb;
+ }
+
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append(product).append(": ")
+ .append((1000.0/((1.0*duration_ms)/iterations))).append(" tx / second");
+
+ return sb.toString();
+ }
+ }
+}
Added: labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/WorkerTask.java
===================================================================
--- labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/WorkerTask.java (rev 0)
+++ labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/WorkerTask.java 2011-06-08 18:59:25 UTC (rev 37075)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc. and/or its affiliates,
+ * and individual contributors as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2011,
+ * @author JBoss, by Red Hat.
+ */
+package org.narayana.tools.perf;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.atomic.AtomicInteger;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import javax.transaction.xa.XAResource;
+
+public abstract class WorkerTask implements Runnable {
+ protected CyclicBarrier cyclicBarrier;
+ protected AtomicInteger count;
+ protected AtomicInteger rid = new AtomicInteger(0);
+ protected int batch_size = 0;
+ protected Map<String, XAResource> resources = new HashMap<String, XAResource> ();
+
+ protected WorkerTask(CyclicBarrier cyclicBarrier, AtomicInteger count, int batch_size) {
+ String name = Thread.currentThread().getName() + rid.incrementAndGet();
+ this.cyclicBarrier = cyclicBarrier;
+ this.count = count;
+ this.batch_size = batch_size;
+
+ resources.put(name, new XAResourceImpl(name, 0));
+ name = Thread.currentThread().getName() + rid.incrementAndGet();
+ resources.put(name, new XAResourceImpl(name, 0));
+ }
+
+ protected void init() {
+ }
+
+ protected void fini() {
+ }
+
+ protected void registerResource(String name, XAResource res) {
+
+ }
+
+ protected void unregisterResource(String name, XAResource res) {
+
+ }
+
+ protected void registerResources() {
+ for (Map.Entry<String, XAResource> e : resources.entrySet())
+ registerResource(e.getKey(), e.getValue());
+ }
+
+ protected void unregisterResources() {
+ for (Map.Entry<String, XAResource> e : resources.entrySet())
+ unregisterResource(e.getKey(), e.getValue());
+ }
+
+ protected void doTx(TransactionManager tm) throws Exception {
+ tm.begin();
+ Transaction t = tm.getTransaction();
+
+ for (XAResource xar : resources.values())
+ t.enlistResource(xar);
+
+ tm.commit();
+ }
+
+ protected abstract TransactionManager getTransactionManager();
+// return new DummyTransactionManager();
+
+ public void run() {
+ TransactionManager tm = getTransactionManager();
+
+ if (tm == null)
+ throw new RuntimeException("No suitable transaction manager for " + this.getClass().getName());
+
+ try {
+ registerResources();
+
+ cyclicBarrier.await();
+
+ while(count.decrementAndGet() >= 0) {
+ for(int i = 0; i < batch_size; i++)
+ doTx(tm);
+ }
+
+ cyclicBarrier.await();
+ } catch(Exception e) {
+ e.printStackTrace();
+ } finally {
+ unregisterResources();
+ }
+ }
+}
Added: labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/XAResourceImpl.java
===================================================================
--- labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/XAResourceImpl.java (rev 0)
+++ labs/jbosstm/trunk/qa/tests/product/src/org/narayana/tools/perf/XAResourceImpl.java 2011-06-08 18:59:25 UTC (rev 37075)
@@ -0,0 +1,130 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates,
+ * and individual contributors as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2010,
+ * @author JBoss, by Red Hat.
+ */
+package org.narayana.tools.perf;
+
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+import javax.transaction.xa.XAException;
+import java.io.Serializable;
+
+/**
+ * Dummy implementation of the XAResource interface for test purposes.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com), 2010-03
+ */
+public class XAResourceImpl implements XAResource, Serializable {
+ static final long serialVersionUID = 1L;
+
+ private String name;
+ private int fault;
+ private int txTimeout;
+ private Xid currentXid;
+
+ public XAResourceImpl(String name, int fault) {
+ this.name = name;
+ this.fault = fault;
+ }
+
+ public void commit(Xid xid, boolean b) throws XAException {
+ //System.out.println("XAResourceImpl.commit(Xid="+xid+", b="+b+")");
+
+/*
+ if(!xid.equals(currentXid)) {
+ System.out.println("XAResourceImpl.commit - wrong Xid!");
+ }
+*/
+
+ currentXid = null;
+
+// System.out.println("XAResourceImpl.commit: " + xid + " FAULT: " + fault);
+ switch (fault) {
+ case 1:
+ fault = 0;
+ throw new XAException(XAException.XA_RBROLLBACK);
+ case 2:
+ break;
+ case 3:
+ break;
+ default:
+ break;
+ }
+ }
+
+ public void end(Xid xid, int i) throws XAException {
+ //System.out.println("XAResourceImpl.end(Xid="+xid+", b="+i+")");
+ }
+
+ public void forget(Xid xid) throws XAException {
+ //System.out.println("XAResourceImpl.forget(Xid="+xid+")");
+ if(!xid.equals(currentXid)) {
+ System.out.println("XAResourceImpl.forget - wrong Xid!");
+ }
+ currentXid = null;
+ }
+
+ public int getTransactionTimeout() throws XAException {
+// System.out.println("XAResourceImpl.getTransactionTimeout() [returning "+txTimeout+"]");
+ return txTimeout;
+ }
+
+ public boolean isSameRM(XAResource xaResource) throws XAException {
+// System.out.println("XAResourceImpl.isSameRM(xaResource="+xaResource+")");
+ return false;
+ }
+
+ public int prepare(Xid xid) throws XAException {
+ //System.out.println("XAResourceImpl.prepare(Xid="+xid+")");
+ return XAResource.XA_OK;
+ }
+
+ public Xid[] recover(int i) throws XAException {
+// System.out.println("XAResourceImpl.recover(i="+i+")");
+ return new Xid[0];
+ }
+ public void rollback(Xid xid) throws XAException {
+// System.out.println("XAResourceImpl.rollback(Xid="+xid+")");
+/* if(!xid.equals(currentXid)) {
+ System.out.println("XAResourceImpl.rollback - wrong Xid!");
+ }*/
+ currentXid = null;
+ }
+
+ public boolean setTransactionTimeout(int i) throws XAException {
+ //System.out.println("XAResourceImpl.setTransactionTimeout(i="+i+")");
+ txTimeout= i;
+ return true;
+ }
+
+ public void start(Xid xid, int i) throws XAException {
+ //System.out.println("XAResourceImpl.start(Xid="+xid+", i="+i+")");
+/* if(currentXid != null) {
+ System.out.println("XAResourceImpl.start - wrong Xid!");
+ }*/
+ currentXid = xid;
+ }
+
+ public String toString() {
+ return name;
+ }
+}
+
+
+
More information about the jboss-svn-commits
mailing list