[jboss-cvs] JBossAS SVN: r111948 - in projects/jboss-jca/branches/performance: faban/benchmarks/cli-noop-jca-benchmark/deploy and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Aug 5 13:15:49 EDT 2011


Author: whitingjr
Date: 2011-08-05 13:15:49 -0400 (Fri, 05 Aug 2011)
New Revision: 111948

Modified:
   projects/jboss-jca/branches/performance/doc/perfguide/en-US/modules/benchmark.xml
   projects/jboss-jca/branches/performance/faban/benchmarks/cli-noop-jca-benchmark/deploy/config.xhtml
   projects/jboss-jca/branches/performance/faban/benchmarks/cli-noop-jca-benchmark/deploy/run.xml
   projects/jboss-jca/branches/performance/faban/src/main/java/org/jboss/jca/perf/benchmark/cli/noop/CLINoOpBenchmark.java
   projects/jboss-jca/branches/performance/faban/src/main/java/org/jboss/jca/perf/benchmark/cli/noop/CLINoOpDriver.java
Log:
Add completed implementation of NoOp benchmark. Documentation updated with Faban information.

Modified: projects/jboss-jca/branches/performance/doc/perfguide/en-US/modules/benchmark.xml
===================================================================
--- projects/jboss-jca/branches/performance/doc/perfguide/en-US/modules/benchmark.xml	2011-08-05 16:56:44 UTC (rev 111947)
+++ projects/jboss-jca/branches/performance/doc/perfguide/en-US/modules/benchmark.xml	2011-08-05 17:15:49 UTC (rev 111948)
@@ -18,49 +18,82 @@
 ant benchmark-report-summary
      </programlisting>
    </section>
-   <section id="jmeter">
-   <title>IronJacamar and JMeter</title>
-   <para>Initial setup</para>
-   <para>JMeter has been setup to benchmark the IronJacama server for HTTP and JDBC loads.</para>
-   <para>Before using JMeter to benchmark run the following Ant targets only once. Execute these in the root directory of the checked out performance branch.</para>
-   <programlisting>
-ant download-servers
-ant benchmark</programlisting>
-   <para>Test Plans</para>
-   <para>With the JMeter integration comes several Test Plans. Test Plans are JMeter test configurations containing the sequence of requests to create the desired load. The default test plan is the first listed below and will be loaded when JMeter is started. To load one of the other test plans select "File - Open" from the JMeter menu.</para>
-   <programlisting>src/main/resources/jmeter/Http-Test.jmx
-src/main/resources/jmeter/Direct-JDBC.jmx</programlisting>
-   </section>
    
-   <para>The number of concurrent threads executing the requests can be configured in JMeter. See the <ulink url="http://jakarta.apache.org/jmeter/usermanual/index.html">JMeter User Manual</ulink> for step-by-step instructions.</para>
+   <section id="faban">
+   <title id="ij and faban">IronJacamar and Faban.</title>
    
-   <para>Monitoring</para>
-   <para>This test plan monitors the transaction rate.</para>
-   <programlisting>src/main/resources/jmeter/Monitor-Test-Plan.jmx</programlisting>
+   <section>
+   <subtitle id="faban intro">Faban introduction</subtitle>
+   <para>Faban is a flexible open source performance benchmarking and load injector. The system provides extension points to plug in custom benchmarks and configurations to manage services necessary for benchmark runs.</para>
+   <para>The role for Faban in the IronJacamar project is to manage running a benchmark and collection of results. Benchmarks are provided for evaluating the JCA container.</para>
+   </section>
    
-   <para>The Monitor Test Plan provides runtime statistics for the rate of transactions completed per second. It uses JMX to gather the metrics. To open the monitoring test plan execute the following command.</para>
-   <programlisting>ant jmeter.monitoring</programlisting>
+   <section>
+   <subtitle id="faban setup">Initial Faban setup.</subtitle>
+   <para>Download and install the <ulink url="http://www.faban.org/">Faban harness</ulink> following the instructions in the <ulink url="http://www.faban.org/1.0/docs/toc.html#Faban_Harness_Users_Guide_">User Guide</ulink> for instructions.
+      <tip><title>Firewall</title> If the machines used are running a firewall you will need to build a modified version of Faban to use specific ports. The patched version is available at GitHub. You will need to change the firewall on each machine to accept connections on port 9982 in combination with using the version of Faban software based including software changes in this commit. <ulink url="https://github.com/whitingjr/faban/commit/d7e4d18f5b528710bab94e02dcd3aa3331ddd11c"></ulink></tip>
+   </para>
+   </section>
    
