[jboss-cvs] JBossAS SVN: r109055 - in projects/jboss-jca/branches/performance: pojos and 9 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Nov 1 13:33:00 EDT 2010


Author: jesper.pedersen
Date: 2010-11-01 13:32:59 -0400 (Mon, 01 Nov 2010)
New Revision: 109055

Added:
   projects/jboss-jca/branches/performance/pojos/
   projects/jboss-jca/branches/performance/pojos/build.xml
   projects/jboss-jca/branches/performance/pojos/src/
   projects/jboss-jca/branches/performance/pojos/src/main/
   projects/jboss-jca/branches/performance/pojos/src/main/java/
   projects/jboss-jca/branches/performance/pojos/src/main/java/org/
   projects/jboss-jca/branches/performance/pojos/src/main/java/org/jboss/
   projects/jboss-jca/branches/performance/pojos/src/main/java/org/jboss/jca/
   projects/jboss-jca/branches/performance/pojos/src/main/java/org/jboss/jca/performance/
   projects/jboss-jca/branches/performance/pojos/src/main/java/org/jboss/jca/performance/pojos/
   projects/jboss-jca/branches/performance/pojos/src/main/java/org/jboss/jca/performance/pojos/DatabaseTester.java
   projects/jboss-jca/branches/performance/pojos/src/main/resources/
   projects/jboss-jca/branches/performance/pojos/src/main/resources/dbtester.xml
Modified:
   projects/jboss-jca/branches/performance/build.xml
   projects/jboss-jca/branches/performance/ivy.xml
Log:
Added simple database POJO tester

Modified: projects/jboss-jca/branches/performance/build.xml
===================================================================
--- projects/jboss-jca/branches/performance/build.xml	2010-11-01 17:32:38 UTC (rev 109054)
+++ projects/jboss-jca/branches/performance/build.xml	2010-11-01 17:32:59 UTC (rev 109055)
@@ -161,6 +161,7 @@
     <ant dir="rars" inheritRefs="true" target="jars"/>
     <ant dir="extensions" inheritRefs="true" target="jars"/>
     <ant dir="apps" inheritRefs="true" target="jars"/>
+    <ant dir="pojos" inheritRefs="true" target="jars"/>
   </target>
   
   <!-- ================================= 
@@ -168,6 +169,7 @@
        ================================= -->
   <target name="docs" depends="jars">
     <ant dir="rars" inheritRefs="true" target="docs"/>
+    <ant dir="pojos" inheritRefs="true" target="docs"/>
   </target>
 
   <!-- ================================= 

Modified: projects/jboss-jca/branches/performance/ivy.xml
===================================================================
--- projects/jboss-jca/branches/performance/ivy.xml	2010-11-01 17:32:38 UTC (rev 109054)
+++ projects/jboss-jca/branches/performance/ivy.xml	2010-11-01 17:32:59 UTC (rev 109055)
@@ -36,17 +36,18 @@
   </configurations>
 
   <dependencies>
-    <dependency org="org.jboss.javaee" name="jboss-jca-api" rev="${version.jboss.jca.api}" conf="common"/>
-    <dependency org="org.jboss.javaee" name="jboss-ejb-api" rev="${version.jboss.ejb.api}" conf="common"/>
-    <dependency org="org.jboss.stdio" name="jboss-stdio" rev="${version.jboss.stdio}" conf="common"/>
-    <dependency org="log4j" name="log4j" rev="${version.log4j}" conf="common"/>
-    <dependency org="org.jboss.logging" name="jboss-logging-log4j" rev="${version.jboss.logging}" conf="common"/>
     <dependency org="com.github.fungal" name="fungal" rev="${version.fungal}" conf="sjc"/>
     <dependency org="com.github.fungal" name="fungal-cli" rev="${version.fungal}" conf="sjc"/>
     <dependency org="jboss" name="jboss-serialization" rev="${version.jboss.serialization}" conf="sjc"/>
