[jboss-cvs] JBoss Messaging SVN: r7707 - in trunk: examples/soak and 9 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Aug 11 09:16:33 EDT 2009


Author: jmesnil
Date: 2009-08-11 09:16:33 -0400 (Tue, 11 Aug 2009)
New Revision: 7707

Added:
   trunk/examples/soak/reconnect/
   trunk/examples/soak/reconnect/build.xml
   trunk/examples/soak/reconnect/extra-libs/
   trunk/examples/soak/reconnect/jndi.properties
   trunk/examples/soak/reconnect/perf.properties
   trunk/examples/soak/reconnect/server0/
   trunk/examples/soak/reconnect/server0/jbm-configuration-messaging-lab.xml
   trunk/examples/soak/reconnect/server0/jbm-configuration.xml
   trunk/examples/soak/reconnect/server0/jbm-jboss-beans.xml
   trunk/examples/soak/reconnect/server0/jbm-jms.xml
   trunk/examples/soak/reconnect/src/
   trunk/examples/soak/reconnect/src/org/
   trunk/examples/soak/reconnect/src/org/jboss/
   trunk/examples/soak/reconnect/src/org/jboss/jms/
   trunk/examples/soak/reconnect/src/org/jboss/jms/soak/
   trunk/examples/soak/reconnect/src/org/jboss/jms/soak/example/
   trunk/examples/soak/reconnect/src/org/jboss/jms/soak/example/reconnect/
   trunk/examples/soak/reconnect/src/org/jboss/jms/soak/example/reconnect/ServerDump.java
   trunk/examples/soak/reconnect/src/org/jboss/jms/soak/example/reconnect/SoakBase.java
   trunk/examples/soak/reconnect/src/org/jboss/jms/soak/example/reconnect/SoakParams.java
   trunk/examples/soak/reconnect/src/org/jboss/jms/soak/example/reconnect/SoakReconnectableReceiver.java
   trunk/examples/soak/reconnect/src/org/jboss/jms/soak/example/reconnect/SoakReconnectableSender.java
Modified:
   trunk/.classpath
Log:
JBMESSAGING-1589: Soak tests

* added code for soaking reconnectable sender/receivers
* their JMS ConnectionFactory is configured to reconnect indefinitely to the single server (even
  when the server is cleanly shutdown)

Modified: trunk/.classpath
===================================================================
--- trunk/.classpath	2009-08-11 08:45:40 UTC (rev 7706)
+++ trunk/.classpath	2009-08-11 13:16:33 UTC (rev 7707)
@@ -87,6 +87,7 @@
 	<classpathentry kind="src" path="examples/javaee/servlet-transport/src"/>
 	<classpathentry kind="src" path="examples/javaee/xarecovery/src"/>
 	<classpathentry kind="src" path="examples/soak/normal/src"/>
+	<classpathentry kind="src" path="examples/soak/reconnect/src"/>
 	<classpathentry kind="lib" path="thirdparty/junit/lib/junit.jar"/>
 	<classpathentry kind="lib" path="thirdparty/apache-logging/lib/commons-logging.jar"/>
 	<classpathentry kind="lib" path="thirdparty/apache-xerces/lib/xercesImpl.jar"/>


Property changes on: trunk/examples/soak/reconnect
___________________________________________________________________
Name: svn:ignore
   + build
data