-   <para>Use the Monitor test plan alongside one of the other plans. You will need to configure the JAVA_HOME environment property. This needs setting to the home directory of a Java Development Kit. The rmiregistry service is started to expose the MBean to JMX clients (JMeter).</para>
-
-   <para>Startup order</para>
-   <para>To use monitoring the sequence of starting each component is important.</para>
-   <para>To monitor Direct-JDBC.jmx test plan</para>
-   <programlisting>ant database
-ant jmeter.monitoring
-ant jmeter
-   </programlisting>
-<para>To monitor the Http-Test.jmx test plan </para>
-   <programlisting>ant server
-ant jmeter.monitoring
-ant jmeter
-   </programlisting>
-
-   <para>Monitoring of either test plan is exclusive. You will need to shutdown the server or database before starting the other test plan. The following Ant targets will shutdown the respective jvm process.</para>
-   <programlisting>ant shutdown-database
-ant shutdown-server</programlisting>
+   <section>
+   <subtitle id="benchmark source">Sources for IronJacamar Benchmarks.</subtitle>
+   <para>Provided benchmarks are located in the performance branch in source control.</para>
+   <programlisting>performance/faban/benchmarks</programlisting>
+   </section>
    
-   <para>JMeter overhead</para>
-   <para>Note, the overhead of running JMeter and the Graph Results can be reduced. Try un-selecting the check boxes labeled 'Average', 'Median', 'Deviation' and 'Threshold' leaving the 'Data' checkbox selected.</para>
-   
+   <section>
+   <subtitle id="benchmark list">List of Benchmarks.</subtitle>
+   <para>The provided benchmarks create a workload directed at a system under test. The IronJacamar provides two systems. The IronJacamar JCA container and a Perfenv system for performance testing. The benchmarks have been written to operate with one of these two systems. The System dependency column indicates which is required.</para>
+   <para>  
+   <table>
+     <title>Benchmarks list</title>
+     <tgroup cols="6">
+     <colspec colname="c1" colwidth="1*"/>
+     <colspec colname="c2" colwidth="1*"/>
+     <colspec colname="c3" colwidth="1*"/>
+     <colspec colname="c4" colwidth="1*"/>
+     <colspec colname="c5" colwidth="1*"/>
+     <colspec colname="c6" colwidth="1*"/>
+     <thead>
+        <row>
+           <entry>Name</entry>
+           <entry>Protocol</entry>
+           <entry>System dependency</entry>
+           <entry>Datasource impl</entry>
+           <entry>Transactions impl</entry>
+           <entry>Comments</entry>
+        </row>
+       </thead>
+       <tbody>
+          <row>
+             <entry>HTTP Benchmark</entry>
+             <entry>HTTP</entry>
+             <entry>IronJacamar</entry>
+             <entry>default</entry>
+             <entry>default</entry>
+             <entry>This calls a servlet which performs a JTA transaction.</entry>
+          </row>
+          <row>
+             <entry>CLI NoOp</entry>
+             <entry>CLI - socket</entry>
+             <entry>Perfenv</entry>
+             <entry>NoOp</entry>
+             <entry>NoOp</entry>
+             <entry>This calls a Test class with a NoOp implementation for the datasource and transaction manager.</entry>
+          </row>
+          <row>
+             <entry>CLI Transaction</entry>
+             <entry>CLI - socket</entry>
+             <entry>Perfenv</entry>
+             <entry>default</entry>
+             <entry>default</entry>
+             <entry>Calls test class which performs a JTA transaction.</entry>
+          </row>
+       </tbody>
+       </tgroup>
+    </table>
+    </para>
+    <para>Each benchmark will require the system to be built beforehand. The benchmark will start the service before applying load to the system then shut it down after completion.</para>
+   </section>
+   </section>
 </chapter>

Modified: projects/jboss-jca/branches/performance/faban/benchmarks/cli-noop-jca-benchmark/deploy/config.xhtml
===================================================================
--- projects/jboss-jca/branches/performance/faban/benchmarks/cli-noop-jca-benchmark/deploy/config.xhtml	2011-08-05 16:56:44 UTC (rev 111947)
+++ projects/jboss-jca/branches/performance/faban/benchmarks/cli-noop-jca-benchmark/deploy/config.xhtml	2011-08-05 17:15:49 UTC (rev 111948)
@@ -125,6 +125,8 @@
             <xforms:bind id='bind-runConfig-driverConfig-properties' xforms:nodeset='fd:properties'>
                <xforms:bind id="bind-driver-datasourceJNDI" xforms:nodeset="fd:property[fd:name='jndiName']/fd:value"/>
                <xforms:bind id="bind-driver-fqcnTest" xforms:nodeset="fd:property[fd:name='fqcn.test']/fd:value"/>
+               <xforms:bind id="bind-driver-isMultithreaded" xforms:nodeset="fd:property[fd:name='test.multithreaded']/fd:value"/>
+               <xforms:bind id="bind-driver-testThreadCount" xforms:nodeset="fd:property[fd:name='test.thread.count']/fd:value"/>
                <xforms:bind id="bind-driver-testIterationCount" xforms:nodeset="fd:property[fd:name='test.iteration.count']/fd:value"/>
             </xforms:bind>
             