+    <dependency org="log4j" name="log4j" rev="${version.log4j}" conf="common"/>
+    <dependency org="org.jboss.javaee" name="jboss-ejb-api" rev="${version.jboss.ejb.api}" conf="common"/>
+    <dependency org="org.jboss.javaee" name="jboss-jca-api" rev="${version.jboss.jca.api}" conf="common"/>
+    <dependency org="org.jboss.javaee" name="jboss-transaction-api" rev="${version.jboss.jboss-transaction-api}" conf="common"/>
+    <dependency org="org.jboss.jbossas" name="jboss-server-manager" rev="${version.jboss.server.manager}" conf="jbossas"/>
+    <dependency org="org.jboss.logging" name="jboss-logging-log4j" rev="${version.jboss.logging}" conf="common"/>
     <dependency org="org.jboss.remoting" name="jboss-remoting" rev="${version.jboss.remoting}" conf="sjc"/>
+    <dependency org="org.jboss.stdio" name="jboss-stdio" rev="${version.jboss.stdio}" conf="common"/>
     <dependency org="org.jboss.test" name="jboss-test" rev="${version.jboss.test}" conf="jbossas"/>
-    <dependency org="org.jboss.jbossas" name="jboss-server-manager" rev="${version.jboss.server.manager}" conf="jbossas"/>
   </dependencies>
 
 </ivy-module>

Added: projects/jboss-jca/branches/performance/pojos/build.xml
===================================================================
--- projects/jboss-jca/branches/performance/pojos/build.xml	                        (rev 0)
+++ projects/jboss-jca/branches/performance/pojos/build.xml	2010-11-01 17:32:59 UTC (rev 109055)
@@ -0,0 +1,98 @@
+<!--
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+-->
+<project name="ironjacamar-performance-pojos" 
+         default="jars" 
+         xmlns:ivy="antlib:org.apache.ivy.ant">
+
+  <!-- ================================= 
+       Properties              
+       ================================= -->
+  <property name="build.pojos.dir" value="${build.dir}/pojos" />
+
+  <!-- ================================= 
+       Target: compile
+       ================================= -->
+  <target name="compile">
+    <mkdir dir="${build.pojos.dir}" />
+    <mkdir dir="${build.pojos.dir}/impl" />
+
+    <javac srcdir="src/main"
+           destdir="${build.pojos.dir}/impl"
+           classpathref="lib.path.id"
+           debug="${javac.debug}"
+           deprecation="${javac.deprecation}"
+           optimize="${javac.optimize}">
+      <compilerarg value="-Xlint"/>
+    </javac> 
+  </target>
+
+  <!-- ================================= 
+       Target: jars 
+       ================================= -->
+  <target name="jars" depends="compile">
+    <mkdir dir="${build.pojos.dir}/jars" />
+
+    <copy todir="${build.pojos.dir}/jars">
+      <fileset dir="src/main/resources" includes="**/*"/>
+    </copy>
+
+    <copy todir="${build.pojos.dir}/jars">
+      <fileset dir="${build.pojos.dir}/impl"
+               includes="**"/>
+    </copy>
+
+    <jar destfile="${target.dir}/ironjacamar-performance-pojos.jar"
+         basedir="${build.pojos.dir}/jars">
+      <manifest>
+        <attribute name="Implementation-Title" value="IronJacamar Performance (POJOs)"/>
+        <attribute name="Implementation-Vendor" value="The IronJacamar project (http://www.jboss.org/ironjacamar)"/>
+        <attribute name="Implementation-Vendor-Id" value="org.jboss"/>
+      </manifest>
+    </jar>
+  </target>
+
+  <!-- ================================= 
+       Target: docs
+       ================================= -->
+  <target name="docs" depends="compile">
+    <mkdir dir="${target.dir}/docs/performance"/>
+    <mkdir dir="${target.dir}/docs/performance/pojos"/>
+    <javadoc packagenames="org.*"
+             sourcepath="src/main/java"
+             destdir="${target.dir}/docs/performance/pojos"
+             author="true"
+             version="true"
+             windowtitle="IronJacamar Performance POJOs"
+             doctitle="IronJacamar Performance POJOs"
+             use="true"
+             additionalparam="-author -version"
+             classpath="${build.pojos.dir}/impl"
+             classpathref="lib.path.id"
+             bottom="Copyright &#169; 2010 Red Hat Middleware LLC (http://www.jboss.com/)">
+      <link offline="true" href="http://java.sun.com/j2se/5/docs/api/" packagelistLoc="${java.home}/../docs/api"/>
+    </javadoc>
+    <copy todir="${target.dir}/docs/performance/pojos" overwrite="true">
+      <fileset dir="${tools.dir}/api"/>
+    </copy>
+  </target>
+
+</project>