Added: trunk/examples/soak/reconnect/build.xml
===================================================================
--- trunk/examples/soak/reconnect/build.xml	                        (rev 0)
+++ trunk/examples/soak/reconnect/build.xml	2009-08-11 13:16:33 UTC (rev 7707)
@@ -0,0 +1,98 @@
+<?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 Soak Example">
+
+	<import file="../../common/build.xml" />
+
+	<path id="extra.classpath">
+		<path location="server0" />
+		<fileset dir="extra-libs">
+			<include name="*.jar" />
+		</fileset>
+	</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.soak.example.reconnect.SoakReconnectableSender" fork="true" resultproperty="example-result">
+			<jvmarg value="-Xms512M" />
+			<jvmarg value="-Xmx512M" />
+			<jvmarg value="-XX:+UseParallelGC" />
+			<jvmarg value="-XX:+AggressiveOpts" />
+			<jvmarg value="-Dcom.sun.management.jmxremote" />
+			<jvmarg value="-XX:+UseFastAccessorMethods" />
+			<!--
+                 <jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"/>
+             -->
+			<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="runReceiver" depends="compile">
+		<java classname="org.jboss.jms.soak.example.reconnect.SoakReconnectableReceiver" fork="true" resultproperty="example-result">
+			<jvmarg value="-Xms512M" />
+			<jvmarg value="-Xmx512M" />
+			<jvmarg value="-XX:+UseParallelGC" />
+			<jvmarg value="-XX:+AggressiveOpts" />
+			<jvmarg value="-Dcom.sun.management.jmxremote" />
+			<jvmarg value="-XX:+UseFastAccessorMethods" />
+			<!--
+                 <jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"/>
+             -->
+			<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" />
+			<jvmarg value="-Dcom.sun.management.jmxremote" />
+			<arg line="jbm-jboss-beans.xml" />
+			<classpath refid="extra.classpath" />
+			<classpath refid="server.classpath" />
+		</java>
+	</target>
+</project>

Added: trunk/examples/soak/reconnect/jndi.properties
===================================================================
--- trunk/examples/soak/reconnect/jndi.properties	                        (rev 0)
+++ trunk/examples/soak/reconnect/jndi.properties	2009-08-11 13:16:33 UTC (rev 7707)
@@ -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/soak/reconnect/perf.properties
===================================================================
--- trunk/examples/soak/reconnect/perf.properties	                        (rev 0)
+++ trunk/examples/soak/reconnect/perf.properties	2009-08-11 13:16:33 UTC (rev 7707)
@@ -0,0 +1,13 @@
+num-messages=200
+num-warmup-messages=100
+message-size=1024
+durable=true
+transacted=false
+batch-size=1000
+drain-queue=false
+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/soak/reconnect/server0/jbm-configuration-messaging-lab.xml
===================================================================
--- trunk/examples/soak/reconnect/server0/jbm-configuration-messaging-lab.xml	                        (rev 0)
+++ trunk/examples/soak/reconnect/server0/jbm-configuration-messaging-lab.xml	2009-08-11 13:16:33 UTC (rev 7707)
@@ -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/soak/reconnect/server0/jbm-configuration.xml
===================================================================
--- trunk/examples/soak/reconnect/server0/jbm-configuration.xml	                        (rev 0)
+++ trunk/examples/soak/reconnect/server0/jbm-configuration.xml	2009-08-11 13:16:33 UTC (rev 7707)
@@ -0,0 +1,36 @@
+<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>
+
+   <backup>false</backup>
+   
+   <security-enabled>false</security-enabled>
+   
+   <persistence-enabled>true</persistence-enabled>
+   
+   <queues>
+	   <queue name="perfQueue">
+	   	<address>perfAddress</address>
+	   </queue>
+   </queues>
+
+</configuration>

Added: trunk/examples/soak/reconnect/server0/jbm-jboss-beans.xml
===================================================================
--- trunk/examples/soak/reconnect/server0/jbm-jboss-beans.xml	                        (rev 0)
+++ trunk/examples/soak/reconnect/server0/jbm-jboss-beans.xml	2009-08-11 13:16:33 UTC (rev 7707)
@@ -0,0 +1,48 @@
+<?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">
+      <constructor>
+         <parameter>
+            <inject bean="Configuration"/>
+         </parameter>         
+      </constructor>
+      <start ignored="true"/>
+      <stop ignored="true"/>
+   </bean>
+
+   <!-- The JMS server -->
+   <bean name="JMSServerManager" class="org.jboss.messaging.jms.server.impl.JMSServerManagerImpl">
+      <constructor>
+         <parameter>
+            <inject bean="MessagingServer"/>
+         </parameter>
+      </constructor>
+   </bean>
+
+   <bean name="Dump" class="org.jboss.jms.soak.example.reconnect.ServerDump">
+      <constructor>
+         <!-- dump interval in minutes -->
+         <parameter>1</parameter>
+      </constructor>
+   </bean>
+   
+</deployment>