@@ -142,38 +144,26 @@
          </xforms:bind>
       </xforms:bind>
 
-      <xforms:bind id='bind-jcaServer' xforms:nodeset='jcaServer'>
-         <xforms:bind id='bind-jcaServer-hostConfig'
+      <xforms:bind id='bind-perfenvServer' xforms:nodeset='perfenvServer'>
+         <xforms:bind id='bind-perfenvServer-hostConfig'
             xforms:nodeset='fa:hostConfig'>
-            <xforms:bind id='bind-jcaServer-hostConfig-host'
+            <xforms:bind id='bind-perfenvServer-hostConfig-host'
                xforms:nodeset='fa:host'>
             </xforms:bind>
-            <xforms:bind id='bind-jcaServer-hostConfig-enabled'
+            <xforms:bind id='bind-perfenvServer-hostConfig-enabled'
                xforms:nodeset='fh:enabled'>
             </xforms:bind>
-            <xforms:bind id='bind-jcaServer-hostConfig-tools'
+            <xforms:bind id='bind-perfenvServer-hostConfig-tools'
                xforms:nodeset='fh:tools'>
             </xforms:bind>
-            <xforms:bind id='bind-jcaServer-hostConfig-managedHosts'
+            <xforms:bind id='bind-perfenvServer-hostConfig-managedHosts'
                xforms:nodeset='fh:managedHosts'>
             </xforms:bind>
-            <xforms:bind id='bind-jcaServer-hostConfig-userCommands'
+            <xforms:bind id='bind-perfenvServer-hostConfig-userCommands'
                xforms:nodeset='fh:userCommands'>
             </xforms:bind>
          </xforms:bind>
       </xforms:bind>
-
-      <xforms:bind id='bind-dbServer' xforms:nodeset='dbServer'>
-         <xforms:bind id='bind-dbServer-hostConfig'
-            xforms:nodeset='fa:hostConfig'>
-            <xforms:bind id='bind-dbServer-hostConfig-host'
-               xforms:nodeset='fa:host' />
-            <xforms:bind id='bind-dbServer-hostConfig-enabled'
-               xforms:nodeset='fh:enabled' />
-            <xforms:bind id='bind-dbServer-hostConfig-tools'
-               xforms:nodeset='fh:tools' />
-         </xforms:bind>
-      </xforms:bind>
    </xforms:bind>
 
 </xforms:model>
@@ -225,7 +215,7 @@
     <serverHome>Server Home</serverHome>
     <user>User</user>
     <password>Password</password>
-    <jcaServer>Jca Server</jcaServer>
+    <perfenvServer>Perfenv Server</perfenvServer>
     <binPath>Bin Path</binPath>
     <webContext>Web Context</webContext>
     <resourcePath>Resource Path</resourcePath>
@@ -246,6 +236,8 @@
     <datasourceJNDI>DataSource JNDI name</datasourceJNDI>
     <fqcnTest>Fully qualified class name</fqcnTest>
     <perfEnvironmentConfiguration>Perf Env</perfEnvironmentConfiguration>
+    <testMultithreaded>Is multithreaded</testMultithreaded>
+    <threadCount>Thread count</threadCount>
     <testIterationCount>Test iteration count</testIterationCount>
 </labels>
    </xforms:instance>
@@ -274,27 +266,17 @@
       </xforms:action>
    </xforms:trigger>
 
-   <xforms:trigger id='trigger-jcaServer'>
+   <xforms:trigger id='trigger-perfenvServer'>
       <xforms:label xforms:model='benchmark-labels'
-         xforms:ref='/labels/jcaServer' />
-      <xforms:action id='action-jcaServer'>
+         xforms:ref='/labels/perfenvServer' />
+      <xforms:action id='action-perfenvServer'>
          <xforms:revalidate xforms:model='benchmark-model'
-            id='revalidate-jcaServer' />
-         <xforms:toggle id='toggle-jcaServer'
-            xforms:case='case-jcaServer' />
+            id='revalidate-perfenvServer' />
+         <xforms:toggle id='toggle-perfenvServer'
+            xforms:case='case-perfenvServer' />
       </xforms:action>
    </xforms:trigger>
 
-   <xforms:trigger id='trigger-dbServer'>
-      <xforms:label xforms:model='benchmark-labels'
-         xforms:ref='/labels/dbServer' />
-      <xforms:action id='action-dbServer'>
-         <xforms:revalidate xforms:model='benchmark-model'
-            id='revalidate-dbServer' />
-         <xforms:toggle id='toggle-dbServer' xforms:case='case-dbServer' />
-      </xforms:action>
-   </xforms:trigger>
-
    <xforms:switch id="switch">
       <xforms:case id='case-jvmConfig'>
          <xforms:group id='group-jvmConfig'>
