activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r411650 - /incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/
Date Mon, 05 Jun 2006 03:22:13 GMT
Author: aco
Date: Sun Jun  4 20:22:12 2006
New Revision: 411650

URL: http://svn.apache.org/viewvc?rev=411650&view=rev
Log:
- Added JMS Client system test

Added:
    incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSystemSupport.java
    incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsConsumerSystem.java
    incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsProducerSystem.java
Modified:
    incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSupport.java
    incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsConsumerClient.java
    incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsFactorySupport.java
    incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsProducerClient.java
    incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/PerfMeasurementTool.java

Modified: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSupport.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSupport.java?rev=411650&r1=411649&r2=411650&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSupport.java
(original)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSupport.java
Sun Jun  4 20:22:12 2006
@@ -18,7 +18,6 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.activemq.ActiveMQConnectionFactory;
 
 import javax.jms.ConnectionFactory;
 import javax.jms.Session;

Added: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSystemSupport.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSystemSupport.java?rev=411650&view=auto
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSystemSupport.java
(added)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSystemSupport.java
Sun Jun  4 20:22:12 2006
@@ -0,0 +1,142 @@
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tool;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.Properties;
+import java.util.Iterator;
+
+public abstract class JmsClientSystemSupport {
+    private static final Log log = LogFactory.getLog(JmsClientSystemSupport.class);
+
+    public static final String PREFIX_CONFIG_SYSTEM_TEST = "sysTest.";
+
+    protected Properties sysTestSettings   = new Properties();
+    protected Properties samplerSettings   = new Properties();
+    protected Properties jmsClientSettings = new Properties();
+    protected ThreadGroup clientThreadGroup;
+    protected PerfMeasurementTool performanceSampler;
+
+    protected int numClients = 1;
+
+    public void runSystemTest() {
+        // Create a new copy of the settings to ensure immutability
+        final Properties clientSettings = getJmsClientSettings();
+
+        // Create performance sampler
+        performanceSampler = new PerfMeasurementTool();
+        performanceSampler.setSamplerSettings(samplerSettings);
+
+        clientThreadGroup = new ThreadGroup(getThreadGroupName());
+        for (int i=0; i<numClients; i++) {
+            final String clientName = getClientName() + i;
+            Thread t = new Thread(clientThreadGroup, new Runnable() {
+                public void run() {
+                    runJmsClient(clientName, clientSettings);
+                }
+            });
+            t.setName(getThreadName() + i);
+            t.start();
+        }
+
+        performanceSampler.startSampler();
+    }
+
+    public abstract void runJmsClient(String clientName, Properties clientSettings);
+
+    public String getClientName() {
+        return "JMS Client: ";
+    }
+
+    public String getThreadName() {
+        return "JMS Client Thread: ";
+    }
+
+    public String getThreadGroupName() {
+        return "JMS Clients Thread Group";
+    }
+
+    public PerfMeasurementTool getPerformanceSampler() {
+        return performanceSampler;
+    }
+
+    public void setPerformanceSampler(PerfMeasurementTool performanceSampler) {
+        this.performanceSampler = performanceSampler;
+    }
+
+    public Properties getSettings() {
+        Properties allSettings = new Properties();
+        allSettings.putAll(sysTestSettings);
+        allSettings.putAll(samplerSettings);
+        allSettings.putAll(jmsClientSettings);
+        return allSettings;
+    }
+
+    public void setSettings(Properties settings) {
+        for (Iterator i=settings.keySet().iterator(); i.hasNext();) {
+            String key = (String)i.next();
+            String val = settings.getProperty(key);
+            setProperty(key, val);
+        }
+        ReflectionUtil.configureClass(this, sysTestSettings);
+    }
+
+    public void setProperty(String key, String value) {
+        if (key.startsWith(PREFIX_CONFIG_SYSTEM_TEST)) {
+            sysTestSettings.setProperty(key, value);
+        } else if (key.startsWith(PerfMeasurementTool.PREFIX_CONFIG_SYSTEM_TEST)) {
+            samplerSettings.setProperty(key, value);
+        } else {
+            jmsClientSettings.setProperty(key, value);
+        }
+    }
+
+    public Properties getSysTestSettings() {
+        return sysTestSettings;
+    }
+
+    public void setSysTestSettings(Properties sysTestSettings) {
+        this.sysTestSettings = sysTestSettings;
+        ReflectionUtil.configureClass(this, sysTestSettings);
+    }
+
+    public Properties getSamplerSettings() {
+        return samplerSettings;
+    }
+
+    public void setSamplerSettings(Properties samplerSettings) {
+        this.samplerSettings = samplerSettings;
+    }
+
+    public Properties getJmsClientSettings() {
+        return jmsClientSettings;
+    }
+
+    public void setJmsClientSettings(Properties jmsClientSettings) {
+        this.jmsClientSettings = jmsClientSettings;
+    }
+
+    public int getNumClients() {
+        return numClients;
+    }
+
+    public void setNumClients(int numClients) {
+        this.numClients = numClients;
+    }
+}