Added: trunk/examples/soak/reconnect/server0/jbm-jms.xml
===================================================================
--- trunk/examples/soak/reconnect/server0/jbm-jms.xml	                        (rev 0)
+++ trunk/examples/soak/reconnect/server0/jbm-jms.xml	2009-08-11 13:16:33 UTC (rev 7707)
@@ -0,0 +1,23 @@
+<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>
+	  <retry-interval>1000</retry-interval> 
+      <retry-interval-multiplier>1.0</retry-interval-multiplier> 
+      <reconnect-attempts>-1</reconnect-attempts> 
+      <failover-on-server-shutdown>true</failover-on-server-shutdown> 
+      <call-timeout>5000</call-timeout> 
+<block-on-non-persistent-send>true</block-on-non-persistent-send>
+<block-on-persistent-send>true</block-on-persistent-send>
+   </connection-factory>
+   
+   <queue name="perfQueue">
+      <entry name="perfQueue"/>
+   </queue>
+
+</configuration>

Added: trunk/examples/soak/reconnect/src/org/jboss/jms/soak/example/reconnect/ServerDump.java
===================================================================
--- trunk/examples/soak/reconnect/src/org/jboss/jms/soak/example/reconnect/ServerDump.java	                        (rev 0)
+++ trunk/examples/soak/reconnect/src/org/jboss/jms/soak/example/reconnect/ServerDump.java	2009-08-11 13:16:33 UTC (rev 7707)
@@ -0,0 +1,149 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, 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.soak.example.reconnect;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.MemoryMXBean;
+import java.lang.management.MemoryUsage;
+import java.lang.management.ThreadMXBean;
+import java.util.Date;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import javax.management.MBeanServerInvocationHandler;
+
+import org.jboss.messaging.core.management.MessagingServerControl;
+import org.jboss.messaging.core.management.ObjectNames;
+
+/**
+ * A MemoryDump
+ *
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ *
+ */
+public class ServerDump
+{
+   private final int dumpIntervalInMinutes;
+
+   private final TimerTask task;
+
+   private final Timer timer;
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public ServerDump(int dumpIntervalInHours)
+   {
+      this.dumpIntervalInMinutes = dumpIntervalInHours;
+      timer = new Timer(true);
+      task = new TimerTask()
+      {
+         @Override
+         public void run()
+         {
+            try
+            {
+               MemoryMXBean memory = ManagementFactory.getMemoryMXBean();
+               MemoryUsage heapMemory = memory.getHeapMemoryUsage();
+               MemoryUsage nonHeapMemory = memory.getHeapMemoryUsage();
+               ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
+               MessagingServerControl messagingServer = (MessagingServerControl)MBeanServerInvocationHandler.newProxyInstance(ManagementFactory.getPlatformMBeanServer(),
+                                                                                                                              ObjectNames.getMessagingServerObjectName(),
+                                                                                                                              MessagingServerControl.class,
+                                                                                                                              false);
+               System.out.println("**** Server Dump ****");
+               System.out.format("date:            %s\n", new Date());
+               System.out.format("heap memory:     used=%s, max=%s\n",
+                                 sizeof(heapMemory.getUsed()),
+                                 sizeof(heapMemory.getMax()));
+               System.out.format("non-heap memory: used=%s, max=%s\n",
+                                 sizeof(nonHeapMemory.getUsed()),
+                                 sizeof(nonHeapMemory.getMax()));
+               System.out.format("# of thread:     %d\n", threadMXBean.getThreadCount());
+               System.out.format("# of conns:      %d\n", messagingServer.getConnectionCount());
+               System.out.println("********************");
+            }
+            catch (Exception e)
+            {
+               // TODO Auto-generated catch block
+               e.printStackTrace();
+            }
+         }
+      };
+   }
+
+   // Public --------------------------------------------------------
+
+   public void start()
+   {
+      timer.scheduleAtFixedRate(task, 0, dumpIntervalInMinutes * 60 * 1000);
+   }
+
+   public void stop()
+   {
+      timer.cancel();
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   private static long oneKB = 1024;
+
+   private static long oneMB = oneKB * 1024;
+
+   private static long oneGB = oneMB * 1024;
+
+   public String sizeof(long size)
+   {
+      double s = Long.valueOf(size).doubleValue();
+      String suffix = "B";
+      if (s > oneGB)
+      {
+         s /= oneGB;
+         suffix = "GB";
+      }
+      else if (s > oneMB)
+      {
+         s /= oneMB;
+         suffix = "MB";
+      }
+      else if (s > oneKB)
+      {
+         s /= oneKB;
+         suffix = "kB";
+      }
+      return String.format("%.2f %s", s, suffix);
+   }
+
+   // Inner classes -------------------------------------------------
+
+}

Added: trunk/examples/soak/reconnect/src/org/jboss/jms/soak/example/reconnect/SoakBase.java
===================================================================
--- trunk/examples/soak/reconnect/src/org/jboss/jms/soak/example/reconnect/SoakBase.java	                        (rev 0)
+++ trunk/examples/soak/reconnect/src/org/jboss/jms/soak/example/reconnect/SoakBase.java	2009-08-11 13:16:33 UTC (rev 7707)
@@ -0,0 +1,142 @@
+/*
+   * 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.soak.example.reconnect;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.Properties;
+import java.util.Random;
+import java.util.logging.Logger;
+
+/**
+ * 
+ * A SoakBase
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ *
+ */
+public class SoakBase
+{
+   private static final Logger log = Logger.getLogger(SoakBase.class.getName());
+
+   private static final String DEFAULT_PERF_PROPERTIES_FILE_NAME = "perf.properties";
+
+   public static byte[] randomByteArray(final int length)
+   {
+      byte[] bytes = new byte[length];
+
+      Random random = new Random();
+
+      for (int i = 0; i < length; i++)
+      {
+         bytes[i] = Integer.valueOf(random.nextInt()).byteValue();
+      }
+
+      return bytes;
+   }
+
+   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 SoakParams 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);
+
+      SoakParams perfParams = new SoakParams();
+      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;
+   }
+}