@@ -459,6 +441,14 @@
                <xforms:label xforms:model='benchmark-labels' xforms:ref='/labels/fqcnTest' />
                <xforms:help>Enter the fully qualified class name of the installed test in the PerfEnv.</xforms:help>
             </xforms:input>
+            <xforms:input id='input-driver-isMultithreaded' xforms:bind="bind-driver-isMultithreaded">
+               <xforms:label xforms:model='benchmark-labels' xforms:ref='/labels/testMultithreaded' />
+               <xforms:help>Is the test multithreaded.</xforms:help>
+            </xforms:input>
+            <xforms:input id='input-driver-testThreadCount' xforms:bind='bind-driver-testThreadCount'>
+               <xforms:label xforms:model='benchmark-labels' xforms:ref='/labels/threadCount' />
+               <xforms:help>Number of threads.</xforms:help>
+            </xforms:input>
             <xforms:input id='input-driver-testIterationCount' xforms:bind='bind-driver-testIterationCount'>
                <xforms:label xforms:model='benchmark-labels' xforms:ref='/labels/testIterationCount' />
                <xforms:help>Enter the number of times the test should be called for an invocation on the CLI.</xforms:help>
@@ -467,57 +457,36 @@
           
       </xforms:case>
 
-      <xforms:case id='case-jcaServer'>
-         <xforms:group id='group-jcaServer'>
-            <xforms:input id='input-jcaServer-hostConfig-host'
-               xforms:bind='bind-jcaServer-hostConfig-host'>
+      <xforms:case id='case-perfenvServer'>
+         <xforms:group id='group-perfenvServer'>
+            <xforms:input id='input-perfenvServer-hostConfig-host'
+               xforms:bind='bind-perfenvServer-hostConfig-host'>
                <xforms:label xforms:model='benchmark-labels'
                   xforms:ref='/labels/host' />
             </xforms:input>
-            <xforms:input id='input-jcaServer-hostConfig-enabled'
-               xforms:bind='bind-jcaServer-hostConfig-enabled'>
+            <xforms:input id='input-perfenvServer-hostConfig-enabled'
+               xforms:bind='bind-perfenvServer-hostConfig-enabled'>
                <xforms:label xforms:model='benchmark-labels'
                   xforms:ref='/labels/enabled' />
             </xforms:input>
-            <xforms:input id='input-jcaServer-hostConfig-tools'
-               xforms:bind='bind-jcaServer-hostConfig-tools'>
+            <xforms:input id='input-perfenvServer-hostConfig-tools'
+               xforms:bind='bind-perfenvServer-hostConfig-tools'>
                <xforms:label xforms:model='benchmark-labels'
                   xforms:ref='/labels/tools' />
             </xforms:input>
-            <xforms:input id='input-jcaServer-hostConfig-managedHosts'
-               xforms:bind='bind-jcaServer-hostConfig-managedHosts'>
+            <xforms:input id='input-perfenvServer-hostConfig-managedHosts'
+               xforms:bind='bind-perfenvServer-hostConfig-managedHosts'>
                <xforms:label xforms:model='benchmark-labels'
                   xforms:ref='/labels/managedHosts' />
             </xforms:input>
-            <xforms:input id='input-jcaServer-hostConfig-userCommands'
-               xforms:bind='bind-jcaServer-hostConfig-userCommands'>
+            <xforms:input id='input-perfenvServer-hostConfig-userCommands'
+               xforms:bind='bind-perfenvServer-hostConfig-userCommands'>
                <xforms:label xforms:model='benchmark-labels'
                   xforms:ref='/labels/userCommands'/>
             </xforms:input>
          </xforms:group>
       </xforms:case>
 
-      <xforms:case id='case-dbServer'>
-         <xforms:group id='group-dbServer'>
-
-            <xforms:input id='input-dbServer-hostConfig-host'
-               xforms:bind='bind-dbServer-hostConfig-host'>
-               <xforms:label xforms:model='benchmark-labels'
-                  xforms:ref='/labels/host' />
-            </xforms:input>
-            <xforms:input id='input-dbServer-hostConfig-enabled'
-               xforms:bind='bind-dbServer-hostConfig-enabled'>
-               <xforms:label xforms:model='benchmark-labels'
-                  xforms:ref='/labels/enabled' />
-            </xforms:input>
-            <xforms:input id='input-dbServer-hostConfig-tools'
-               xforms:bind='bind-dbServer-hostConfig-tools'>
-               <xforms:label xforms:model='benchmark-labels'
-                  xforms:ref='/labels/tools' />
-            </xforms:input>
-         </xforms:group>
-      </xforms:case>
-
    </xforms:switch>
 </xforms:group>
 <xforms:group id="group-buttons">

