[jboss-cvs] JBoss Messaging SVN: r7081 - in trunk: examples/common and 11 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed May 27 13:00:57 EDT 2009


Author: timfox
Date: 2009-05-27 13:00:57 -0400 (Wed, 27 May 2009)
New Revision: 7081

Added:
   trunk/examples/jms/perf/
   trunk/examples/jms/perf/build.xml
   trunk/examples/jms/perf/jndi.properties
   trunk/examples/jms/perf/perf.properties
   trunk/examples/jms/perf/readme.html
   trunk/examples/jms/perf/server0/
   trunk/examples/jms/perf/server0/jbm-configuration-messaging-lab.xml
   trunk/examples/jms/perf/server0/jbm-configuration.xml
   trunk/examples/jms/perf/server0/jbm-jboss-beans.xml
   trunk/examples/jms/perf/server0/jbm-jms.xml
   trunk/examples/jms/perf/src/
   trunk/examples/jms/perf/src/org/
   trunk/examples/jms/perf/src/org/jboss/
   trunk/examples/jms/perf/src/org/jboss/core/
   trunk/examples/jms/perf/src/org/jboss/core/example/
   trunk/examples/jms/perf/src/org/jboss/jms/
   trunk/examples/jms/perf/src/org/jboss/jms/example/
   trunk/examples/jms/perf/src/org/jboss/jms/example/PerfBase.java
   trunk/examples/jms/perf/src/org/jboss/jms/example/PerfListener.java
   trunk/examples/jms/perf/src/org/jboss/jms/example/PerfParams.java
   trunk/examples/jms/perf/src/org/jboss/jms/example/PerfSender.java
Modified:
   trunk/.classpath
   trunk/examples/common/build.xml
   trunk/examples/core/perf/server0/jbm-jboss-beans.xml
   trunk/examples/core/perf/src/org/jboss/core/example/PerfListener.java
Log:
jms perf example

Modified: trunk/.classpath
===================================================================
--- trunk/.classpath	2009-05-27 16:08:28 UTC (rev 7080)
+++ trunk/.classpath	2009-05-27 17:00:57 UTC (rev 7081)
@@ -49,6 +49,7 @@
 	<classpathentry kind="src" path="examples/jms/message-priority/src"/>
 	<classpathentry kind="src" path="examples/jms/no-consumer-buffering/src"/>
 	<classpathentry kind="src" path="examples/jms/paging/src"/>
+	<classpathentry kind="src" path="examples/jms/perf/src"/>
 	<classpathentry kind="src" path="examples/jms/pre-acknowledge/src"/>
 	<classpathentry kind="src" path="examples/jms/producer-rate-limit/src"/>
 	<classpathentry kind="src" path="examples/jms/queue/src"/>

Modified: trunk/examples/common/build.xml
===================================================================
--- trunk/examples/common/build.xml	2009-05-27 16:08:28 UTC (rev 7080)
+++ trunk/examples/common/build.xml	2009-05-27 17:00:57 UTC (rev 7081)
@@ -163,6 +163,7 @@
       <delete dir="./server5/logs" quiet="true" />
       <delete dir="./server5/data" quiet="true" />
       <delete dir="./ObjectStore" quiet="true" />
+      <delete dir="./data" quiet="true" />
       <!-- large-message creates huge .dat files -->
       <delete>
 	     <fileset dir=".">

Modified: trunk/examples/core/perf/server0/jbm-jboss-beans.xml
===================================================================
--- trunk/examples/core/perf/server0/jbm-jboss-beans.xml	2009-05-27 16:08:28 UTC (rev 7080)
+++ trunk/examples/core/perf/server0/jbm-jboss-beans.xml	2009-05-27 17:00:57 UTC (rev 7081)
@@ -1,48 +1,17 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
 <deployment xmlns="urn:jboss:bean-deployer:2.0">
-
-
-    <!-- MBean server -->
-   <bean name="MBeanServer" class="javax.management.MBeanServer">
-      <constructor factoryClass="java.lang.management.ManagementFactory"
-                   factoryMethod="getPlatformMBeanServer"/>
-   </bean>
-
+      
    <!-- The core configuration -->
-   <bean name="Configuration" class="org.jboss.messaging.core.config.impl.FileConfiguration"/>
+   <bean name="Configuration" class="org.jboss.messaging.core.config.impl.FileConfiguration"/>   
 
-   <!-- The security manager -->
-   <bean name="JBMSecurityManager" class="org.jboss.messaging.core.security.impl.JBMSecurityManagerImpl">
-      <start ignored="true"/>
-      <stop ignored="true"/>
-   </bean>
-
    <!-- The core server -->
    <bean name="MessagingServer" class="org.jboss.messaging.core.server.impl.MessagingServerImpl">
-      <start ignored="true"/>
-      <stop ignored="true"/>
       <constructor>
          <parameter>
             <inject bean="Configuration"/>
-         </parameter>
-         <parameter>
-            <inject bean="MBeanServer"/>
-         </parameter>
-         <parameter>
-            <inject bean="JBMSecurityManager"/>
-         </parameter>
+         </parameter>         
       </constructor>
    </bean>