Added: trunk/examples/soak/reconnect/src/org/jboss/jms/soak/example/reconnect/SoakParams.java
===================================================================
--- trunk/examples/soak/reconnect/src/org/jboss/jms/soak/example/reconnect/SoakParams.java	                        (rev 0)
+++ trunk/examples/soak/reconnect/src/org/jboss/jms/soak/example/reconnect/SoakParams.java	2009-08-11 13:16:33 UTC (rev 7707)
@@ -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.soak.example.reconnect;
+
+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 SoakParams 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/soak/reconnect/src/org/jboss/jms/soak/example/reconnect/SoakReconnectableReceiver.java
===================================================================
--- trunk/examples/soak/reconnect/src/org/jboss/jms/soak/example/reconnect/SoakReconnectableReceiver.java	                        (rev 0)
+++ trunk/examples/soak/reconnect/src/org/jboss/jms/soak/example/reconnect/SoakReconnectableReceiver.java	2009-08-11 13:16:33 UTC (rev 7707)
@@ -0,0 +1,178 @@
+/*
+   * 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.soak.example.reconnect;
+
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.logging.Logger;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.Session;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+public class SoakReconnectableReceiver
+{
+   private static final Logger log = Logger.getLogger(SoakReconnectableReceiver.class.getName());
+
+   public static void main(String[] args)
+   {
+      try
+      {
+         String fileName = SoakBase.getPerfFileName(args);
+
+         SoakParams params = SoakBase.getParams(fileName);
+
+         final SoakReconnectableReceiver receiver = new SoakReconnectableReceiver(params);
+
+         Runtime.getRuntime().addShutdownHook(new Thread()
+         {
+            @Override
+            public void run()
+            {
+               receiver.disconnect();
+            }
+         });
+
+         receiver.run();
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+      }
+   }
+
+   private SoakParams perfParams;
+
+   private Destination destination;
+
+   private Connection connection;
+
+   private ExceptionListener exceptionListener = new ExceptionListener()
+   {
+      public void onException(JMSException e)
+      {
+         disconnect();
+         connect();
+      }
+   };
+
+   private MessageListener listener = new MessageListener()
+   {
+      int modulo = 10000;
+
+      private final AtomicLong count = new AtomicLong(0);
+
+      private long start = System.currentTimeMillis();
+
+      public void onMessage(Message msg)
+      {
+         if (count.incrementAndGet() % modulo == 0)
+         {
+            double duration = (1.0 * System.currentTimeMillis() - start) / 1000;
+            start = System.currentTimeMillis();
+            log.info(String.format("received %s messages in %2.2fs", modulo, duration));
+         }
+      }
+   };
+
+   private SoakReconnectableReceiver(final SoakParams perfParams)
+   {
+      this.perfParams = perfParams;
+   }
+
+   public void run() throws Exception
+   {
+      connect();
+
+      while (true)
+      {
+         Thread.sleep(500);
+      }
+   }
+
+   private void disconnect()
+   {
+      if (connection != null)
+      {
+         try
+         {
+            connection.setExceptionListener(null);
+            connection.close();
+         }
+         catch (JMSException e)
+         {
+            e.printStackTrace();
+         }
+         finally
+         {
+            connection = null;
+         }
+      }
+   }
+
+   private void connect()
+   {
+      InitialContext ic = null;
+      try
+      {
+         ic = new InitialContext();
+
+         ConnectionFactory factory = (ConnectionFactory)ic.lookup(perfParams.getConnectionFactoryLookup());
+
+         destination = (Destination)ic.lookup(perfParams.getDestinationLookup());
+
+         connection = factory.createConnection();
+         connection.setExceptionListener(exceptionListener);
+
+         Session session = connection.createSession(perfParams.isSessionTransacted(),
+                                                    perfParams.isDupsOK() ? Session.DUPS_OK_ACKNOWLEDGE
+                                                                         : Session.AUTO_ACKNOWLEDGE);
+
+         MessageConsumer messageConsumer = session.createConsumer(destination);
+         messageConsumer.setMessageListener(listener);
+
+         connection.start();
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+      }
+      finally
+      {
+         try
+         {
+            ic.close();
+         }
+         catch (NamingException e)
+         {
+            e.printStackTrace();
+         }
+      }
+   }
+}
\ No newline at end of file

Added: trunk/examples/soak/reconnect/src/org/jboss/jms/soak/example/reconnect/SoakReconnectableSender.java
===================================================================
--- trunk/examples/soak/reconnect/src/org/jboss/jms/soak/example/reconnect/SoakReconnectableSender.java	                        (rev 0)
+++ trunk/examples/soak/reconnect/src/org/jboss/jms/soak/example/reconnect/SoakReconnectableSender.java	2009-08-11 13:16:33 UTC (rev 7707)
@@ -0,0 +1,222 @@
+/*
+   * 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.soak.example.reconnect;
+
+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.ExceptionListener;
+import javax.jms.JMSException;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.messaging.utils.TokenBucketLimiter;
+import org.jboss.messaging.utils.TokenBucketLimiterImpl;
+
+public class SoakReconnectableSender
+{
+   private static final Logger log = Logger.getLogger(SoakReconnectableSender.class.getName());
+
+   public static void main(String[] args)
+   {
+      try
+      {
+         String fileName = SoakBase.getPerfFileName(args);
+
+         SoakParams params = SoakBase.getParams(fileName);
+
+         final SoakReconnectableSender sender = new SoakReconnectableSender(params);
+
+         Runtime.getRuntime().addShutdownHook(new Thread()
+         {
+            @Override
+            public void run()
+            {
+               sender.disconnect();
+            }
+         });
+
+         sender.run();
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+      }
+   }
+
+   private SoakParams perfParams;
+
+   private Destination destination;
+
+   private Connection connection;
+
+   private Session session;
+
+   private MessageProducer producer;
+
+   private ExceptionListener exceptionListener = new ExceptionListener()
+   {
+      public void onException(JMSException e)
+      {
+         System.out.println("SoakReconnectableSender.exceptionListener.new ExceptionListener() {...}.onException()");
+         disconnect();
+         connect();
+      }
+
+   };
+
+   private SoakReconnectableSender(final SoakParams perfParams)
+   {
+      this.perfParams = perfParams;
+   }
+
+   public void run() throws Exception
+   {
+      System.out.println("SoakReconnectableSender.run()");
+      connect();
+
+      BytesMessage message = session.createBytesMessage();
+
+      byte[] payload = SoakBase.randomByteArray(perfParams.getMessageSize());
+
+      message.writeBytes(payload);
+
+      final int modulo = 10000;
+
+      TokenBucketLimiter tbl = perfParams.getThrottleRate() != -1 ? new TokenBucketLimiterImpl(perfParams.getThrottleRate(),
+                                                                                               false)
+                                                                 : null;
+
+      boolean transacted = perfParams.isSessionTransacted();
+      int txBatchSize = perfParams.getBatchSize();
+      boolean display = true;
+
+      long start = System.currentTimeMillis();
+      AtomicLong count = new AtomicLong(0);
+      while (true)
+      {
+         try
+         {
+            while (true)
+            {
+               producer.send(message);
+               count.incrementAndGet();
+
+               if (transacted)
+               {
+                  if (count.longValue() % txBatchSize == 0)
+                  {
+                     session.commit();
+                  }
+               }
+
+               if (display && (count.longValue() % modulo == 0))
+               {
+                  double duration = (1.0 * System.currentTimeMillis() - start) / 1000;
+                  start = System.currentTimeMillis();
+                  log.info(String.format("sent %s messages in %2.2fs", modulo, duration));
+               }
+
+               if (tbl != null)
+               {
+                  tbl.limit();
+               }
+            }
+         }
+         catch (Exception e)
+         {
+            e.printStackTrace();
+         }
+      }
+   }
+
+   private synchronized void disconnect()
+   {
+      if (connection != null)
+      {
+         try
+         {
+            connection.setExceptionListener(null);
+            connection.close();
+         }
+         catch (JMSException e)
+         {
+            e.printStackTrace();
+         }
+         finally
+         {
+            connection = null;
+         }
+      }
+   }
+
+   private void connect()
+   {
+      InitialContext ic = null;
+      try
+      {
+         ic = new InitialContext();
+
+         ConnectionFactory 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);
+
+         producer = session.createProducer(destination);
+
+         producer.setDeliveryMode(perfParams.isDurable() ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
+
+         producer.setDisableMessageID(perfParams.isDisableMessageID());
+
+         producer.setDisableMessageTimestamp(perfParams.isDisableTimestamp());
+
+         connection.setExceptionListener(exceptionListener);
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+      }
+      finally
+      {
+         try
+         {
+            ic.close();
+         }
+         catch (NamingException e)
+         {
+            e.printStackTrace();
+         }
+      }
+   }
+}
\ No newline at end of file




More information about the jboss-cvs-commits mailing list