Modified: projects/jboss-jca/branches/performance/faban/benchmarks/cli-noop-jca-benchmark/deploy/run.xml
===================================================================
--- projects/jboss-jca/branches/performance/faban/benchmarks/cli-noop-jca-benchmark/deploy/run.xml	2011-08-05 16:56:44 UTC (rev 111947)
+++ projects/jboss-jca/branches/performance/faban/benchmarks/cli-noop-jca-benchmark/deploy/run.xml	2011-08-05 17:15:49 UTC (rev 111948)
@@ -130,6 +130,14 @@
             <fd:value>org.jboss.jca.performance.perfenv.tests.DatabaseTester</fd:value>
          </fd:property>
          <fd:property>
+            <fd:name>test.multithreaded</fd:name>
+            <fd:value>false</fd:value>
+         </fd:property>
+         <fd:property>
+            <fd:name>test.thread.count</fd:name>
+            <fd:value>1</fd:value>
+         </fd:property>
+         <fd:property>
             <fd:name>test.iteration.count</fd:name>
             <fd:value>1000</fd:value>
          </fd:property>
@@ -148,35 +156,16 @@
     Harness.
   -->
  
-  <jcaServer>
+  <perfenvServer>
     <fa:hostConfig xmlns="http://faban.sunsource.net/ns/fabanharness"
       xmlns:fa="http://faban.sunsource.net/ns/faban" xmlns:fh="http://faban.sunsource.net/ns/fabanharness">
       <fa:host>Enter middle tier host name or IP</fa:host>
       <fh:enabled>false</fh:enabled>
       <fh:cpus>0</fh:cpus>
       <fh:tools>NONE</fh:tools>
-      <fh:managedHosts>Enter managed host name</fh:managedHosts>
+      <fh:managedHosts>Enter middle tier host name or IP</fh:managedHosts>
       <userCommands></userCommands>
     </fa:hostConfig>
 
-    <!--
-      <fh:service xmlns:fh="http://faban.sunsource.net/ns/fabanharness">
-      <fh:name>IronJacamarService</fh:name>
-      <fh:enabled>true</fh:enabled> <fh:tools>NONE</fh:tools>
-      <fh:restart>true</fh:restart> <fh:config> <serverHome>Enter JCA
-      server install path.</serverHome> <runScript>run.sh</runScript>
-      <interfaceBindname>Enter a bind name</interfaceBindname>
-      <javaOptions></javaOptions> <listenPort>8080</listenPort>
-      </fh:config> </fh:service>
-    -->
-  </jcaServer>
-
-  <dbServer>
-    <fa:hostConfig xmlns="http://faban.sunsource.net/ns/fabanharness"
-      xmlns:fa="http://faban.sunsource.net/ns/faban" xmlns:fh="http://faban.sunsource.net/ns/fabanharness">
-      <fa:host>Enter middle tier host name or IP</fa:host>
-      <fh:enabled>false</fh:enabled>
-      <fh:tools>NONE</fh:tools>
-    </fa:hostConfig>
-  </dbServer>
+  </perfenvServer>
 </jcaBenchmark>

Modified: projects/jboss-jca/branches/performance/faban/src/main/java/org/jboss/jca/perf/benchmark/cli/noop/CLINoOpBenchmark.java
===================================================================
--- projects/jboss-jca/branches/performance/faban/src/main/java/org/jboss/jca/perf/benchmark/cli/noop/CLINoOpBenchmark.java	2011-08-05 16:56:44 UTC (rev 111947)
+++ projects/jboss-jca/branches/performance/faban/src/main/java/org/jboss/jca/perf/benchmark/cli/noop/CLINoOpBenchmark.java	2011-08-05 17:15:49 UTC (rev 111948)
@@ -32,7 +32,9 @@
  */
 public class CLINoOpBenchmark extends CLIBenchmark
 {
+   public static final String THREAD_COUNT = "test.thread.count";
    public static final String ITERATION_COUNT = "test.iteration.count";
+   public static final String MULTITHREADED_STATE = "test.multithreaded";
    
    @Override
    public void validate() throws Exception
@@ -56,5 +58,32 @@
             		"the value entered was not recognised as an integer");
          }
       }
+      
+      Object value = params.getBooleanValue(MULTITHREADED_STATE);
+      boolean isMultiThreaded = Boolean.parseBoolean((String)value);
+      if (null == value)
+      {
+         throw new Exception("Please select an option for enabling/disabling multithreading.");
+      }
+
+      if (isMultiThreaded)
+      {
+         String threadCount = params.getParameter(THREAD_COUNT);
+         if (null != threadCount && !"".equals(threadCount.trim()))
+         {
+            try
+            {
+               int count = Integer.parseInt(threadCount);
+               if (count < 1)
+               {
+                  throw new Exception ("The thread count must be greater than 0.");
+               }
+            }
+            catch (NumberFormatException nfe)
+            {
+               throw new Exception("The value thread count number entered is not a valid number.");
+            }
+         }
+      }
    }
 }