Modified: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsConsumerClient.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsConsumerClient.java?rev=411650&r1=411649&r2=411650&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsConsumerClient.java
(original)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsConsumerClient.java
Sun Jun  4 20:22:12 2006
@@ -253,7 +253,7 @@
     }
 
     public static void main(String[] args) throws JMSException {
-        String[] options = new String[22];
+        String[] options = new String[21];
         options[0] = "-Dsampler.duration=60000";     // 1 min
         options[1] = "-Dsampler.interval=5000";      // 5 secs
         options[2] = "-Dsampler.rampUpTime=10000";   // 10 secs
@@ -273,12 +273,11 @@
         options[14] = "-Dconsumer.recvType=time";
 
         options[15] = "-Dfactory.brokerUrl=tcp://localhost:61616";
-        options[16] = "-Dfactory.clientID=consumerSampleClient";
-        options[17] = "-Dfactory.optimAck=true";
-        options[18] = "-Dfactory.optimDispatch=true";
-        options[19] = "-Dfactory.prefetchQueue=100";
-        options[20] = "-Dfactory.prefetchTopic=32767";
-        options[21] = "-Dfactory.useRetroactive=false";
+        options[16] = "-Dfactory.optimAck=true";
+        options[17] = "-Dfactory.optimDispatch=true";
+        options[18] = "-Dfactory.prefetchQueue=100";
+        options[19] = "-Dfactory.prefetchTopic=32767";
+        options[20] = "-Dfactory.useRetroactive=false";
 
         args = options;
 

Added: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsConsumerSystem.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsConsumerSystem.java?rev=411650&view=auto
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsConsumerSystem.java
(added)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsConsumerSystem.java
Sun Jun  4 20:22:12 2006
@@ -0,0 +1,101 @@
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tool;
+
+import javax.jms.JMSException;
+import java.util.Properties;
+
+public class JmsConsumerSystem extends JmsClientSystemSupport {
+    public void runJmsClient(String clientName, Properties clientSettings) {
+        PerfMeasurementTool sampler = getPerformanceSampler();
+
+        JmsConsumerClient consumer = new JmsConsumerClient();
+        consumer.setSettings(clientSettings);
+        consumer.setConsumerName(clientName); // For durable subscribers
+
+        if (sampler != null) {
+            sampler.registerClient(consumer);
+            consumer.setPerfEventListener(sampler);
+        }
+
+        try {
+            consumer.receiveMessages();
+        } catch (JMSException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public String getClientName() {
+        return "JMS Consumer: ";
+    }
+
+    public String getThreadName() {
+        return "JMS Consumer Thread: ";
+    }
+
+    public String getThreadGroupName() {
+        return "JMS Consumer Thread Group";
+    }
+
+    public static void main(String[] args) throws JMSException {
+        String[] options = new String[22];
+        options[0] = "-Dsampler.duration=60000";     // 1 min
+        options[1] = "-Dsampler.interval=5000";      // 5 secs
+        options[2] = "-Dsampler.rampUpTime=10000";   // 10 secs
+        options[3] = "-Dsampler.rampDownTime=10000"; // 10 secs
+
+        options[4] = "-Dclient.spiClass=org.apache.activemq.tool.spi.ActiveMQPojoSPI";
+        options[5] = "-Dclient.sessTransacted=false";
+        options[6] = "-Dclient.sessAckMode=autoAck";
+        options[7] = "-Dclient.destName=topic://FOO.BAR.TEST";
+        options[8] = "-Dclient.destCount=1";
+        options[9] = "-Dclient.destComposite=false";
+
+        options[10] = "-Dconsumer.durable=false";
+        options[11] = "-Dconsumer.asyncRecv=true";
+        options[12] = "-Dconsumer.recvCount=1000";     // 1000 messages
+        options[13] = "-Dconsumer.recvDuration=60000"; // 1 min
+        options[14] = "-Dconsumer.recvType=time";
+
+        options[15] = "-Dfactory.brokerUrl=tcp://localhost:61616";
+        options[16] = "-Dfactory.optimAck=true";
+        options[17] = "-Dfactory.optimDispatch=true";
+        options[18] = "-Dfactory.prefetchQueue=10";
+        options[19] = "-Dfactory.prefetchTopic=10";
+        options[20] = "-Dfactory.useRetroactive=false";
+
+        options[21] = "-DsysTest.numClients=5";
+
+        args = options;
+
+        Properties sysSettings  = new Properties();
+        for (int i=0; i<args.length; i++) {
+            // Get property define options only
+            if (args[i].startsWith("-D")) {
+                String propDefine = args[i].substring("-D".length());
+                int  index = propDefine.indexOf("=");
+                String key = propDefine.substring(0, index);
+                String val = propDefine.substring(index+1);
+                sysSettings.setProperty(key, val);
+            }
+        }
+
+        JmsConsumerSystem sysTest = new JmsConsumerSystem();
+        sysTest.setSettings(sysSettings);
+        sysTest.runSystemTest();
+    }
+}

Modified: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsFactorySupport.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsFactorySupport.java?rev=411650&r1=411649&r2=411650&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsFactorySupport.java
(original)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsFactorySupport.java
Sun Jun  4 20:22:12 2006
@@ -47,6 +47,7 @@
             log.debug("Created: " + jmsFactory.getClass().getName() + " using SPIConnectionFactory:
" + spiFactory.getClass().getName());
             return jmsFactory;
         } catch (Exception e) {
+            e.printStackTrace();
             throw new JMSException(e.getMessage());
         }
     }

Modified: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsProducerClient.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsProducerClient.java?rev=411650&r1=411649&r2=411650&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsProducerClient.java
(original)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsProducerClient.java
Sun Jun  4 20:22:12 2006
@@ -291,7 +291,7 @@
     }
 
     public static void main(String[] args) throws JMSException {
-        String[] options = new String[17];
+        String[] options = new String[16];
         options[0] = "-Dsampler.duration=60000";     // 1 min
         options[1] = "-Dsampler.interval=5000";      // 5 secs
         options[2] = "-Dsampler.rampUpTime=10000";   // 10 secs
@@ -310,8 +310,7 @@
         options[13] = "-Dproducer.sendType=time";
 
         options[14] = "-Dfactory.brokerUrl=tcp://localhost:61616";
-        options[15] = "-Dfactory.clientID=producerSampleClient";
-        options[16] = "-Dfactory.asyncSend=true";
+        options[15] = "-Dfactory.asyncSend=true";
 
         args = options;
 

Added: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsProducerSystem.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsProducerSystem.java?rev=411650&view=auto
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsProducerSystem.java
(added)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsProducerSystem.java
Sun Jun  4 20:22:12 2006
@@ -0,0 +1,97 @@
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tool;
+
+import javax.jms.JMSException;
+import java.util.Properties;
+
+public class JmsProducerSystem extends JmsClientSystemSupport {
+    public void runJmsClient(String clientName, Properties clientSettings) {
+        PerfMeasurementTool sampler = getPerformanceSampler();
+
+        JmsProducerClient producer = new JmsProducerClient();
+        producer.setSettings(clientSettings);
+
+        if (sampler != null) {
+            sampler.registerClient(producer);
+            producer.setPerfEventListener(sampler);
+        }
+
+        try {
+            producer.createJmsTextMessage();
+            producer.sendMessages();
+        } catch (JMSException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public String getClientName() {
+        return "JMS Producer: ";
+    }
+
+    public String getThreadName() {
+        return "JMS Producer Thread: ";
+    }
+
+    public String getThreadGroupName() {
+        return "JMS Producer Thread Group";
+    }
+
+    public static void main(String[] args) throws JMSException {
+        String[] options = new String[17];
+        options[0] = "-Dsampler.duration=60000";     // 1 min
+        options[1] = "-Dsampler.interval=5000";      // 5 secs
+        options[2] = "-Dsampler.rampUpTime=10000";   // 10 secs
+        options[3] = "-Dsampler.rampDownTime=10000"; // 10 secs
+
+        options[4] = "-Dclient.spiClass=org.apache.activemq.tool.spi.ActiveMQPojoSPI";
+        options[5] = "-Dclient.sessTransacted=false";
+        options[6] = "-Dclient.sessAckMode=autoAck";
+        options[7] = "-Dclient.destName=topic://FOO.BAR.TEST";
+        options[8] = "-Dclient.destCount=1";
+        options[9] = "-Dclient.destComposite=false";
+
+        options[10] = "-Dproducer.messageSize=1024";
+        options[11] = "-Dproducer.sendCount=1000";     // 1000 messages
+        options[12] = "-Dproducer.sendDuration=60000"; // 1 min
+        options[13] = "-Dproducer.sendType=time";
+
+        options[14] = "-Dfactory.brokerUrl=tcp://localhost:61616";
+        options[15] = "-Dfactory.asyncSend=true";
+
+        options[16] = "-DsysTest.numClients=5";
+
+        args = options;
+
+        Properties sysSettings  = new Properties();
+
+        for (int i=0; i<args.length; i++) {
+            // Get property define options only
+            if (args[i].startsWith("-D")) {
+                String propDefine = args[i].substring("-D".length());
+                int  index = propDefine.indexOf("=");
+                String key = propDefine.substring(0, index);
+                String val = propDefine.substring(index+1);
+                sysSettings.setProperty(key, val);
+            }
+        }
+
+        JmsProducerSystem sysTest = new JmsProducerSystem();
+        sysTest.setSettings(sysSettings);
+        sysTest.runSystemTest();
+    }
+}

Modified: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/PerfMeasurementTool.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/PerfMeasurementTool.java?rev=411650&r1=411649&r2=411650&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/PerfMeasurementTool.java
(original)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/PerfMeasurementTool.java
Sun Jun  4 20:22:12 2006
@@ -25,6 +25,8 @@
 import java.util.Properties;
 
 public class PerfMeasurementTool implements PerfEventListener, Runnable {
+    public static final String PREFIX_CONFIG_SYSTEM_TEST = "sampler.";
+
     private long duration     = 5 * 60 * 1000; // 5 mins by default test duration
     private long interval     = 1000;          // 1 sec sample interval
     private long rampUpTime   = 1 * 60 * 1000; // 1 min default test ramp up time



Mime
View raw message