Added: projects/jboss-jca/branches/performance/pojos/src/main/java/org/jboss/jca/performance/pojos/DatabaseTester.java
===================================================================
--- projects/jboss-jca/branches/performance/pojos/src/main/java/org/jboss/jca/performance/pojos/DatabaseTester.java	                        (rev 0)
+++ projects/jboss-jca/branches/performance/pojos/src/main/java/org/jboss/jca/performance/pojos/DatabaseTester.java	2010-11-01 17:32:59 UTC (rev 109055)
@@ -0,0 +1,277 @@
+ /*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2010, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY 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 along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.jca.performance.pojos;
+
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.List;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.SynchronousQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.logging.Logger;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.sql.DataSource;
+import javax.transaction.UserTransaction;
+
+/**
+ * A test application for database access
+ * 
+ * @author <a href="jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class DatabaseTester
+{
+   /** The logger */
+   private static Logger log = Logger.getLogger(DatabaseTester.class.getName());
+
+   /** User transaction JNDI name */
+   private static final String JNDI_USER_TRANSACTION = "java:/UserTransaction";
+
+   /** Multithreaded execution */
+   private boolean multiThreaded;
+
+   /** The JNDI for the datasource */
+   private String dbJndiName;
+
+   /** Iterations */
+   private int iterations;
+
+   /** The list of SQL statements to execute */
+   private List<String> sqls;
+
+   /**
+    * Constructor
+    */
+   public DatabaseTester()
+   {
+      this.multiThreaded = false;
+      this.dbJndiName = null;
+      this.iterations = 1;
+      this.sqls = null;
+   }
+
+   /**
+    * Set the multithreaded execution mode
+    * @param v The value
+    */
+   public void setMultiThreaded(boolean v)
+   {
+      this.multiThreaded = v;
+   }
+
+   /**
+    * Set the datasource JNDI name
+    * @param v The value
+    */
+   public void setDbJndiName(String v)
+   {
+      this.dbJndiName = v;
+   }
+
+   /**
+    * Set the number of iterations
+    * @param v The value
+    */
+   public void setIterations(int v)
+   {
+      this.iterations = v;
+   }
+
+   /**
+    * Set the SQL statements
+    * @param v The value
+    */
+   public void setSqls(List<String> v)
+   {
+      this.sqls = v;
+   }
+
+   /**
+    * Start
+    */
+   public void start() throws Throwable
+   {
+      if (dbJndiName == null || dbJndiName.trim().equals(""))
+         throw new IllegalArgumentException("No datasource JNDI name defined");
+
+      long start = System.currentTimeMillis();
+
+      if (multiThreaded)
+      {
+         try
+         {
+            CountDownLatch cdl = new CountDownLatch(iterations);
+
+            BlockingQueue<Runnable> threadPoolQueue = new SynchronousQueue<Runnable>(true);
+            ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors(), Integer.MAX_VALUE,
+                                                                           60, TimeUnit.SECONDS,
+                                                                           threadPoolQueue);
+
+            threadPoolExecutor.allowCoreThreadTimeOut(true);
+            threadPoolExecutor.prestartAllCoreThreads();
+
+            for (int counter = 0; counter < iterations; counter++)
+            {
+               Test t = new Test(dbJndiName, sqls, cdl);
+               threadPoolExecutor.submit(t);
+            }
+
+            cdl.await();
+         }
+         catch (Throwable t)
+         {
+            // Ignore
+         }
+      }
+      else
+      {
+         Test t = new Test(dbJndiName, sqls);
+         for (int counter = 0; counter < iterations; counter++)
+         {
+            t.run();
+         }
+      }
+
+      log.info("Took: " + (System.currentTimeMillis() - start) + " ms");
+   }
+
+   /**
+    * Test class
+    */
+   private static class Test implements Runnable
+   {
+      private String dbJndiName;
+      private List<String> sqls;
+      private CountDownLatch cdl;
+
+      Test(String dbJndiName, List<String> sqls)
+      {
+         this(dbJndiName, sqls, null);
+      }
+
+      Test(String dbJndiName, List<String> sqls, CountDownLatch cdl)
+      {
+         this.dbJndiName = dbJndiName;
+         this.sqls = sqls;
+         this.cdl = cdl;
+      }
+
+      public void run()
+      {
+         if (dbJndiName == null || dbJndiName.trim().equals(""))
+            throw new IllegalArgumentException("No datasource JNDI name defined");
+
+         Context context = null;
+         UserTransaction userTransaction = null;
+         DataSource dataSource = null;
+         Connection connection = null;
+
+         try
+         {
+            context = new InitialContext();
+
+            userTransaction = (UserTransaction)context.lookup(JNDI_USER_TRANSACTION);
+            userTransaction.begin();
+
+            dataSource = (DataSource)context.lookup(dbJndiName);
+            connection = dataSource.getConnection();
+
+            PreparedStatement ps = null;
+            ResultSet resultSet = null;
+
+            if (sqls != null)
+            {
+               for (String sqlStatement : sqls)
+               {
+                  log.fine("Executing: " + sqlStatement);
+
+                  try
+                  {
+                     ps = connection.prepareStatement(sqlStatement);
+                     resultSet = ps.executeQuery();
+                  }
+                  finally
+                  {
+                     try
+                     {
+                        if (resultSet != null)
+                           resultSet.close();
+                     }
+                     catch (SQLException se) 
+                     {
+                        // Ignore
+                     }
+                     try
+                     {
+                        if (ps != null)
+                           ps.close();
+                     }
+                     catch (SQLException se)
+                     {
+                        // Ignore
+                     }
+                  }
+               }
+            }
+            
+            userTransaction.commit();
+
+            context.close();
+         }
+         catch (Throwable t)
+         {
+            try
+            {
+               if (userTransaction != null)
+                  userTransaction.rollback();
+            }
+            catch (Throwable inner)
+            {
+               // Ignore
+            }
+
+            log.severe(t.getMessage());
+         }
+         finally
+         {
+            try
+            {
+               if (connection != null)
+                  connection.close();
+            }
+            catch (SQLException se)
+            {
+               // Ignore
+            }
+
+            if (cdl != null)
+               cdl.countDown();
+         }
+      }
+   }
+}

Added: projects/jboss-jca/branches/performance/pojos/src/main/resources/dbtester.xml
===================================================================
--- projects/jboss-jca/branches/performance/pojos/src/main/resources/dbtester.xml	                        (rev 0)
+++ projects/jboss-jca/branches/performance/pojos/src/main/resources/dbtester.xml	2010-11-01 17:32:59 UTC (rev 109055)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment>
+
+  <!-- Datasource tester -->
+  <bean name="DatabaseTester" 
+        class="org.jboss.jca.performance.pojos.DatabaseTester">
+    <property name="MultiThreaded">true</property>
+    <property name="DbJndiName">java:/H2XADS</property>
+    <property name="Iterations">1000</property>
+    <property name="Sqls">
+      <list elementClass="java.lang.String">
+        <value>SELECT 1</value>
+      </list>
+    </property>
+  </bean>
+
+</deployment>



More information about the jboss-cvs-commits mailing list