Modified: projects/jboss-jca/branches/performance/faban/src/main/java/org/jboss/jca/perf/benchmark/cli/noop/CLINoOpDriver.java
===================================================================
--- projects/jboss-jca/branches/performance/faban/src/main/java/org/jboss/jca/perf/benchmark/cli/noop/CLINoOpDriver.java	2011-08-05 16:56:44 UTC (rev 111947)
+++ projects/jboss-jca/branches/performance/faban/src/main/java/org/jboss/jca/perf/benchmark/cli/noop/CLINoOpDriver.java	2011-08-05 17:15:49 UTC (rev 111948)
@@ -22,8 +22,11 @@
 
 package org.jboss.jca.perf.benchmark.cli.noop;
 
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
 import org.jboss.jca.perf.benchmark.cli.CLIBenchmark;
-import org.jboss.jca.perf.benchmark.container.test.CLITransactionTest;
 import org.jboss.jca.performance.perfenv.Activate;
 import org.jboss.jca.performance.perfenv.CLI;
 import org.jboss.jca.performance.perfenv.Deactivate;
@@ -36,12 +39,14 @@
 import com.sun.faban.driver.BenchmarkDefinition;
 import com.sun.faban.driver.BenchmarkDriver;
 import com.sun.faban.driver.BenchmarkOperation;
+import com.sun.faban.driver.CustomMetrics;
 import com.sun.faban.driver.CycleType;
 import com.sun.faban.driver.DriverContext;
 import com.sun.faban.driver.FixedTime;
 import com.sun.faban.driver.FlatMix;
 import com.sun.faban.driver.OnceAfter;
 import com.sun.faban.driver.OnceBefore;
+import com.sun.faban.driver.Result;
 import com.sun.faban.driver.Timing;
 
 /**
@@ -54,6 +59,8 @@
 (
       name="NoOp Driver using the perfenv CLI interface."
       , version="1.0"
+      , scaleName = "txPerSec"
+      , metric = "tx/sec"
 )
 @BenchmarkDriver
 (
@@ -73,9 +80,9 @@
       , cycleDeviation=2
 )
 
-public class CLINoOpDriver
+public class CLINoOpDriver implements Serializable
 {
-   private DriverContext context;
+   transient DriverContext context;
    private static final String[] activateArgs = {new Activate().getName(), "sjc", Boolean.FALSE.toString()}; // NoopTS
    private static final String[] deployNoOpJDBCArgs = {new Deploy().getName(), "ironjacamar-performance-noopdb.jar"};
    private static final String[] deployJDBCArgs = {new Deploy().getName(), "jdbc-local.rar"};
@@ -84,24 +91,32 @@
    private static final String[] undeployJDBCArgs = {new Undeploy().getName(), "ironjacamar-performance-noopdb.jar"};
    private static final String[] undeployNoOpJDBCArgs = {new Undeploy().getName(), "jdbc-local.rar"};
    private static final String[] undeployDSArgs = {new Undeploy().getName(), "noopdb-ds.xml"};
-   private static final String[] deactivateArgs = {new Deactivate().getName(), CLITransactionTest.class.getName()};
    
-   private String[] setupArgs;
-   private String[] transactionArgs;
-   private String[] teardownArgs;
+   transient private ThreadLocal<CLI> cli = new ThreadLocal<CLI>();
    
+   CLINoOpMetric metric ;
+   
+   private String[] setupArgs, deactivateArgs, transactionArgs, teardownArgs;
+   private Boolean isMultithreaded;
+   private Integer threadCount = 1;
+   private Integer iterationCount;
+   
    @BenchmarkOperation
    (
-      name="callTransaction"
+      name="callNoOp"
       , max90th=2
       , timing = Timing.MANUAL
    )
    public void doCLIRequest()
       throws Exception
    {
-      context.recordTime();
+      context.recordTime();         
       CLI.main(transactionArgs);
       context.recordTime();
+      if (context.isTxSteadyState())
+      {
+         metric.invocationCount += 1;
+      }
    }
    
    @OnceBefore
@@ -109,6 +124,10 @@
       throws Exception
    {
       context.getLogger().info("Called test set-up on command line.");
+      metric.steadyState = context.getSteadyState();
+      metric.scale = context.getScale();
+      metric.iterationCount = iterationCount;
+      metric.threadCount = threadCount;
       CLI.main(activateArgs);
       CLI.main(deployNoOpJDBCArgs);
       CLI.main(deployJDBCArgs);
@@ -130,14 +149,360 @@
 
    /**
     * Create a new CLITransactionDriver.
-    * 
+    * There is an implicit expectation the validation of 
+    * user @see CLINoOpBenchmark.validate() entered data is valid.
+    *  The validate method should have caught any data that will 
+    *  not directly be parsed to field types.
     */
    public CLINoOpDriver()
    {
       context = DriverContext.getContext();
-      setupArgs = new String[]{new TestSetUp().getName(), context.getProperty(CLIBenchmark.FQCN_TEST), context.getProperty(CLIBenchmark.JNDI_NAME)};
-      transactionArgs = new String[] {new TestRunner().getName(), context.getProperty(CLIBenchmark.FQCN_TEST), "1"};
+
+      transactionArgs = new String[] {new TestRunner().getName(), context.getProperty(CLIBenchmark.FQCN_TEST)};
       teardownArgs = new String[]{new TestTearDown().getName(), context.getProperty(CLIBenchmark.FQCN_TEST)};
+      deactivateArgs = new String[]{new Deactivate().getName(), context.getProperty(CLIBenchmark.FQCN_TEST)};
+      iterationCount = Integer.parseInt(context.getProperty(CLINoOpBenchmark.ITERATION_COUNT));
+      isMultithreaded = Boolean.parseBoolean(context.getProperty( CLINoOpBenchmark.MULTITHREADED_STATE));
+      if (isMultithreaded)
+      {
+         threadCount = Integer.parseInt(context.getProperty(CLINoOpBenchmark.THREAD_COUNT));
+      }
+      // java:/NoopDS true/false threadcount iterations
+      setupArgs = new String[]{new TestSetUp().getName(), context.getProperty(CLIBenchmark.FQCN_TEST), context.getProperty(CLIBenchmark.JNDI_NAME), isMultithreaded.toString(), threadCount.toString(), iterationCount.toString()};
+      metric = new CLINoOpMetric();
+      context.attachMetrics("CLI ops/second metric.", metric);
    }