-
-   <!-- The JMS server -->
-   <bean name="JMSServerManager" class="org.jboss.messaging.jms.server.impl.JMSServerManagerImpl">
-      <constructor>
-         <parameter>
-            <inject bean="MessagingServer"/>
-         </parameter>
-      </constructor>
-   </bean>
-
-
+   
 </deployment>

Modified: trunk/examples/core/perf/src/org/jboss/core/example/PerfListener.java
===================================================================
--- trunk/examples/core/perf/src/org/jboss/core/example/PerfListener.java	2009-05-27 16:08:28 UTC (rev 7080)
+++ trunk/examples/core/perf/src/org/jboss/core/example/PerfListener.java	2009-05-27 17:00:57 UTC (rev 7081)
@@ -23,6 +23,7 @@
 
 import java.util.logging.Logger;
 
+
 /**
  * 
  * A PerfListener


Property changes on: trunk/examples/jms/perf
___________________________________________________________________
Name: svn:ignore
   + build


Added: trunk/examples/jms/perf/build.xml
===================================================================
--- trunk/examples/jms/perf/build.xml	                        (rev 0)
+++ trunk/examples/jms/perf/build.xml	2009-05-27 17:00:57 UTC (rev 7081)
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE project [
+      <!ENTITY libraries SYSTEM "../../../thirdparty/libraries.ent">
+      ]>
+
+<!-- =========================================================================================== -->
+<!--                                                                                             -->
+<!-- JBoss, Home of Professional Open Source                                                     -->
+<!-- Copyright 2005, 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.                                    -->
+<!--                                                                                             -->
+<!-- =========================================================================================== -->
+
+
+<project name="JBoss Messaging JMS Perf Example">
+
+   <import file="../../common/build.xml"/>
+
+   <path id="extra.classpath">
+       <path location="server0"/>
+   </path>
+   
+   <property name="perf.properties.file.name" value="perf.properties" />
+
+   <path id="the.classpath">         
+      <path refid="client.classpath"/>
+      <path location="."/>
+   </path>
+   
+   <target name="runSender" depends="compile">
+      <java classname="org.jboss.jms.example.PerfSender" fork="true" resultproperty="example-result">
+		   <jvmarg value="-Xms512M"/>
+		   <jvmarg value="-Xmx512M"/>
+         <jvmarg value="-XX:+UseParallelGC"/>
+         <jvmarg value="-XX:+AggressiveOpts"/>
+		   <jvmarg value="-XX:+UseFastAccessorMethods"/>
+         <jvmarg value="-Djava.util.logging.config.file=${config.dir}/logging.properties"/>
+         <arg line="${perf.properties.file.name}"/>
+         <classpath refid="the.classpath"/>
+      </java>
+   </target>
+
+   <target name="runListener" depends="compile">
+      <java classname="org.jboss.jms.example.PerfListener" fork="true" resultproperty="example-result">         
+         <jvmarg value="-Xms512M"/>
+		   <jvmarg value="-Xmx512M"/>
+         <jvmarg value="-XX:+UseParallelGC"/>
+         <jvmarg value="-XX:+AggressiveOpts"/>
+		   <jvmarg value="-XX:+UseFastAccessorMethods"/>
+         <jvmarg value="-Djava.util.logging.config.file=${config.dir}/logging.properties"/>  
+         <arg line="${perf.properties.file.name}"/>
+         <classpath refid="the.classpath"/>
+      </java>
+   </target>
+
+   <target name="runServer" depends="compile">
+      <java classname="org.jboss.common.example.SpawnedJBMServer" fork="true" resultproperty="example-result">
+         <jvmarg value="-Xms2048M"/>
+		   <jvmarg value="-Xmx2048M"/>
+         <jvmarg value="-XX:+UseParallelGC"/> 
+      	<sysproperty key="java.library.path" value="${java.library.path}${path.separator}${aio.library.path}"/>
+         <jvmarg value="-XX:+AggressiveOpts"/>
+		   <jvmarg value="-XX:+UseFastAccessorMethods"/>
+         <jvmarg value="-Djava.util.logging.config.file=${config.dir}/logging.properties"/>
+         <arg line="jbm-jboss-beans.xml"/>
+         <classpath refid="server.classpath"/>
+      </java>
+   </target>
+
+</project>
\ No newline at end of file

Added: trunk/examples/jms/perf/jndi.properties
===================================================================
--- trunk/examples/jms/perf/jndi.properties	                        (rev 0)
+++ trunk/examples/jms/perf/jndi.properties	2009-05-27 17:00:57 UTC (rev 7081)
@@ -0,0 +1,3 @@
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.provider.url=jnp://localhost:1099
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

Added: trunk/examples/jms/perf/perf.properties
===================================================================
--- trunk/examples/jms/perf/perf.properties	                        (rev 0)
+++ trunk/examples/jms/perf/perf.properties	2009-05-27 17:00:57 UTC (rev 7081)
@@ -0,0 +1,13 @@
+num-messages=100000
+num-warmup-messages=10000
+message-size=0
+durable=false
+transacted=false
+batch-size=1000
+drain-queue=true
+destination-lookup=perfQueue
+connection-factory-lookup=/ConnectionFactory
+throttle-rate=-1
+dups-ok-acknowledge=false
+disable-message-id=true
+disable-message-timestamp=true

Added: trunk/examples/jms/perf/readme.html
===================================================================
--- trunk/examples/jms/perf/readme.html	                        (rev 0)
+++ trunk/examples/jms/perf/readme.html	2009-05-27 17:00:57 UTC (rev 7081)
@@ -0,0 +1,114 @@
+<html>
+   <head>
+      <title>JBoss Messaging Performance Example</title>
+      <link rel="stylesheet" type="text/css" href="../../common/common.css"/>
+   </head>
+   <body>
+      <h1>Performance Example</h1>
+      <br/>
+      <p>This example is used to measure performance on JBoss Messaging through different
+         scenarios.</p>
+      <p>To play with these difference scenarios, change server configurations and change properties
+         on perf.properties:</p>
+      <p>
+         <ul>
+            <li>num-messages - Number of messages generated and read on this scenario</li>
+            <li>message-size - Number of bytes written on the message body</li>
+            <li>durable - Boolean value if the message should be persisted on disk before delivery</li>
+            <li>transacted - Boolean value if the test should use transactions</li>
+            <li>batch-size - Number of elements per transactions</li>
+            <li>drain-queue - Boolean value if the test should read all elements on the queue before starting</li>
+            <li>queue-name - Name of the queue used on the test</li>
+            <li>address - Address used to send message</li>
+            <li>throttle-rate - TODO</li>
+         </ul>
+      </p>
+      <h2>Example step-by-step</h2>
+      <p>After configured server and perf.properties:</p>
+      <br/>
+      <ol>
+         <li>Start the server in one Window. Just call ant runServer:</li>
+         <pre><code>user at myserver:/jboss-messaging/examples/core/perf$ ant runServer
+Buildfile: build.xml
+
+init:
+
+compile:
+[echo] src.example.dir=/jboss-messaging/examples/core/perf/src
+
+runServer:
+[java] May 21, 2009 4:44:55 PM org.jboss.messaging.core.logging.Logger warn
+[java] WARNING: It has been detected that the cluster admin password which is used to replicate management operation from one node to the other has not had its password changed from the installation default. Please see the JBoss Messaging user guide for instructions on how to do this.
+[java] May 21, 2009 4:44:56 PM org.jboss.messaging.core.logging.Logger warn
+[java] WARNING: Property jbm.remoting.netty.tcpsendbuffersize must be an Integer
+[java] May 21, 2009 4:44:56 PM org.jboss.messaging.core.logging.Logger warn
+[java] WARNING: Property jbm.remoting.netty.tcpreceivebuffersize must be an Integer
+[java] May 21, 2009 4:44:56 PM org.jboss.messaging.core.logging.Logger info
+[java] INFO: JBoss Messaging Server version 2.0.0.BETA1-SNAPSHOT (Stilton, 101) started
+[java] STARTED::</code>
+        </pre>
+         <li>Start the listener. Just call ant runListener</li>
+         <pre><code>user at myserver:/jboss-messaging/examples/core/perf$ ant runListener
+Buildfile: build.xml
+
+init:
+
+compile:
+[echo] src.example.dir=/jboss-messaging/examples/core/perf/src
+
+runListener:
+[java] May 21, 2009 4:47:47 PM org.jboss.core.example.PerfBase getParams
+[java] INFO: num-messages: 1000000
+[java] May 21, 2009 4:47:47 PM org.jboss.core.example.PerfBase getParams
+[java] INFO: num-warmup-messages: 50000
+[java] May 21, 2009 4:47:47 PM org.jboss.core.example.PerfBase getParams
+[java] INFO: message-size: 0
+[java] May 21, 2009 4:47:47 PM org.jboss.core.example.PerfBase getParams
+[java] INFO: durable: false
+[java] May 21, 2009 4:47:47 PM org.jboss.core.example.PerfBase getParams
+[java] INFO: transacted: false
+[java] May 21, 2009 4:47:47 PM org.jboss.core.example.PerfBase getParams
+[java] INFO: batch-size: 1000
+[java] May 21, 2009 4:47:47 PM org.jboss.core.example.PerfBase getParams
+[java] INFO: drain-queue: true
+[java] May 21, 2009 4:47:47 PM org.jboss.core.example.PerfBase getParams
+[java] INFO: address: perfAddress
+[java] May 21, 2009 4:47:47 PM org.jboss.core.example.PerfBase getParams
+[java] INFO: throttle-rate: -1
+[java] May 21, 2009 4:47:48 PM org.jboss.core.example.PerfBase drainQueue
+[java] INFO: Draining queue
+[java] May 21, 2009 4:47:51 PM org.jboss.core.example.PerfBase drainQueue
+[java] INFO: Drained 0 messages
+[java] May 21, 2009 4:47:51 PM org.jboss.core.example.PerfBase runListener
+[java] INFO: READY!!!</code></pre>
+         <li>Start the sender. Just call ant runSender</li>
+         <pre><code>user at myserver:/jboss-messaging/examples/core/perf$ ant runSender
+Buildfile: build.xml
+
+init:
+
+compile:
+[echo] src.example.dir=/work/projects/trunk/examples/core/perf/src
+
+runSender:
+[java] May 21, 2009 4:51:16 PM org.jboss.core.example.PerfBase getParams
+[java] INFO: num-messages: 1000000
+[java] May 21, 2009 4:51:16 PM org.jboss.core.example.PerfBase getParams
+[java] INFO: num-warmup-messages: 50000
+[java] May 21, 2009 4:51:16 PM org.jboss.core.example.PerfBase getParams
+
+...
+
+[java] May 21, 2009 4:51:33 PM org.jboss.core.example.PerfBase sendMessages
+[java] INFO: sent 994000 messages in 10.60s
+[java] May 21, 2009 4:51:33 PM org.jboss.core.example.PerfBase sendMessages
+[java] INFO: sent 996000 messages in 10.61s
+[java] May 21, 2009 4:51:33 PM org.jboss.core.example.PerfBase sendMessages
+[java] INFO: sent 998000 messages in 10.61s
+[java] May 21, 2009 4:51:33 PM org.jboss.core.example.PerfBase sendMessages
+[java] INFO: sent 1000000 messages in 10.62s
+[java] May 21, 2009 4:51:33 PM org.jboss.core.example.PerfBase displayAverage
+[java] INFO: average: 94197.44 msg/s (1000000 messages in 10.62s)</code></pre>
+      </ol>
+   </body>
+</html>

Added: trunk/examples/jms/perf/server0/jbm-configuration-messaging-lab.xml
===================================================================
--- trunk/examples/jms/perf/server0/jbm-configuration-messaging-lab.xml	                        (rev 0)
+++ trunk/examples/jms/perf/server0/jbm-configuration-messaging-lab.xml	2009-05-27 17:00:57 UTC (rev 7081)
@@ -0,0 +1,32 @@
+<configuration xmlns="urn:jboss:messaging"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:jboss:messaging /schema/jbm-configuration.xsd">
+
+   
+   <!-- Acceptors -->
+   <acceptors>
+      <acceptor name="netty-acceptor">
+         <factory-class>org.jboss.messaging.integration.transports.netty.NettyAcceptorFactory</factory-class>    
+         <param key="jbm.remoting.netty.tcpnodelay" value="false" type="Boolean"/>
+         <param key="jbm.remoting.netty.tcpsendbuffersize" value="1048576" type="Boolean"/>
+         <param key="jbm.remoting.netty.tcpreceivebuffersize" value="1048576" type="Boolean"/>
+         <param key="jbm.remoting.netty.host" value="172.16.8.10" type="String"/>
+      </acceptor>
+   </acceptors>
+   
+   <security-enabled>false</security-enabled>
+   
+   <persistence-enabled>true</persistence-enabled>
+
+   <large-messages-directory>/jbm-data/large-messages</large-messages-directory>
+   <bindings-directory>/jbm-data/bindings</bindings-directory>
+   <journal-directory>/jbm-data/journal</journal-directory>
+   <paging-directory>/jbm-data/paging</paging-directory> 
+   
+   <queues>
+	   <queue name="perfQueue">
+	   	<address>perfAddress</address>
+	   </queue>
+   </queues>
+
+</configuration>

Added: trunk/examples/jms/perf/server0/jbm-configuration.xml
===================================================================
--- trunk/examples/jms/perf/server0/jbm-configuration.xml	                        (rev 0)
+++ trunk/examples/jms/perf/server0/jbm-configuration.xml	2009-05-27 17:00:57 UTC (rev 7081)
@@ -0,0 +1,34 @@
+<configuration xmlns="urn:jboss:messaging"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:jboss:messaging /schema/jbm-configuration.xsd">
+
+   <connectors>
+      <connector name="netty-connector">
+         <factory-class>org.jboss.messaging.integration.transports.netty.NettyConnectorFactory</factory-class>    
+         <param key="jbm.remoting.netty.tcpnodelay" value="false" type="Boolean"/>
+         <param key="jbm.remoting.netty.tcpsendbuffersize" value="1048576" type="Integer"/>
+         <param key="jbm.remoting.netty.tcpreceivebuffersize" value="1048576" type="Integer"/>
+      </connector>
+   </connectors>
+   
+   <!-- Acceptors -->
+   <acceptors>
+      <acceptor name="netty-acceptor">
+         <factory-class>org.jboss.messaging.integration.transports.netty.NettyAcceptorFactory</factory-class>    
+         <param key="jbm.remoting.netty.tcpnodelay" value="false" type="Boolean"/>
+         <param key="jbm.remoting.netty.tcpsendbuffersize" value="1048576" type="Integer"/>
+         <param key="jbm.remoting.netty.tcpreceivebuffersize" value="1048576" type="Integer"/>
+      </acceptor>
+   </acceptors>
+   
+   <security-enabled>false</security-enabled>
+   
+   <persistence-enabled>false</persistence-enabled>
+   
+   <queues>
+	   <queue name="perfQueue">
+	   	<address>perfAddress</address>
+	   </queue>
+   </queues>
+
+</configuration>

Added: trunk/examples/jms/perf/server0/jbm-jboss-beans.xml
===================================================================
--- trunk/examples/jms/perf/server0/jbm-jboss-beans.xml	                        (rev 0)
+++ trunk/examples/jms/perf/server0/jbm-jboss-beans.xml	2009-05-27 17:00:57 UTC (rev 7081)
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+<bean name="Naming" class="org.jnp.server.NamingBeanImpl"/>
+
+   <!-- JNDI server. Disable this if you don't want JNDI -->
+   <bean name="JNDIServer" class="org.jnp.server.Main">
+      <property name="namingInfo">
+         <inject bean="Naming"/>
+      </property>
+      <property name="port">1099</property>
+      <property name="bindAddress">localhost</property>
+      <property name="rmiPort">1098</property>
+      <property name="rmiBindAddress">localhost</property>
+   </bean>
+
+   <!-- The core configuration -->
+   <bean name="Configuration" class="org.jboss.messaging.core.config.impl.FileConfiguration"/>
+
+   <!-- The core server -->
+   <bean name="MessagingServer" class="org.jboss.messaging.core.server.impl.MessagingServerImpl">
+      <start ignored="true"/>
+      <stop ignored="true"/>
+      <constructor>
+         <parameter>
+            <inject bean="Configuration"/>
+         </parameter>         
+      </constructor>
+   </bean>
+
+   <!-- The JMS server -->
+   <bean name="JMSServerManager" class="org.jboss.messaging.jms.server.impl.JMSServerManagerImpl">
+      <constructor>
+         <parameter>
+            <inject bean="MessagingServer"/>
+         </parameter>
+      </constructor>
+   </bean>
+
+</deployment>

Added: trunk/examples/jms/perf/server0/jbm-jms.xml
===================================================================
--- trunk/examples/jms/perf/server0/jbm-jms.xml	                        (rev 0)
+++ trunk/examples/jms/perf/server0/jbm-jms.xml	2009-05-27 17:00:57 UTC (rev 7081)
@@ -0,0 +1,16 @@
+<configuration xmlns="urn:jboss:messaging"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:jboss:messaging /schema/jbm-jms.xsd">
+   <!--the connection factory used by the example-->
+   <connection-factory name="ConnectionFactory">
+      <connector-ref connector-name="netty-connector"/>
+      <entries>
+         <entry name="ConnectionFactory"/>
+      </entries>
+   </connection-factory>
+   
+   <queue name="perfQueue">
+      <entry name="perfQueue"/>
+   </queue>
+
+</configuration>

Added: trunk/examples/jms/perf/src/org/jboss/jms/example/PerfBase.java
===================================================================
--- trunk/examples/jms/perf/src/org/jboss/jms/example/PerfBase.java	                        (rev 0)
+++ trunk/examples/jms/perf/src/org/jboss/jms/example/PerfBase.java	2009-05-27 17:00:57 UTC (rev 7081)
@@ -0,0 +1,458 @@
+/*
+   * JBoss, Home of Professional Open Source
+   * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+   * 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.jms.example;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.Properties;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.logging.Logger;
+
+import javax.jms.BytesMessage;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.Destination;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.naming.InitialContext;
+
+import org.jboss.messaging.utils.TokenBucketLimiter;
+import org.jboss.messaging.utils.TokenBucketLimiterImpl;
+
+/**
+ * 
+ * A PerfBase
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ *
+ */
+public abstract class PerfBase
+{
+   private static final Logger log = Logger.getLogger(PerfSender.class.getName());
+
+   private static final String DEFAULT_PERF_PROPERTIES_FILE_NAME = "perf.properties";
+
+   protected static String getPerfFileName(String[] args)
+   {
+      String fileName;
+
+      if (args.length > 0)
+      {
+         fileName = args[0];
+      }
+      else
+      {
+         fileName = DEFAULT_PERF_PROPERTIES_FILE_NAME;
+      }
+
+      return fileName;
+   }
+
+   protected static PerfParams getParams(final String fileName) throws Exception
+   {
+      Properties props = null;
+
+      InputStream is = null;
+
+      try
+      {
+         is = new FileInputStream(fileName);
+
+         props = new Properties();
+
+         props.load(is);
+      }
+      finally
+      {
+         if (is != null)
+         {
+            is.close();
+         }
+      }
+
+      int noOfMessages = Integer.valueOf(props.getProperty("num-messages"));
+      int noOfWarmupMessages = Integer.valueOf(props.getProperty("num-warmup-messages"));
+      int messageSize = Integer.valueOf(props.getProperty("message-size"));
+      boolean durable = Boolean.valueOf(props.getProperty("durable"));
+      boolean transacted = Boolean.valueOf(props.getProperty("transacted"));
+      int batchSize = Integer.valueOf(props.getProperty("batch-size"));
+      boolean drainQueue = Boolean.valueOf(props.getProperty("drain-queue"));
+      String destinationLookup = props.getProperty("destination-lookup");
+      String connectionFactoryLookup = props.getProperty("connection-factory-lookup");
+      int throttleRate = Integer.valueOf(props.getProperty("throttle-rate"));
+      boolean dupsOK = Boolean.valueOf(props.getProperty("dups-ok-acknowlege"));
+      boolean disableMessageID = Boolean.valueOf(props.getProperty("disable-message-id"));
+      boolean disableTimestamp = Boolean.valueOf(props.getProperty("disable-message-timestamp"));
+
+      log.info("num-messages: " + noOfMessages);
+      log.info("num-warmup-messages: " + noOfWarmupMessages);
+      log.info("message-size: " + messageSize);
+      log.info("durable: " + durable);
+      log.info("transacted: " + transacted);
+      log.info("batch-size: " + batchSize);
+      log.info("drain-queue: " + drainQueue);
+      log.info("throttle-rate: " + throttleRate);
+      log.info("connection-factory-lookup: " + connectionFactoryLookup);
+      log.info("destination-lookup: " + destinationLookup);
+      log.info("disable-message-id: " + disableMessageID);
+      log.info("disable-message-timestamp: " + disableTimestamp);
+      log.info("dups-ok-acknowledge: " + dupsOK);
+
+      PerfParams perfParams = new PerfParams();
+      perfParams.setNoOfMessagesToSend(noOfMessages);
+      perfParams.setNoOfWarmupMessages(noOfWarmupMessages);
+      perfParams.setMessageSize(messageSize);
+      perfParams.setDurable(durable);
+      perfParams.setSessionTransacted(transacted);
+      perfParams.setBatchSize(batchSize);
+      perfParams.setDrainQueue(drainQueue);
+      perfParams.setConnectionFactoryLookup(connectionFactoryLookup);
+      perfParams.setDestinationLookup(destinationLookup);
+      perfParams.setThrottleRate(throttleRate);
+      perfParams.setDisableMessageID(disableMessageID);
+      perfParams.setDisableTimestamp(disableTimestamp);
+      perfParams.setDupsOK(dupsOK);
+
+      return perfParams;
+   }
+
+   private final PerfParams perfParams;
+
+   protected PerfBase(final PerfParams perfParams)
+   {
+      this.perfParams = perfParams;
+   }
+
+   private ConnectionFactory factory;
+
+   private Connection connection;
+
+   private Session session;
+
+   private Destination destination;
+
+   private long start;
+
+   private void init() throws Exception
+   {
+      InitialContext ic = new InitialContext();
+
+      factory = (ConnectionFactory)ic.lookup(perfParams.getConnectionFactoryLookup());
+
+      destination = (Destination)ic.lookup(perfParams.getDestinationLookup());
+
+      connection = factory.createConnection();
+
+      session = connection.createSession(perfParams.isSessionTransacted(),
+                                         perfParams.isDupsOK() ? Session.DUPS_OK_ACKNOWLEDGE : Session.AUTO_ACKNOWLEDGE);
+
+      ic.close();
+   }
+
+   private void displayAverage(final long numberOfMessages, final long start, final long end)
+   {
+      double duration = (1.0 * end - start) / 1000; // in seconds
+      double average = (1.0 * numberOfMessages / duration);
+      log.info(String.format("average: %.2f msg/s (%d messages in %2.2fs)", average, numberOfMessages, duration));
+   }
+
+   protected void runSender()
+   {
+      try
+      {
+         init();
+
+         if (perfParams.isDrainQueue())
+         {
+            drainQueue();
+         }
+
+         start = System.currentTimeMillis();
+         log.info("warming up by sending " + perfParams.getNoOfWarmupMessages() + " messages");
+         sendMessages(perfParams.getNoOfWarmupMessages(),
+                      perfParams.getBatchSize(),
+                      perfParams.isDurable(),
+                      perfParams.isSessionTransacted(),
+                      false,
+                      perfParams.getThrottleRate(),
+                      perfParams.getMessageSize());
+         log.info("warmed up");
+         start = System.currentTimeMillis();
+         sendMessages(perfParams.getNoOfMessagesToSend(),
+                      perfParams.getBatchSize(),
+                      perfParams.isDurable(),
+                      perfParams.isSessionTransacted(),
+                      true,
+                      perfParams.getThrottleRate(),
+                      perfParams.getMessageSize());
+         long end = System.currentTimeMillis();
+         displayAverage(perfParams.getNoOfMessagesToSend(), start, end);
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+      }
+      finally
+      {
+         if (session != null)
+         {
+            try
+            {
+               session.close();
+            }
+            catch (Exception e)
+            {
+               e.printStackTrace();
+            }
+         }
+      }
+   }
+
+   protected void runListener()
+   {
+      try
+      {
+         init();
+
+         if (perfParams.isDrainQueue())
+         {
+            drainQueue();
+         }
+
+         MessageConsumer consumer = session.createConsumer(destination);
+
+         connection.start();
+
+         log.info("READY!!!");
+
+         CountDownLatch countDownLatch = new CountDownLatch(1);
+         consumer.setMessageListener(new PerfListener(countDownLatch, perfParams));
+         countDownLatch.await();
+         long end = System.currentTimeMillis();
+         // start was set on the first received message
+         displayAverage(perfParams.getNoOfMessagesToSend(), start, end);
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+      }
+      finally
+      {
+         if (session != null)
+         {
+            try
+            {
+               session.close();
+            }
+            catch (Exception e)
+            {
+               e.printStackTrace();
+            }
+         }
+      }
+   }
+
+   private void drainQueue() throws Exception
+   {
+      log.info("Draining queue");
+
+      Session drainSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+      MessageConsumer consumer = drainSession.createConsumer(destination);
+
+      connection.start();
+
+      Message message = null;
+
+      int count = 0;
+      do
+      {
+         message = consumer.receive(3000);
+
+         if (message != null)
+         {
+            message.acknowledge();
+
+            count++;
+         }
+      }
+      while (message != null);
+
+      drainSession.close();
+
+      log.info("Drained " + count + " messages");
+   }
+
+   private void sendMessages(final int numberOfMessages,
+                             final int txBatchSize,
+                             final boolean durable,
+                             final boolean transacted,
+                             final boolean display,
+                             final int throttleRate,
+                             final int messageSize) throws Exception
+   {
+      MessageProducer producer = session.createProducer(destination);
+
+      producer.setDeliveryMode(perfParams.isDurable() ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
+
+      producer.setDisableMessageID(perfParams.isDisableMessageID());
+
+      producer.setDisableMessageTimestamp(perfParams.isDisableTimestamp());
+
+      BytesMessage message = session.createBytesMessage();
+
+      byte[] payload = new byte[messageSize];
+
+      message.writeBytes(payload);
+
+      final int modulo = 2000;
+
+      TokenBucketLimiter tbl = throttleRate != -1 ? new TokenBucketLimiterImpl(throttleRate, false) : null;
+
+      boolean committed = false;
+      for (int i = 1; i <= numberOfMessages; i++)
+      {
+         producer.send(message);
+
+         if (transacted)
+         {
+            if (i % txBatchSize == 0)
+            {
+               session.commit();
+               committed = true;
+            }
+            else
+            {
+               committed = false;
+            }
+         }
+
+         if (display && (i % modulo == 0))
+         {
+            double duration = (1.0 * System.currentTimeMillis() - start) / 1000;
+            log.info(String.format("sent %6d messages in %2.2fs", i, duration));
+         }
+
+         if (tbl != null)
+         {
+            tbl.limit();
+         }
+      }
+      if (transacted && !committed)
+      {
+         session.commit();
+      }
+   }
+
+   private class PerfListener implements MessageListener
+   {
+      private final CountDownLatch countDownLatch;
+
+      private final PerfParams perfParams;
+
+      private boolean warmingUp = true;
+
+      private boolean started = false;
+
+      private final int modulo;
+
+      private final AtomicLong count = new AtomicLong(0);
+
+      public PerfListener(final CountDownLatch countDownLatch, final PerfParams perfParams)
+      {
+         this.countDownLatch = countDownLatch;
+         this.perfParams = perfParams;
+         warmingUp = perfParams.getNoOfWarmupMessages() > 0;
+         this.modulo = 2000;
+      }
+
+      public void onMessage(final Message message)
+      {
+         try
+         {
+            if (warmingUp)
+            {
+               boolean committed = checkCommit();
+               if (count.incrementAndGet() == perfParams.getNoOfWarmupMessages())
+               {
+                  log.info("warmed up after receiving " + count.longValue() + " msgs");
+                  if (!committed)
+                  {
+                     checkCommit();
+                  }
+                  warmingUp = false;
+               }
+               return;
+            }
+
+            if (!started)
+            {
+               started = true;
+               // reset count to take stats
+               count.set(0);
+               start = System.currentTimeMillis();
+            }
+
+            long currentCount = count.incrementAndGet();
+            boolean committed = checkCommit();
+            if (currentCount == perfParams.getNoOfMessagesToSend())
+            {
+               if (!committed)
+               {
+                  checkCommit();
+               }
+               countDownLatch.countDown();
+            }
+            if (currentCount % modulo == 0)
+            {
+               double duration = (1.0 * System.currentTimeMillis() - start) / 1000;
+               log.info(String.format("received %6d messages in %2.2fs", currentCount, duration));
+            }
+         }
+         catch (Exception e)
+         {
+            e.printStackTrace();
+         }
+      }
+
+      private boolean checkCommit() throws Exception
+      {
+         if (perfParams.isSessionTransacted())
+         {
+            if (count.longValue() % perfParams.getBatchSize() == 0)
+            {
+               session.commit();
+
+               return true;
+            }
+         }
+         return false;
+      }
+   }
+
+}

Added: trunk/examples/jms/perf/src/org/jboss/jms/example/PerfListener.java
===================================================================
--- trunk/examples/jms/perf/src/org/jboss/jms/example/PerfListener.java	                        (rev 0)
+++ trunk/examples/jms/perf/src/org/jboss/jms/example/PerfListener.java	2009-05-27 17:00:57 UTC (rev 7081)
@@ -0,0 +1,65 @@
+/*
+   * JBoss, Home of Professional Open Source
+   * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+   * 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.jms.example;
+
+import java.util.logging.Logger;
+
+
+/**
+ * 
+ * A PerfListener
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ *
+ */
+public class PerfListener extends PerfBase
+{
+   private static final Logger log = Logger.getLogger(PerfListener.class.getName());
+      
+   public static void main(String[] args)
+   {
+      try
+      {
+         String fileName = PerfBase.getPerfFileName(args);
+         
+         PerfParams params = getParams(fileName);
+
+         new PerfListener(params).run();
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+      }
+   }
+
+   private PerfListener(final PerfParams perfParams)
+   {
+      super(perfParams);
+   }
+
+   public void run() throws Exception
+   {
+      runListener();
+   }
+
+}

Added: trunk/examples/jms/perf/src/org/jboss/jms/example/PerfParams.java
===================================================================
--- trunk/examples/jms/perf/src/org/jboss/jms/example/PerfParams.java	                        (rev 0)
+++ trunk/examples/jms/perf/src/org/jboss/jms/example/PerfParams.java	2009-05-27 17:00:57 UTC (rev 7081)
@@ -0,0 +1,157 @@
+/*
+   * JBoss, Home of Professional Open Source
+   * Copyright 2005, 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.jms.example;
+
+import java.io.Serializable;
+
+/**
+ * 
+ * Class that holds the parameters used in the performance examples
+ * 
+ * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ */
+public class PerfParams implements Serializable
+{
+   private static final long serialVersionUID = -4336539641012356002L;
+   
+   private int noOfMessagesToSend = 1000;
+   private int noOfWarmupMessages;
+   private int messageSize = 1024; // in bytes
+   private boolean durable = false;
+   private boolean isSessionTransacted = false;
+   private int batchSize = 5000;
+   private boolean drainQueue = true;
+   private String connectionFactoryLookup;
+   private String destinationLookup;
+   private int throttleRate;
+   private boolean disableMessageID;
+   private boolean disableTimestamp;
+   private boolean dupsOK;
+   
+   public synchronized int getNoOfMessagesToSend()
+   {
+      return noOfMessagesToSend;
+   }
+   public synchronized void setNoOfMessagesToSend(int noOfMessagesToSend)
+   {
+      this.noOfMessagesToSend = noOfMessagesToSend;
+   }
+   public synchronized int getNoOfWarmupMessages()
+   {
+      return noOfWarmupMessages;
+   }
+   public synchronized void setNoOfWarmupMessages(int noOfWarmupMessages)
+   {
+      this.noOfWarmupMessages = noOfWarmupMessages;
+   }
+   public synchronized int getMessageSize()
+   {
+      return messageSize;
+   }
+   public synchronized void setMessageSize(int messageSize)
+   {
+      this.messageSize = messageSize;
+   }
+   public synchronized boolean isDurable()
+   {
+      return durable;
+   }
+   public synchronized void setDurable(boolean durable)
+   {
+      this.durable = durable;
+   }
+   public synchronized boolean isSessionTransacted()
+   {
+      return isSessionTransacted;
+   }
+   public synchronized void setSessionTransacted(boolean isSessionTransacted)
+   {
+      this.isSessionTransacted = isSessionTransacted;
+   }
+   public synchronized int getBatchSize()
+   {
+      return batchSize;
+   }
+   public synchronized void setBatchSize(int batchSize)
+   {
+      this.batchSize = batchSize;
+   }
+   public synchronized boolean isDrainQueue()
+   {
+      return drainQueue;
+   }
+   public synchronized void setDrainQueue(boolean drainQueue)
+   {
+      this.drainQueue = drainQueue;
+   }
+   public synchronized String getConnectionFactoryLookup()
+   {
+      return connectionFactoryLookup;
+   }
+   public synchronized void setConnectionFactoryLookup(String connectionFactoryLookup)
+   {
+      this.connectionFactoryLookup = connectionFactoryLookup;
+   }
+   public synchronized String getDestinationLookup()
+   {
+      return destinationLookup;
+   }
+   public synchronized void setDestinationLookup(String destinationLookup)
+   {
+      this.destinationLookup = destinationLookup;
+   }
+   public synchronized int getThrottleRate()
+   {
+      return throttleRate;
+   }
+   public synchronized void setThrottleRate(int throttleRate)
+   {
+      this.throttleRate = throttleRate;
+   }
+   public synchronized boolean isDisableMessageID()
+   {
+      return disableMessageID;
+   }
+   public synchronized void setDisableMessageID(boolean disableMessageID)
+   {
+      this.disableMessageID = disableMessageID;
+   }
+   public synchronized boolean isDisableTimestamp()
+   {
+      return disableTimestamp;
+   }
+   public synchronized void setDisableTimestamp(boolean disableTimestamp)
+   {
+      this.disableTimestamp = disableTimestamp;
+   }
+   public synchronized boolean isDupsOK()
+   {
+      return dupsOK;
+   }
+   public synchronized void setDupsOK(boolean dupsOK)
+   {
+      this.dupsOK = dupsOK;
+   }   
+     
+
+
+}

Added: trunk/examples/jms/perf/src/org/jboss/jms/example/PerfSender.java
===================================================================
--- trunk/examples/jms/perf/src/org/jboss/jms/example/PerfSender.java	                        (rev 0)
+++ trunk/examples/jms/perf/src/org/jboss/jms/example/PerfSender.java	2009-05-27 17:00:57 UTC (rev 7081)
@@ -0,0 +1,64 @@
+/*
+   * JBoss, Home of Professional Open Source
+   * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+   * 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.jms.example;
+
+import java.util.logging.Logger;
+
+/**
+ * 
+ * A PerfSender
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ *
+ */
+public class PerfSender extends PerfBase
+{
+   private static final Logger log = Logger.getLogger(PerfSender.class.getName());
+
+   public static void main(String[] args)
+   {
+      try
+      {
+         String fileName = PerfBase.getPerfFileName(args);
+         
+         PerfParams params = getParams(fileName);
+         
+         new PerfSender(params).run();
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+      }
+   }
+
+   private PerfSender(final PerfParams perfParams)
+   {
+      super(perfParams);
+   }
+
+   public void run() throws Exception
+   {
+      runSender();
+   }
+
+}




More information about the jboss-cvs-commits mailing list