+   /*
+   private void main(String[] args)
+   {
+      Socket socket = null;
+      try
+      {
+         String host = null;
+         int port = 7000;
+         int counter = 0;
+         String command = "";
+
+         if ("-h".equals(args[counter]))
+         {
+            counter++;
+            host = args[counter];
+            counter++;
+         }
+
+         if ("-p".equals(args[counter]))
+         {
+            counter++;
+            port = Integer.valueOf(args[counter]).intValue();
+            counter++;
+         }
+
+         command = args[counter];
+         counter++;
+
+         if (host == null)
+            host = "localhost";
+
+         socket = new Socket(host, port);
+
+         ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());
+         boolean keepalive = "keepalive".equals(args[(args.length -1)]);
+         
+         do
+         {
+            oos.writeUTF("getcommand");
+            oos.writeObject(command);
+            
+            oos.flush();
+            
+            ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
+            
+            Serializable result = (Serializable)ois.readObject();
+   
+            if (result == null || result instanceof Class[])
+            {
+               Class[] parameterTypes = (Class[])result;
+               Serializable[] arguments = null;
+               if (parameterTypes != null)
+               {
+                  arguments = new Serializable[parameterTypes.length];
+                  for (int i = 0; i < parameterTypes.length; i++)
+                  {
+                     arguments[i] = getValue(parameterTypes[i], args[counter]);
+                     counter++;
+                  }
+               }
+   
+               executeCommand(host, port, command, arguments);
+            }
+            else
+            {
+               System.err.println(result);
+            }
+         } while (keepalive);
+      }
+      catch (Throwable t)
+      {
+         t.printStackTrace(System.err);
+      }
+      finally
+      {
+         try
+         {
+            if (socket != null)
+               socket.close();
+         }
+         catch (IOException ignore)
+         {
+            // Ignore
+         }
+      }
+   }
+
+   /**
+    * Execute command
+    * @param host The host
+    * @param port The port
+    * @param command The command
+    * @param arguments The arguments
+    * /
+   private static void executeCommand(String host, int port, String command, Serializable[] arguments)
+      throws Throwable
+   {
+      Socket socket = null;
+   
+      try
+      {
+         socket = new Socket(host, port);
+   
+         ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());
+         
+         oos.writeUTF(command);
+         
+         if (arguments != null)
+         {
+            for (Serializable argument : arguments)
+            {
+               oos.writeObject(argument);
+            }
+         }
+         
+         oos.flush();
+   
+         ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
+         
+         Serializable result = (Serializable)ois.readObject();
+   
+         if (result != null)
+         {
+            //System.out.println(result);
+         }
+      }
+      catch (EOFException ee)
+      {
+         // Nothing
+      }
+      finally
+      {
+         try
+         {
+            if (socket != null)
+               socket.close();
+         }
+         catch (IOException ignore)
+         {
+            // Ignore
+         }
+      }
+   }
+   
+   /**
+    * Get an instance of the type
+    * @param type The type
+    * @param value The string representation
+    * /
+   private static Serializable getValue(Class<?> type, String value)
+   {
+      if (value == null)
+         return null;
+   
+      if (String.class.equals(type))
+      {
+         return value;
+      }
+      else if (boolean.class.equals(type))
+      {
+         return Boolean.valueOf(value).booleanValue();
+      }
+      else if (Boolean.class.equals(type))
+      {
+         return Boolean.valueOf(value);
+      }
+      else if (byte.class.equals(type))
+      {
+         return Byte.valueOf(value).byteValue();
+      }
+      else if (Byte.class.equals(type))
+      {
+         return Byte.valueOf(value);
+      }
+      else if (char.class.equals(type))
+      {
+         return Character.valueOf(value.charAt(0)).charValue();
+      }
+      else if (Character.class.equals(type))
+      {
+         return Character.valueOf(value.charAt(0));
+      }
+      else if (double.class.equals(type))
+      {
+         return Double.valueOf(value).doubleValue();
+      }
+      else if (Double.class.equals(type))
+      {
+         return Double.valueOf(value);
+      }
+      else if (float.class.equals(type))
+      {
+         return Float.valueOf(value).floatValue();
+      }
+      else if (Float.class.equals(type))
+      {
+         return Float.valueOf(value);
+      }
+      else if (int.class.equals(type))
+      {
+         return Integer.valueOf(value).intValue();
+      }
+      else if (Integer.class.equals(type))
+      {
+         return Integer.valueOf(value);
+      }
+      else if (long.class.equals(type))
+      {
+         return Long.valueOf(value).longValue();
+      }
+      else if (Long.class.equals(type))
+      {
+         return Long.valueOf(value);
+      }
+      else if (short.class.equals(type))
+      {
+         return Short.valueOf(value).shortValue();
+      }
+      else if (Short.class.equals(type))
+      {
+         return Short.valueOf(value);
+      }
+      else if (URL.class.equals(type))
+      {
+         try
+         {
+            URL url = null;
+   
+            if (!(value.startsWith("file:") || value.startsWith("http:")))
+            {
+               url = new File(value).toURI().toURL();
+            }
+            else
+            {
+               url = new URL(value);
+            }
+            
+            return url;
+         }
+         catch (Throwable t)
+         {
+            System.err.println(t);
+         }
+   
+         return null;
+      }
+      else
+      {
+         System.err.println("Unknown type: " + type.getName() + " Value: " + value);
+      }
+   
+      return null;
+   }
+   */
+
+   /**
+    * A CLINoOpMetric object. This needs to support itself and not depend
+    * on enclosing class for cloning fields.
+    * 
+    * @author <a href="jwhiting at redhat.com">Jeremy Whiting</a>
+    * @version $Revision: 1.1 $
+    */
+   public class CLINoOpMetric implements CustomMetrics, Serializable
+   {
+      /**
+       * Count of the number of time the cli has been called. 
+       */
+      public int invocationCount = 0;
+      
+      /** The serialVersionUID */
+      private static final long serialVersionUID = 7245401177899796597L;
+      
+      /**
+       * Scale for the run
+       */
+      public int scale ;
+
+      /**
+       * steady state of the run
+       */
+      public int steadyState ;
+      
+      public int iterationCount ;
+      
+      int threadCount;
+      
+      /**
+       * List of the results in the data format Faban comprehends
+       */
+      private List<Element> resultElements = new ArrayList<Element>(1);
+      @Override
+      public void add(CustomMetrics other)
+      {
+      }
+
+      @Override
+      public Element[] getResults()
+      {
+         Element[] returnValue = null;
+         Result result = Result.getInstance();
+         double metricValue = result.getMetric();
+         if (metricValue > 0)
+         {
+            double opsRate = ((double)(((iterationCount * invocationCount)* scale)* threadCount) ) / steadyState;
+            Element element = new Element();
+            element.result = String.format("%5.3f", opsRate);
+            element.description = "CLI ops/sec";
+            element.passed = true;
+            resultElements.add(element);
+         }
+         else
+         {
+            resultElements.add(new Element());
+         }
+         returnValue = resultElements.toArray(new Element[0]);
+         
+         return returnValue ;
+      }
+      
+      @Override
+      public Object clone() 
+      {
+         CLINoOpMetric clonedMetric = new CLINoOpMetric();
+         clonedMetric.invocationCount = invocationCount;
+         clonedMetric.scale = scale;
+         clonedMetric.steadyState = steadyState;
+         clonedMetric.iterationCount = iterationCount;
+         clonedMetric.threadCount = threadCount;
+         return clonedMetric;
+      }
+   }
+   
 }
 



More information about the jboss-cvs-commits mailing list