activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r419366 [3/7] - in /incubator/activemq/trunk: activeio/activeio-core/src/main/java/org/apache/activeio/journal/active/ activemq-core/src/main/java/org/apache/activemq/broker/ activemq-core/src/main/java/org/apache/activemq/command/ activemq...
Date Wed, 05 Jul 2006 22:30:26 GMT
Modified: incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/tool/ReportGenerator.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/tool/ReportGenerator.java?rev=419366&r1=419365&r2=419366&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/tool/ReportGenerator.java (original)
+++ incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/tool/ReportGenerator.java Wed Jul  5 15:30:19 2006
@@ -1,159 +1,159 @@
-/**
- *
- * 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.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Enumeration;
-import java.util.Properties;
-
-public class ReportGenerator {
-    private static final Log log = LogFactory.getLog(ReportGenerator.class);
-    private String reportDirectory = null;
-    private String reportName = null;
-    private PrintWriter writer = null;
-    private File reportFile = null;
-    private Properties testSettings;
-
-    public ReportGenerator() {
-    }
-
-    public ReportGenerator(String reportDirectory, String reportName) {
-        this.setReportDirectory(reportDirectory);
-        this.setReportName(reportName);
-    }
-
-    public void startGenerateReport() {
-
-
-        File reportDir = new File(getReportDirectory());
-
-        // Create output directory if it doesn't exist.
-        if (!reportDir.exists()) {
-            reportDir.mkdirs();
-        }
-
-
-        if (reportDir != null) {
-            reportFile = new File(this.getReportDirectory() + File.separator + this.getReportName() + ".xml");
-        }
-
-        try {
-            this.writer = new PrintWriter(new FileOutputStream(reportFile));
-        } catch (IOException e1) {
-            e1.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-        }
-    }
-
-    public void stopGenerateReport() {
-        writeWithIndent(0, "</test-report>");
-        this.getWriter().flush();
-        this.getWriter().close();
-        log.info(" TEST REPORT OUTPUT : " + reportFile.getAbsolutePath());
-
-
-    }
-
-    protected void addTestInformation() {
-
-        writeWithIndent(0, "<test-report>");
-        writeWithIndent(2, "<test-information>");
-
-        writeWithIndent(4, "<os-name>" + System.getProperty("os.name") + "</os-name>");
-        writeWithIndent(4, "<java-version>" + System.getProperty("java.version") + "</java-version>");
-
-    }
-
-
-    protected void addClientSettings() {
-        if (this.getTestSettings() != null) {
-            Enumeration keys = getTestSettings().propertyNames();
-
-            writeWithIndent(4, "<test-settings>");
-
-            String key;
-            while (keys.hasMoreElements()) {
-                key = (String) keys.nextElement();
-                writeWithIndent(6, "<" + key + ">" + getTestSettings().get(key) + "</" + key + ">");
-            }
-
-            writeWithIndent(4, "</test-settings>");
-        }
-    }
-
-    protected void endTestInformation() {
-        writeWithIndent(2, "</test-information>");
-
-    }
-
-    protected void startTestResult(long checkpointInterval) {
-        long intervalInSec = checkpointInterval / 1000;
-        writeWithIndent(2, "<test-result checkpoint_interval_in_sec=" + intervalInSec + " >");
-    }
-
-    protected void endTestResult() {
-        writeWithIndent(2, "</test-result>");
-    }
-
-
-    protected void writeWithIndent(int indent, String result) {
-        StringBuffer buffer = new StringBuffer();
-
-        for (int i = 0; i < indent; ++i) {
-            buffer.append(" ");
-        }
-
-        buffer.append(result);
-        writer.println(buffer.toString());
-    }
-
-    public PrintWriter getWriter() {
-        return this.writer;
-    }
-
-
-    public String getReportDirectory() {
-        return reportDirectory;
-    }
-
-    public void setReportDirectory(String reportDirectory) {
-        this.reportDirectory = reportDirectory;
-    }
-
-    public String getReportName() {
-        return reportName;
-    }
-
-
-    public void setReportName(String reportName) {
-        this.reportName = reportName;
-    }
-
-    public Properties getTestSettings() {
-        return testSettings;
-    }
-
-    public void setTestSettings(Properties testSettings) {
-        this.testSettings = testSettings;
-    }
-}
+/**
+ *
+ * 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.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Enumeration;
+import java.util.Properties;
+
+public class ReportGenerator {
+    private static final Log log = LogFactory.getLog(ReportGenerator.class);
+    private String reportDirectory = null;
+    private String reportName = null;
+    private PrintWriter writer = null;
+    private File reportFile = null;
+    private Properties testSettings;
+
+    public ReportGenerator() {
+    }
+
+    public ReportGenerator(String reportDirectory, String reportName) {
+        this.setReportDirectory(reportDirectory);
+        this.setReportName(reportName);
+    }
+
+    public void startGenerateReport() {
+
+
+        File reportDir = new File(getReportDirectory());
+
+        // Create output directory if it doesn't exist.
+        if (!reportDir.exists()) {
+            reportDir.mkdirs();
+        }
+
+
+        if (reportDir != null) {
+            reportFile = new File(this.getReportDirectory() + File.separator + this.getReportName() + ".xml");
+        }
+
+        try {
+            this.writer = new PrintWriter(new FileOutputStream(reportFile));
+        } catch (IOException e1) {
+            e1.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
+    }
+
+    public void stopGenerateReport() {
+        writeWithIndent(0, "</test-report>");
+        this.getWriter().flush();
+        this.getWriter().close();
+        log.info(" TEST REPORT OUTPUT : " + reportFile.getAbsolutePath());
+
+
+    }
+
+    protected void addTestInformation() {
+
+        writeWithIndent(0, "<test-report>");
+        writeWithIndent(2, "<test-information>");
+
+        writeWithIndent(4, "<os-name>" + System.getProperty("os.name") + "</os-name>");
+        writeWithIndent(4, "<java-version>" + System.getProperty("java.version") + "</java-version>");
+
+    }
+
+
+    protected void addClientSettings() {
+        if (this.getTestSettings() != null) {
+            Enumeration keys = getTestSettings().propertyNames();
+
+            writeWithIndent(4, "<test-settings>");
+
+            String key;
+            while (keys.hasMoreElements()) {
+                key = (String) keys.nextElement();
+                writeWithIndent(6, "<" + key + ">" + getTestSettings().get(key) + "</" + key + ">");
+            }
+
+            writeWithIndent(4, "</test-settings>");
+        }
+    }
+
+    protected void endTestInformation() {
+        writeWithIndent(2, "</test-information>");
+
+    }
+
+    protected void startTestResult(long checkpointInterval) {
+        long intervalInSec = checkpointInterval / 1000;
+        writeWithIndent(2, "<test-result checkpoint_interval_in_sec=" + intervalInSec + " >");
+    }
+
+    protected void endTestResult() {
+        writeWithIndent(2, "</test-result>");
+    }
+
+
+    protected void writeWithIndent(int indent, String result) {
+        StringBuffer buffer = new StringBuffer();
+
+        for (int i = 0; i < indent; ++i) {
+            buffer.append(" ");
+        }
+
+        buffer.append(result);
+        writer.println(buffer.toString());
+    }
+
+    public PrintWriter getWriter() {
+        return this.writer;
+    }
+
+
+    public String getReportDirectory() {
+        return reportDirectory;
+    }
+
+    public void setReportDirectory(String reportDirectory) {
+        this.reportDirectory = reportDirectory;
+    }
+
+    public String getReportName() {
+        return reportName;
+    }
+
+
+    public void setReportName(String reportName) {
+        this.reportName = reportName;
+    }
+
+    public Properties getTestSettings() {
+        return testSettings;
+    }
+
+    public void setTestSettings(Properties testSettings) {
+        this.testSettings = testSettings;
+    }
+}

Propchange: incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/tool/ReportGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/maven/ConsumerMojo.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/maven/ConsumerMojo.java?rev=419366&r1=419365&r2=419366&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/maven/ConsumerMojo.java (original)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/maven/ConsumerMojo.java Wed Jul  5 15:30:19 2006
@@ -1,72 +1,72 @@
-/**
- *
- * 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.maven;
-
-import org.apache.activemq.tool.JmsConsumerSystem;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-
-import java.util.Properties;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Set;
-import java.util.HashSet;
-
-/**
- * Goal which touches a timestamp file.
- *
- * @goal consumer
- * @phase process-sources
- */
-public class ConsumerMojo extends AbstractMojo {
-
-    private String[] validPrefix = {
-        "sysTest.",
-        "factory.",
-        "consumer.",
-        "tpSampler.",
-        "cpuSampler."
-    };
-
-    public void execute() throws MojoExecutionException {
-        JmsConsumerSystem.main(createArgument());
-    }
-
-    protected String[] createArgument() {
-        List args = new ArrayList();
-        Properties sysProps = System.getProperties();
-        Set keys = new HashSet(sysProps.keySet());
-
-        for (Iterator i=keys.iterator(); i.hasNext();) {
-            String key = (String)i.next();
-            if (isRecognizedProperty(key)) {
-                args.add(key + "=" + sysProps.remove(key));
-            }
-        }
-        return (String[])args.toArray(new String[0]);
-    }
-
-    protected boolean isRecognizedProperty(String key) {
-        for (int j=0; j<validPrefix.length; j++) {
-            if (key.startsWith(validPrefix[j])) {
-                return true;
-            }
-        }
-        return false;
-    }
-}
+/**
+ *
+ * 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.maven;
+
+import org.apache.activemq.tool.JmsConsumerSystem;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import java.util.Properties;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * Goal which touches a timestamp file.
+ *
+ * @goal consumer
+ * @phase process-sources
+ */
+public class ConsumerMojo extends AbstractMojo {
+
+    private String[] validPrefix = {
+        "sysTest.",
+        "factory.",
+        "consumer.",
+        "tpSampler.",
+        "cpuSampler."
+    };
+
+    public void execute() throws MojoExecutionException {
+        JmsConsumerSystem.main(createArgument());
+    }
+
+    protected String[] createArgument() {
+        List args = new ArrayList();
+        Properties sysProps = System.getProperties();
+        Set keys = new HashSet(sysProps.keySet());
+
+        for (Iterator i=keys.iterator(); i.hasNext();) {
+            String key = (String)i.next();
+            if (isRecognizedProperty(key)) {
+                args.add(key + "=" + sysProps.remove(key));
+            }
+        }
+        return (String[])args.toArray(new String[0]);
+    }
+
+    protected boolean isRecognizedProperty(String key) {
+        for (int j=0; j<validPrefix.length; j++) {
+            if (key.startsWith(validPrefix[j])) {
+                return true;
+            }
+        }
+        return false;
+    }
+}

Propchange: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/maven/ConsumerMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/maven/ProducerMojo.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/maven/ProducerMojo.java?rev=419366&r1=419365&r2=419366&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/maven/ProducerMojo.java (original)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/maven/ProducerMojo.java Wed Jul  5 15:30:19 2006
@@ -1,72 +1,72 @@
-/**
- *
- * 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.maven;
-
-import org.apache.activemq.tool.JmsProducerSystem;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Properties;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.HashSet;
-
-/**
- * Goal which touches a timestamp file.
- *
- * @goal producer
- * @phase process
- */
-public class ProducerMojo extends AbstractMojo {
-
-    private String[] validPrefix = {
-        "sysTest.",
-        "factory.",
-        "producer.",
-        "tpSampler.",
-        "cpuSampler."
-    };
-
-    public void execute() throws MojoExecutionException {
-        JmsProducerSystem.main(createArgument());
-    }
-
-    protected String[] createArgument() {
-        List args = new ArrayList();
-        Properties sysProps = System.getProperties();
-        Set keys = new HashSet(sysProps.keySet());
-
-        for (Iterator i=keys.iterator(); i.hasNext();) {
-            String key = (String)i.next();
-            if (isRecognizedProperty(key)) {
-                args.add(key + "=" + sysProps.remove(key));
-            }
-        }
-        return (String[])args.toArray(new String[0]);
-    }
-
-    protected boolean isRecognizedProperty(String key) {
-        for (int j=0; j<validPrefix.length; j++) {
-            if (key.startsWith(validPrefix[j])) {
-                return true;
-            }
-        }
-        return false;
-    }
-}
+/**
+ *
+ * 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.maven;
+
+import org.apache.activemq.tool.JmsProducerSystem;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Properties;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * Goal which touches a timestamp file.
+ *
+ * @goal producer
+ * @phase process
+ */
+public class ProducerMojo extends AbstractMojo {
+
+    private String[] validPrefix = {
+        "sysTest.",
+        "factory.",
+        "producer.",
+        "tpSampler.",
+        "cpuSampler."
+    };
+
+    public void execute() throws MojoExecutionException {
+        JmsProducerSystem.main(createArgument());
+    }
+
+    protected String[] createArgument() {
+        List args = new ArrayList();
+        Properties sysProps = System.getProperties();
+        Set keys = new HashSet(sysProps.keySet());
+
+        for (Iterator i=keys.iterator(); i.hasNext();) {
+            String key = (String)i.next();
+            if (isRecognizedProperty(key)) {
+                args.add(key + "=" + sysProps.remove(key));
+            }
+        }
+        return (String[])args.toArray(new String[0]);
+    }
+
+    protected boolean isRecognizedProperty(String key) {
+        for (int j=0; j<validPrefix.length; j++) {
+            if (key.startsWith(validPrefix[j])) {
+                return true;
+            }
+        }
+        return false;
+    }
+}

Propchange: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/maven/ProducerMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/maven/ServerMojo.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/maven/ServerMojo.java?rev=419366&r1=419365&r2=419366&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/maven/ServerMojo.java (original)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/maven/ServerMojo.java Wed Jul  5 15:30:19 2006
@@ -1,139 +1,139 @@
-/**
- *
- * 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.maven;
-
-import org.apache.activemq.console.Main;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.nio.MappedByteBuffer;
-import java.nio.channels.FileChannel;
-
-/**
- * Goal which starts activemq broker.
- *
- * @goal broker
- * @phase process-sources
- */
-public class ServerMojo extends AbstractMojo {
-    /**
-     * Location of the output directory. Defaults to target.
-     *
-     * @parameter expression="${project.build.directory}"
-     * @required
-     */
-    private File outputDirectory;
-
-    /**
-     * Location of the predefined config files.
-     *
-     * @parameter expression="${configDirectory}" default-value="${basedir}/src/main/resources/broker-conf"
-     * @required
-     */
-    private String configDirectory;
-
-    /**
-     * Type of activemq configuration to use. This is also the filename used.
-     *
-     * @parameter expression="${configType}" default-value="activemq"
-     * @required
-     */
-    private String configType;
-
-    /**
-     * Location of activemq config file other those found in resources/config.
-     *
-     * @parameter expression="${configFile}"
-     */
-    private File configFile;
-
-    /**
-     * Broker URL.
-     *
-     * @parameter expression="${url}"
-     */
-    private String url;
-
-    public void execute()
-            throws MojoExecutionException {
-
-        File out = outputDirectory;
-
-        // Create output directory if it doesn't exist.
-        if (!out.exists()) {
-            out.mkdirs();
-        }
-
-        String[] args = new String[2];
-        if (url != null) {
-           args[0] = "start";
-           args[1] = url;
-        } else {
-            File config;
-            if (configFile != null) {
-                config = configFile;
-            } else {
-
-                config = new File(configDirectory + File.separator + configType + ".xml");
-            }
-
-            try {
-                config = copy(config);
-            } catch (IOException e) {
-                throw new MojoExecutionException(e.getMessage());
-            }
-           args[0] = "start";
-           args[1] =  "xbean:" + (config.toURI()).toString();
-        }
-
-
-        Main.main(args);
-    }
-
-    /**
-     * Copy activemq configuration file to output directory.
-     *
-     * @param source
-     * @return
-     * @throws IOException
-     */
-    public File copy(File source) throws IOException {
-        FileChannel in = null, out = null;
-
-        File dest = new File(outputDirectory.getAbsolutePath() + File.separator + "activemq.xml");
-
-        try {
-            in = new FileInputStream(source).getChannel();
-            out = new FileOutputStream(dest).getChannel();
-
-            long size = in.size();
-            MappedByteBuffer buf = in.map(FileChannel.MapMode.READ_ONLY, 0, size);
-
-            out.write(buf);
-
-        } finally {
-            if (in != null) in.close();
-            if (out != null) out.close();
-        }
-
-        return dest;
-    }
+/**
+ *
+ * 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.maven;
+
+import org.apache.activemq.console.Main;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.MappedByteBuffer;
+import java.nio.channels.FileChannel;
+
+/**
+ * Goal which starts activemq broker.
+ *
+ * @goal broker
+ * @phase process-sources
+ */
+public class ServerMojo extends AbstractMojo {
+    /**
+     * Location of the output directory. Defaults to target.
+     *
+     * @parameter expression="${project.build.directory}"
+     * @required
+     */
+    private File outputDirectory;
+
+    /**
+     * Location of the predefined config files.
+     *
+     * @parameter expression="${configDirectory}" default-value="${basedir}/src/main/resources/broker-conf"
+     * @required
+     */
+    private String configDirectory;
+
+    /**
+     * Type of activemq configuration to use. This is also the filename used.
+     *
+     * @parameter expression="${configType}" default-value="activemq"
+     * @required
+     */
+    private String configType;
+
+    /**
+     * Location of activemq config file other those found in resources/config.
+     *
+     * @parameter expression="${configFile}"
+     */
+    private File configFile;
+
+    /**
+     * Broker URL.
+     *
+     * @parameter expression="${url}"
+     */
+    private String url;
+
+    public void execute()
+            throws MojoExecutionException {
+
+        File out = outputDirectory;
+
+        // Create output directory if it doesn't exist.
+        if (!out.exists()) {
+            out.mkdirs();
+        }
+
+        String[] args = new String[2];
+        if (url != null) {
+           args[0] = "start";
+           args[1] = url;
+        } else {
+            File config;
+            if (configFile != null) {
+                config = configFile;
+            } else {
+
+                config = new File(configDirectory + File.separator + configType + ".xml");
+            }
+
+            try {
+                config = copy(config);
+            } catch (IOException e) {
+                throw new MojoExecutionException(e.getMessage());
+            }
+           args[0] = "start";
+           args[1] =  "xbean:" + (config.toURI()).toString();
+        }
+
+
+        Main.main(args);
+    }
+
+    /**
+     * Copy activemq configuration file to output directory.
+     *
+     * @param source
+     * @return
+     * @throws IOException
+     */
+    public File copy(File source) throws IOException {
+        FileChannel in = null, out = null;
+
+        File dest = new File(outputDirectory.getAbsolutePath() + File.separator + "activemq.xml");
+
+        try {
+            in = new FileInputStream(source).getChannel();
+            out = new FileOutputStream(dest).getChannel();
+
+            long size = in.size();
+            MappedByteBuffer buf = in.map(FileChannel.MapMode.READ_ONLY, 0, size);
+
+            out.write(buf);
+
+        } finally {
+            if (in != null) in.close();
+            if (out != null) out.close();
+        }
+
+        return dest;
+    }
 }

Propchange: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/maven/ServerMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/AbstractJmsClient.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/AbstractJmsClient.java?rev=419366&r1=419365&r2=419366&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/AbstractJmsClient.java (original)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/AbstractJmsClient.java Wed Jul  5 15:30:19 2006
@@ -1,157 +1,157 @@
-/**
- *
- * 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.activemq.tool.properties.JmsClientProperties;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.jms.ConnectionFactory;
-import javax.jms.Connection;
-import javax.jms.Session;
-import javax.jms.JMSException;
-import javax.jms.Destination;
-import java.util.Enumeration;
-
-public abstract class AbstractJmsClient {
-    private static final Log log = LogFactory.getLog(AbstractJmsClient.class);
-
-    protected ConnectionFactory factory;
-    protected Connection jmsConnection;
-    protected Session jmsSession;
-
-    protected int destCount = 1, destIndex = 0;
-    protected String clientName = "";
-
-    public AbstractJmsClient(ConnectionFactory factory) {
-        this.factory = factory;
-    }
-
-    abstract public JmsClientProperties getClient();
-    abstract public void setClient(JmsClientProperties client);
-
-    public ConnectionFactory getFactory() {
-        return factory;
-    }
-
-    public void setFactory(ConnectionFactory factory) {
-        this.factory = factory;
-    }
-
-    public int getDestCount() {
-        return destCount;
-    }
-
-    public void setDestCount(int destCount) {
-        this.destCount = destCount;
-    }
-
-    public int getDestIndex() {
-        return destIndex;
-    }
-
-    public void setDestIndex(int destIndex) {
-        this.destIndex = destIndex;
-    }
-
-    public String getClientName() {
-        return clientName;
-    }
-
-    public void setClientName(String clientName) {
-        this.clientName = clientName;
-    }
-
-    public Connection getConnection() throws JMSException {
-        if (jmsConnection == null) {
-            jmsConnection = factory.createConnection();
-            jmsConnection.setClientID(getClientName());
-            log.info("Creating JMS Connection: Provider=" + getClient().getJmsProvider() + ", JMS Spec=" + getClient().getJmsVersion());
-        }
-        return jmsConnection;
-    }
-
-    public Session getSession() throws JMSException {
-        if (jmsSession == null) {
-            int ackMode;
-            if (getClient().getSessAckMode().equalsIgnoreCase(JmsClientProperties.SESSION_AUTO_ACKNOWLEDGE)) {
-                ackMode = Session.AUTO_ACKNOWLEDGE;
-            } else if (getClient().getSessAckMode().equalsIgnoreCase(JmsClientProperties.SESSION_CLIENT_ACKNOWLEDGE)) {
-                ackMode = Session.CLIENT_ACKNOWLEDGE;
-            } else if (getClient().getSessAckMode().equalsIgnoreCase(JmsClientProperties.SESSION_DUPS_OK_ACKNOWLEDGE)) {
-                ackMode = Session.DUPS_OK_ACKNOWLEDGE;
-            } else if (getClient().getSessAckMode().equalsIgnoreCase(JmsClientProperties.SESSION_TRANSACTED)) {
-                ackMode = Session.SESSION_TRANSACTED;
-            } else {
-                ackMode = Session.AUTO_ACKNOWLEDGE;
-            }
-            jmsSession = getConnection().createSession(getClient().isSessTransacted(), ackMode);
-        }
-        return jmsSession;
-    }
-
-    public Destination[] createDestination(int destIndex, int destCount) throws JMSException {
-
-        if (getClient().isDestComposite()) {
-            return new Destination[] {createCompositeDestination(getClient().getDestName(), destIndex, destCount)};
-        } else {
-            Destination[] dest = new Destination[destCount];
-            for (int i=0; i<destCount; i++) {
-                dest[i] = createDestination(getClient().getDestName() + "." + (destIndex + i));
-            }
-
-            return dest;
-        }
-    }
-
-    public Destination createCompositeDestination(int destIndex, int destCount) throws JMSException {
-        return createCompositeDestination(getClient().getDestName(), destIndex, destCount);
-    }
-
-    protected Destination createCompositeDestination(String name, int destIndex, int destCount) throws JMSException {
-        String compDestName;
-        String simpleName;
-
-        if (name.startsWith("queue://")) {
-            simpleName = name.substring("queue://".length());
-        } else if (name.startsWith("topic://")) {
-            simpleName = name.substring("topic://".length());
-        } else {
-            simpleName = name;
-        }
-
-        int i;
-        compDestName = name + "." + destIndex + ","; // First destination
-        for (i=1; i<destCount-1; i++) {
-            compDestName += (simpleName + "." + (destIndex + i) +",");
-        }
-        compDestName += (simpleName + "." + (destIndex + i)); // Last destination (minus the comma)
-
-        return createDestination(compDestName);
-    }
-
-    protected Destination createDestination(String name) throws JMSException {
-        if (name.startsWith("queue://")) {
-            return getSession().createQueue(name.substring("queue://".length()));
-        } else if (name.startsWith("topic://")) {
-            return getSession().createTopic(name.substring("topic://".length()));
-        } else {
-            return getSession().createTopic(name);
-        }
-    }
-
-}
+/**
+ *
+ * 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.activemq.tool.properties.JmsClientProperties;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.jms.ConnectionFactory;
+import javax.jms.Connection;
+import javax.jms.Session;
+import javax.jms.JMSException;
+import javax.jms.Destination;
+import java.util.Enumeration;
+
+public abstract class AbstractJmsClient {
+    private static final Log log = LogFactory.getLog(AbstractJmsClient.class);
+
+    protected ConnectionFactory factory;
+    protected Connection jmsConnection;
+    protected Session jmsSession;
+
+    protected int destCount = 1, destIndex = 0;
+    protected String clientName = "";
+
+    public AbstractJmsClient(ConnectionFactory factory) {
+        this.factory = factory;
+    }
+
+    abstract public JmsClientProperties getClient();
+    abstract public void setClient(JmsClientProperties client);
+
+    public ConnectionFactory getFactory() {
+        return factory;
+    }
+
+    public void setFactory(ConnectionFactory factory) {
+        this.factory = factory;
+    }
+
+    public int getDestCount() {
+        return destCount;
+    }
+
+    public void setDestCount(int destCount) {
+        this.destCount = destCount;
+    }
+
+    public int getDestIndex() {
+        return destIndex;
+    }
+
+    public void setDestIndex(int destIndex) {
+        this.destIndex = destIndex;
+    }
+
+    public String getClientName() {
+        return clientName;
+    }
+
+    public void setClientName(String clientName) {
+        this.clientName = clientName;
+    }
+
+    public Connection getConnection() throws JMSException {
+        if (jmsConnection == null) {
+            jmsConnection = factory.createConnection();
+            jmsConnection.setClientID(getClientName());
+            log.info("Creating JMS Connection: Provider=" + getClient().getJmsProvider() + ", JMS Spec=" + getClient().getJmsVersion());
+        }
+        return jmsConnection;
+    }
+
+    public Session getSession() throws JMSException {
+        if (jmsSession == null) {
+            int ackMode;
+            if (getClient().getSessAckMode().equalsIgnoreCase(JmsClientProperties.SESSION_AUTO_ACKNOWLEDGE)) {
+                ackMode = Session.AUTO_ACKNOWLEDGE;
+            } else if (getClient().getSessAckMode().equalsIgnoreCase(JmsClientProperties.SESSION_CLIENT_ACKNOWLEDGE)) {
+                ackMode = Session.CLIENT_ACKNOWLEDGE;
+            } else if (getClient().getSessAckMode().equalsIgnoreCase(JmsClientProperties.SESSION_DUPS_OK_ACKNOWLEDGE)) {
+                ackMode = Session.DUPS_OK_ACKNOWLEDGE;
+            } else if (getClient().getSessAckMode().equalsIgnoreCase(JmsClientProperties.SESSION_TRANSACTED)) {
+                ackMode = Session.SESSION_TRANSACTED;
+            } else {
+                ackMode = Session.AUTO_ACKNOWLEDGE;
+            }
+            jmsSession = getConnection().createSession(getClient().isSessTransacted(), ackMode);
+        }
+        return jmsSession;
+    }
+
+    public Destination[] createDestination(int destIndex, int destCount) throws JMSException {
+
+        if (getClient().isDestComposite()) {
+            return new Destination[] {createCompositeDestination(getClient().getDestName(), destIndex, destCount)};
+        } else {
+            Destination[] dest = new Destination[destCount];
+            for (int i=0; i<destCount; i++) {
+                dest[i] = createDestination(getClient().getDestName() + "." + (destIndex + i));
+            }
+
+            return dest;
+        }
+    }
+
+    public Destination createCompositeDestination(int destIndex, int destCount) throws JMSException {
+        return createCompositeDestination(getClient().getDestName(), destIndex, destCount);
+    }
+
+    protected Destination createCompositeDestination(String name, int destIndex, int destCount) throws JMSException {
+        String compDestName;
+        String simpleName;
+
+        if (name.startsWith("queue://")) {
+            simpleName = name.substring("queue://".length());
+        } else if (name.startsWith("topic://")) {
+            simpleName = name.substring("topic://".length());
+        } else {
+            simpleName = name;
+        }
+
+        int i;
+        compDestName = name + "." + destIndex + ","; // First destination
+        for (i=1; i<destCount-1; i++) {
+            compDestName += (simpleName + "." + (destIndex + i) +",");
+        }
+        compDestName += (simpleName + "." + (destIndex + i)); // Last destination (minus the comma)
+
+        return createDestination(compDestName);
+    }
+
+    protected Destination createDestination(String name) throws JMSException {
+        if (name.startsWith("queue://")) {
+            return getSession().createQueue(name.substring("queue://".length()));
+        } else if (name.startsWith("topic://")) {
+            return getSession().createTopic(name.substring("topic://".length()));
+        } else {
+            return getSession().createTopic(name);
+        }
+    }
+
+}

Propchange: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/AbstractJmsClient.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/AbstractJmsClientSystem.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/AbstractJmsClientSystem.java?rev=419366&r1=419365&r2=419366&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/AbstractJmsClientSystem.java (original)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/AbstractJmsClientSystem.java Wed Jul  5 15:30:19 2006
@@ -1,272 +1,272 @@
-/**
- *
- * 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 org.apache.activemq.tool.sampler.ThroughputSamplerTask;
-import org.apache.activemq.tool.sampler.CpuSamplerTask;
-import org.apache.activemq.tool.reports.PerformanceReportWriter;
-import org.apache.activemq.tool.reports.XmlFilePerfReportWriter;
-import org.apache.activemq.tool.reports.VerbosePerfReportWriter;
-import org.apache.activemq.tool.properties.JmsClientSystemProperties;
-import org.apache.activemq.tool.properties.AbstractObjectProperties;
-import org.apache.activemq.tool.properties.JmsFactoryProperties;
-import org.apache.activemq.tool.properties.ReflectionUtil;
-import org.apache.activemq.tool.properties.JmsClientProperties;
-import org.apache.activemq.tool.spi.SPIConnectionFactory;
-
-import javax.jms.ConnectionFactory;
-import javax.jms.JMSException;
-import javax.jms.ConnectionMetaData;
-import java.util.Properties;
-import java.util.Enumeration;
-import java.io.IOException;
-import java.io.File;
-import java.io.FileInputStream;
-
-public abstract class AbstractJmsClientSystem extends AbstractObjectProperties {
-    private static final Log log = LogFactory.getLog(AbstractJmsClientSystem.class);
-
-    private int clientDestIndex, clientDestCount;
-
-    protected ThreadGroup clientThreadGroup;
-    protected ConnectionFactory jmsConnFactory;
-
-    // Properties
-    protected JmsFactoryProperties factory  = new JmsFactoryProperties();
-    protected ThroughputSamplerTask tpSampler = new ThroughputSamplerTask();
-    protected CpuSamplerTask cpuSampler = new CpuSamplerTask();
-
-    public void runSystemTest() throws JMSException {
-        // Create connection factory
-        jmsConnFactory = loadJmsFactory(getSysTest().getSpiClass(), factory.getFactorySettings());
-
-        setProviderMetaData(jmsConnFactory.createConnection().getMetaData(), getJmsClientProperties());
-
-        // Create performance sampler
-        PerformanceReportWriter writer = createPerfWriter();
-        tpSampler.setPerfReportWriter(writer);
-        cpuSampler.setPerfReportWriter(writer);
-
-        writer.openReportWriter();
-        writer.writeProperties("jvmSettings", System.getProperties());
-        writer.writeProperties("testSystemSettings", ReflectionUtil.retrieveObjectProperties(getSysTest()));
-        writer.writeProperties("jmsFactorySettings", ReflectionUtil.retrieveObjectProperties(jmsConnFactory));
-        writer.writeProperties("jmsClientSettings", ReflectionUtil.retrieveObjectProperties(getJmsClientProperties()));
-        writer.writeProperties("tpSamplerSettings", ReflectionUtil.retrieveObjectProperties(tpSampler));
-        writer.writeProperties("cpuSamplerSettings", ReflectionUtil.retrieveObjectProperties(cpuSampler));
-
-        clientThreadGroup = new ThreadGroup(getSysTest().getClientPrefix() + " Thread Group");
-        for (int i=0; i<getSysTest().getNumClients(); i++) {
-            distributeDestinations(getSysTest().getDestDistro(), i, getSysTest().getNumClients(), getSysTest().getTotalDests());
-
-            final String clientName = getSysTest().getClientPrefix() + i;
-            final int clientDestIndex = this.clientDestIndex;
-            final int clientDestCount = this.clientDestCount;
-            Thread t = new Thread(clientThreadGroup, new Runnable() {
-                public void run() {
-                    runJmsClient(clientName, clientDestIndex, clientDestCount);
-                }
-            });
-            t.setName(getSysTest().getClientPrefix() + i + " Thread");
-            t.start();
-        }
-
-        // Run samplers
-        if (getSysTest().getSamplers().indexOf(JmsClientSystemProperties.SAMPLER_TP) > -1) {
-            tpSampler.startSampler();
-        }
-
-        if (getSysTest().getSamplers().indexOf(JmsClientSystemProperties.SAMPLER_CPU) > -1) {
-            try {
-                cpuSampler.createPlugin();
-                cpuSampler.startSampler();
-            } catch (IOException e) {
-                log.warn("Unable to start CPU sampler plugin. Reason: " + e.getMessage());
-            }
-        }
-
-        tpSampler.waitUntilDone();
-        cpuSampler.waitUntilDone();
-
-        writer.closeReportWriter();
-    }
-
-    public ThroughputSamplerTask getTpSampler() {
-        return tpSampler;
-    }
-
-    public void setTpSampler(ThroughputSamplerTask tpSampler) {
-        this.tpSampler = tpSampler;
-    }
-
-    public CpuSamplerTask getCpuSampler() {
-        return cpuSampler;
-    }
-
-    public void setCpuSampler(CpuSamplerTask cpuSampler) {
-        this.cpuSampler = cpuSampler;
-    }
-
-    public JmsFactoryProperties getFactory() {
-        return factory;
-    }
-
-    public void setFactory(JmsFactoryProperties factory) {
-        this.factory = factory;
-    }
-
-    public abstract JmsClientSystemProperties getSysTest();
-    public abstract void setSysTest(JmsClientSystemProperties sysTestProps);
-    public abstract JmsClientProperties getJmsClientProperties();
-
-    protected PerformanceReportWriter createPerfWriter() {
-        if (getSysTest().getReportType().equalsIgnoreCase(JmsClientSystemProperties.REPORT_XML_FILE)) {
-            String reportName;
-
-            if ((reportName = getSysTest().getReportName()) == null) {
-                reportName = getSysTest().getClientPrefix() + "_" +
-                             "numClients" + getSysTest().getNumClients() + "_" +
-                             "numDests" + getSysTest().getTotalDests() + "_" +
-                             getSysTest().getDestDistro();
-            }
-            return new XmlFilePerfReportWriter(getSysTest().getReportDir(), reportName);
-        } else if (getSysTest().getReportType().equalsIgnoreCase(JmsClientSystemProperties.REPORT_VERBOSE)) {
-            return new VerbosePerfReportWriter();
-        } else {
-            // Use verbose if unknown report type
-            return new VerbosePerfReportWriter();
-        }
-    }
-
-    protected void distributeDestinations(String distroType, int clientIndex, int numClients, int numDests) {
-        if (distroType.equalsIgnoreCase(JmsClientSystemProperties.DEST_DISTRO_ALL)) {
-            clientDestCount = numDests;
-            clientDestIndex = 0;
-        } else if (distroType.equalsIgnoreCase(JmsClientSystemProperties.DEST_DISTRO_EQUAL)) {
-            int destPerClient = (numDests / numClients);
-            // There are equal or more destinations per client
-            if (destPerClient > 0) {
-                clientDestCount = destPerClient;
-                clientDestIndex = destPerClient * clientIndex;
-            // If there are more clients than destinations, share destinations per client
-            } else {
-                clientDestCount = 1; // At most one destination per client
-                clientDestIndex = clientIndex % numDests;
-            }
-        } else if (distroType.equalsIgnoreCase(JmsClientSystemProperties.DEST_DISTRO_DIVIDE)) {
-            int destPerClient = (numDests / numClients);
-            // There are equal or more destinations per client
-            if (destPerClient > 0) {
-                int remain = numDests % numClients;
-                int nextIndex;
-                if (clientIndex < remain) {
-                    destPerClient++;
-                    nextIndex = clientIndex * destPerClient;
-                } else {
-                    nextIndex = (clientIndex * destPerClient) + remain;
-                }
-
-                clientDestCount = destPerClient;
-                clientDestIndex = nextIndex;
-
-            // If there are more clients than destinations, share destinations per client
-            } else {
-                clientDestCount = 1; // At most one destination per client
-                clientDestIndex = clientIndex % numDests;
-            }
-
-        // Send to all for unknown behavior
-        } else {
-            log.warn("Unknown destination distribution type: " + distroType);
-            clientDestCount = numDests;
-            clientDestIndex = 0;
-        }
-    }
-
-    protected ConnectionFactory loadJmsFactory(String spiClass, Properties factorySettings) throws JMSException {
-        try {
-            Class spi = Class.forName(spiClass);
-            SPIConnectionFactory spiFactory = (SPIConnectionFactory)spi.newInstance();
-            ConnectionFactory jmsFactory = spiFactory.createConnectionFactory(factorySettings);
-            log.info("Created: " + jmsFactory.getClass().getName() + " using SPIConnectionFactory: " + spiFactory.getClass().getName());
-            return jmsFactory;
-        } catch (Exception e) {
-            e.printStackTrace();
-            throw new JMSException(e.getMessage());
-        }
-    }
-
-    protected void setProviderMetaData(ConnectionMetaData metaData, JmsClientProperties props) throws JMSException {
-        props.setJmsProvider(metaData.getJMSProviderName() + "-" + metaData.getProviderVersion());
-        props.setJmsVersion(metaData.getJMSVersion());
-
-        String jmsProperties = "";
-        Enumeration jmsProps = metaData.getJMSXPropertyNames();
-        while (jmsProps.hasMoreElements()) {
-            jmsProperties += (jmsProps.nextElement().toString() + ",");
-        }
-        if (jmsProperties.length() > 0) {
-            // Remove the last comma
-            jmsProperties = jmsProperties.substring(0, jmsProperties.length()-1);
-        }
-        props.setJmsProperties(jmsProperties);
-    }
-
-    protected abstract void runJmsClient(String clientName, int clientDestIndex, int clientDestCount);
-
-    protected static Properties parseStringArgs(String[] args) {
-        File configFile = null;
-        Properties props = new Properties();
-
-        if (args == null || args.length == 0) {
-            return props; // Empty properties
-        }
-
-        for (int i=0; i<args.length; i++) {
-            String arg = args[i];
-            if (arg.startsWith("-D") || arg.startsWith("-d")) {
-                arg = arg.substring(2);
-            }
-            int index  = arg.indexOf("=");
-            String key = arg.substring(0, index);
-            String val = arg.substring(index + 1);
-
-            if (key.equalsIgnoreCase("sysTest.propsConfigFile")) {
-                if (!val.endsWith(".properties")) {
-                    val += ".properties";
-                }
-                configFile = new File(val);
-            }
-            props.setProperty(key, val);
-        }
-
-        Properties fileProps = new Properties();
-        try {
-            if (configFile != null) {
-                log.info("Loading properties file: " + configFile.getAbsolutePath());
-                fileProps.load(new FileInputStream(configFile));
-            }
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-        // Overwrite file settings with command line settings
-        fileProps.putAll(props);
-        return fileProps;
-    }
-}
+/**
+ *
+ * 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 org.apache.activemq.tool.sampler.ThroughputSamplerTask;
+import org.apache.activemq.tool.sampler.CpuSamplerTask;
+import org.apache.activemq.tool.reports.PerformanceReportWriter;
+import org.apache.activemq.tool.reports.XmlFilePerfReportWriter;
+import org.apache.activemq.tool.reports.VerbosePerfReportWriter;
+import org.apache.activemq.tool.properties.JmsClientSystemProperties;
+import org.apache.activemq.tool.properties.AbstractObjectProperties;
+import org.apache.activemq.tool.properties.JmsFactoryProperties;
+import org.apache.activemq.tool.properties.ReflectionUtil;
+import org.apache.activemq.tool.properties.JmsClientProperties;
+import org.apache.activemq.tool.spi.SPIConnectionFactory;
+
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSException;
+import javax.jms.ConnectionMetaData;
+import java.util.Properties;
+import java.util.Enumeration;
+import java.io.IOException;
+import java.io.File;
+import java.io.FileInputStream;
+
+public abstract class AbstractJmsClientSystem extends AbstractObjectProperties {
+    private static final Log log = LogFactory.getLog(AbstractJmsClientSystem.class);
+
+    private int clientDestIndex, clientDestCount;
+
+    protected ThreadGroup clientThreadGroup;
+    protected ConnectionFactory jmsConnFactory;
+
+    // Properties
+    protected JmsFactoryProperties factory  = new JmsFactoryProperties();
+    protected ThroughputSamplerTask tpSampler = new ThroughputSamplerTask();
+    protected CpuSamplerTask cpuSampler = new CpuSamplerTask();
+
+    public void runSystemTest() throws JMSException {
+        // Create connection factory
+        jmsConnFactory = loadJmsFactory(getSysTest().getSpiClass(), factory.getFactorySettings());
+
+        setProviderMetaData(jmsConnFactory.createConnection().getMetaData(), getJmsClientProperties());
+
+        // Create performance sampler
+        PerformanceReportWriter writer = createPerfWriter();
+        tpSampler.setPerfReportWriter(writer);
+        cpuSampler.setPerfReportWriter(writer);
+
+        writer.openReportWriter();
+        writer.writeProperties("jvmSettings", System.getProperties());
+        writer.writeProperties("testSystemSettings", ReflectionUtil.retrieveObjectProperties(getSysTest()));
+        writer.writeProperties("jmsFactorySettings", ReflectionUtil.retrieveObjectProperties(jmsConnFactory));
+        writer.writeProperties("jmsClientSettings", ReflectionUtil.retrieveObjectProperties(getJmsClientProperties()));
+        writer.writeProperties("tpSamplerSettings", ReflectionUtil.retrieveObjectProperties(tpSampler));
+        writer.writeProperties("cpuSamplerSettings", ReflectionUtil.retrieveObjectProperties(cpuSampler));
+
+        clientThreadGroup = new ThreadGroup(getSysTest().getClientPrefix() + " Thread Group");
+        for (int i=0; i<getSysTest().getNumClients(); i++) {
+            distributeDestinations(getSysTest().getDestDistro(), i, getSysTest().getNumClients(), getSysTest().getTotalDests());
+
+            final String clientName = getSysTest().getClientPrefix() + i;
+            final int clientDestIndex = this.clientDestIndex;
+            final int clientDestCount = this.clientDestCount;
+            Thread t = new Thread(clientThreadGroup, new Runnable() {
+                public void run() {
+                    runJmsClient(clientName, clientDestIndex, clientDestCount);
+                }
+            });
+            t.setName(getSysTest().getClientPrefix() + i + " Thread");
+            t.start();
+        }
+
+        // Run samplers
+        if (getSysTest().getSamplers().indexOf(JmsClientSystemProperties.SAMPLER_TP) > -1) {
+            tpSampler.startSampler();
+        }
+
+        if (getSysTest().getSamplers().indexOf(JmsClientSystemProperties.SAMPLER_CPU) > -1) {
+            try {
+                cpuSampler.createPlugin();
+                cpuSampler.startSampler();
+            } catch (IOException e) {
+                log.warn("Unable to start CPU sampler plugin. Reason: " + e.getMessage());
+            }
+        }
+
+        tpSampler.waitUntilDone();
+        cpuSampler.waitUntilDone();
+
+        writer.closeReportWriter();
+    }
+
+    public ThroughputSamplerTask getTpSampler() {
+        return tpSampler;
+    }
+
+    public void setTpSampler(ThroughputSamplerTask tpSampler) {
+        this.tpSampler = tpSampler;
+    }
+
+    public CpuSamplerTask getCpuSampler() {
+        return cpuSampler;
+    }
+
+    public void setCpuSampler(CpuSamplerTask cpuSampler) {
+        this.cpuSampler = cpuSampler;
+    }
+
+    public JmsFactoryProperties getFactory() {
+        return factory;
+    }
+
+    public void setFactory(JmsFactoryProperties factory) {
+        this.factory = factory;
+    }
+
+    public abstract JmsClientSystemProperties getSysTest();
+    public abstract void setSysTest(JmsClientSystemProperties sysTestProps);
+    public abstract JmsClientProperties getJmsClientProperties();
+
+    protected PerformanceReportWriter createPerfWriter() {
+        if (getSysTest().getReportType().equalsIgnoreCase(JmsClientSystemProperties.REPORT_XML_FILE)) {
+            String reportName;
+
+            if ((reportName = getSysTest().getReportName()) == null) {
+                reportName = getSysTest().getClientPrefix() + "_" +
+                             "numClients" + getSysTest().getNumClients() + "_" +
+                             "numDests" + getSysTest().getTotalDests() + "_" +
+                             getSysTest().getDestDistro();
+            }
+            return new XmlFilePerfReportWriter(getSysTest().getReportDir(), reportName);
+        } else if (getSysTest().getReportType().equalsIgnoreCase(JmsClientSystemProperties.REPORT_VERBOSE)) {
+            return new VerbosePerfReportWriter();
+        } else {
+            // Use verbose if unknown report type
+            return new VerbosePerfReportWriter();
+        }
+    }
+
+    protected void distributeDestinations(String distroType, int clientIndex, int numClients, int numDests) {
+        if (distroType.equalsIgnoreCase(JmsClientSystemProperties.DEST_DISTRO_ALL)) {
+            clientDestCount = numDests;
+            clientDestIndex = 0;
+        } else if (distroType.equalsIgnoreCase(JmsClientSystemProperties.DEST_DISTRO_EQUAL)) {
+            int destPerClient = (numDests / numClients);
+            // There are equal or more destinations per client
+            if (destPerClient > 0) {
+                clientDestCount = destPerClient;
+                clientDestIndex = destPerClient * clientIndex;
+            // If there are more clients than destinations, share destinations per client
+            } else {
+                clientDestCount = 1; // At most one destination per client
+                clientDestIndex = clientIndex % numDests;
+            }
+        } else if (distroType.equalsIgnoreCase(JmsClientSystemProperties.DEST_DISTRO_DIVIDE)) {
+            int destPerClient = (numDests / numClients);
+            // There are equal or more destinations per client
+            if (destPerClient > 0) {
+                int remain = numDests % numClients;
+                int nextIndex;
+                if (clientIndex < remain) {
+                    destPerClient++;
+                    nextIndex = clientIndex * destPerClient;
+                } else {
+                    nextIndex = (clientIndex * destPerClient) + remain;
+                }
+
+                clientDestCount = destPerClient;
+                clientDestIndex = nextIndex;
+
+            // If there are more clients than destinations, share destinations per client
+            } else {
+                clientDestCount = 1; // At most one destination per client
+                clientDestIndex = clientIndex % numDests;
+            }
+
+        // Send to all for unknown behavior
+        } else {
+            log.warn("Unknown destination distribution type: " + distroType);
+            clientDestCount = numDests;
+            clientDestIndex = 0;
+        }
+    }
+
+    protected ConnectionFactory loadJmsFactory(String spiClass, Properties factorySettings) throws JMSException {
+        try {
+            Class spi = Class.forName(spiClass);
+            SPIConnectionFactory spiFactory = (SPIConnectionFactory)spi.newInstance();
+            ConnectionFactory jmsFactory = spiFactory.createConnectionFactory(factorySettings);
+            log.info("Created: " + jmsFactory.getClass().getName() + " using SPIConnectionFactory: " + spiFactory.getClass().getName());
+            return jmsFactory;
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new JMSException(e.getMessage());
+        }
+    }
+
+    protected void setProviderMetaData(ConnectionMetaData metaData, JmsClientProperties props) throws JMSException {
+        props.setJmsProvider(metaData.getJMSProviderName() + "-" + metaData.getProviderVersion());
+        props.setJmsVersion(metaData.getJMSVersion());
+
+        String jmsProperties = "";
+        Enumeration jmsProps = metaData.getJMSXPropertyNames();
+        while (jmsProps.hasMoreElements()) {
+            jmsProperties += (jmsProps.nextElement().toString() + ",");
+        }
+        if (jmsProperties.length() > 0) {
+            // Remove the last comma
+            jmsProperties = jmsProperties.substring(0, jmsProperties.length()-1);
+        }
+        props.setJmsProperties(jmsProperties);
+    }
+
+    protected abstract void runJmsClient(String clientName, int clientDestIndex, int clientDestCount);
+
+    protected static Properties parseStringArgs(String[] args) {
+        File configFile = null;
+        Properties props = new Properties();
+
+        if (args == null || args.length == 0) {
+            return props; // Empty properties
+        }
+
+        for (int i=0; i<args.length; i++) {
+            String arg = args[i];
+            if (arg.startsWith("-D") || arg.startsWith("-d")) {
+                arg = arg.substring(2);
+            }
+            int index  = arg.indexOf("=");
+            String key = arg.substring(0, index);
+            String val = arg.substring(index + 1);
+
+            if (key.equalsIgnoreCase("sysTest.propsConfigFile")) {
+                if (!val.endsWith(".properties")) {
+                    val += ".properties";
+                }
+                configFile = new File(val);
+            }
+            props.setProperty(key, val);
+        }
+
+        Properties fileProps = new Properties();
+        try {
+            if (configFile != null) {
+                log.info("Loading properties file: " + configFile.getAbsolutePath());
+                fileProps.load(new FileInputStream(configFile));
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        // Overwrite file settings with command line settings
+        fileProps.putAll(props);
+        return fileProps;
+    }
+}

Propchange: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/AbstractJmsClientSystem.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/AbstractJmsMeasurableClient.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/AbstractJmsMeasurableClient.java?rev=419366&r1=419365&r2=419366&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/AbstractJmsMeasurableClient.java (original)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/AbstractJmsMeasurableClient.java Wed Jul  5 15:30:19 2006
@@ -1,51 +1,51 @@
-/**
- *
- * 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.activemq.tool.sampler.MeasurableClient;
-
-import javax.jms.ConnectionFactory;
-
-import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicLong;
-
-public abstract class AbstractJmsMeasurableClient extends AbstractJmsClient implements MeasurableClient {
-    protected AtomicLong throughput = new AtomicLong(0);
-
-    public AbstractJmsMeasurableClient( ConnectionFactory factory) {
-        super( factory);
-    }
-
-    public void reset() {
-        setThroughput(0);
-    }
-
-    public long getThroughput() {
-        return throughput.get();
-    }
-
-    public void setThroughput(long val) {
-        throughput.set(val);
-    }
-
-    public void incThroughput() {
-        throughput.incrementAndGet();
-    }
-
-    public void incThroughput(long val) {
-        throughput.addAndGet(val);
-    }
-}
+/**
+ *
+ * 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.activemq.tool.sampler.MeasurableClient;
+
+import javax.jms.ConnectionFactory;
+
+import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicLong;
+
+public abstract class AbstractJmsMeasurableClient extends AbstractJmsClient implements MeasurableClient {
+    protected AtomicLong throughput = new AtomicLong(0);
+
+    public AbstractJmsMeasurableClient( ConnectionFactory factory) {
+        super( factory);
+    }
+
+    public void reset() {
+        setThroughput(0);
+    }
+
+    public long getThroughput() {
+        return throughput.get();
+    }
+
+    public void setThroughput(long val) {
+        throughput.set(val);
+    }
+
+    public void incThroughput() {
+        throughput.incrementAndGet();
+    }
+
+    public void incThroughput(long val) {
+        throughput.addAndGet(val);
+    }
+}

Propchange: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/AbstractJmsMeasurableClient.java
------------------------------------------------------------------------------
    svn:eol-style = native

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=419366&r1=419365&r2=419366&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 Wed Jul  5 15:30:19 2006
@@ -1,214 +1,214 @@
-/**
- *
- * 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.LogFactory;
-import org.apache.commons.logging.Log;
-import org.apache.activemq.tool.properties.JmsConsumerProperties;
-import org.apache.activemq.tool.properties.JmsClientProperties;
-
-import javax.jms.MessageConsumer;
-import javax.jms.JMSException;
-import javax.jms.ConnectionFactory;
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.Topic;
-
-import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicInteger;
-
-public class JmsConsumerClient extends AbstractJmsMeasurableClient {
-    private static final Log log = LogFactory.getLog(JmsConsumerClient.class);
-
-    protected MessageConsumer jmsConsumer;
-    protected JmsConsumerProperties client;
-
-    public JmsConsumerClient(ConnectionFactory factory) {
-        this(new JmsConsumerProperties(), factory);
-    }
-
-    public JmsConsumerClient(JmsConsumerProperties clientProps, ConnectionFactory factory) {
-        super(factory);
-        client = clientProps;
-    }
-
-    public void receiveMessages() throws JMSException {
-        if (client.isAsyncRecv()) {
-            if (client.getRecvType().equalsIgnoreCase(JmsConsumerProperties.TIME_BASED_RECEIVING)) {
-                receiveAsyncTimeBasedMessages(client.getRecvDuration());
-            } else {
-                receiveAsyncCountBasedMessages(client.getRecvCount());
-            }
-        } else {
-            if (client.getRecvType().equalsIgnoreCase(JmsConsumerProperties.TIME_BASED_RECEIVING)) {
-                receiveSyncTimeBasedMessages(client.getRecvDuration());
-            } else {
-                receiveSyncCountBasedMessages(client.getRecvCount());
-            }
-        }
-    }
-
-    public void receiveMessages(int destCount) throws JMSException {
-        this.destCount = destCount;
-        receiveMessages();
-    }
-
-    public void receiveMessages(int destIndex, int destCount) throws JMSException {
-        this.destIndex = destIndex;
-        receiveMessages(destCount);
-    }
-
-    public void receiveSyncTimeBasedMessages(long duration) throws JMSException {
-        if (getJmsConsumer() == null) {
-            createJmsConsumer();
-        }
-
-        try {
-            getConnection().start();
-
-            log.info("Starting to synchronously receive messages for " + duration + " ms...");
-            long endTime = System.currentTimeMillis() + duration;
-            while (System.currentTimeMillis() < endTime) {
-                getJmsConsumer().receive();
-                incThroughput();
-            }
-        } finally {
-            getConnection().close();
-        }
-    }
-
-    public void receiveSyncCountBasedMessages(long count) throws JMSException {
-        if (getJmsConsumer() == null) {
-            createJmsConsumer();
-        }
-
-        try {
-            getConnection().start();
-            log.info("Starting to synchronously receive " + count + " messages...");
-
-            int recvCount = 0;
-            while (recvCount < count) {
-                getJmsConsumer().receive();
-                incThroughput();
-                recvCount++;
-            }
-        } finally {
-            getConnection().close();
-        }
-    }
-
-    public void receiveAsyncTimeBasedMessages(long duration) throws JMSException {
-        if (getJmsConsumer() == null) {
-            createJmsConsumer();
-        }
-
-        getJmsConsumer().setMessageListener(new MessageListener() {
-            public void onMessage(Message msg) {
-                incThroughput();
-            }
-        });
-
-        try {
-            getConnection().start();
-            log.info("Starting to asynchronously receive messages for " + duration + " ms...");
-            try {
-                Thread.sleep(duration);
-            } catch (InterruptedException e) {
-                throw new JMSException("JMS consumer thread sleep has been interrupted. Message: " + e.getMessage());
-            }
-        } finally {
-            getConnection().close();
-        }
-    }
-
-    public void receiveAsyncCountBasedMessages(long count) throws JMSException {
-        if (getJmsConsumer() == null) {
-            createJmsConsumer();
-        }
-
-        final AtomicInteger recvCount = new AtomicInteger(0);
-        getJmsConsumer().setMessageListener(new MessageListener() {
-            public void onMessage(Message msg) {
-                incThroughput();
-                recvCount.incrementAndGet();
-                recvCount.notify();
-            }
-        });
-
-        try {
-            getConnection().start();
-            log.info("Starting to asynchronously receive " + client.getRecvCount() + " messages...");
-            try {
-                while (recvCount.get() < count) {
-                    recvCount.wait();
-                }
-            } catch (InterruptedException e) {
-                throw new JMSException("JMS consumer thread wait has been interrupted. Message: " + e.getMessage());
-            }
-        } finally {
-            getConnection().close();
-        }
-    }
-
-    public MessageConsumer createJmsConsumer() throws JMSException {
-        Destination[] dest = createDestination(destIndex, destCount);
-        return createJmsConsumer(dest[0]);
-    }
-
-    public MessageConsumer createJmsConsumer(Destination dest) throws JMSException {
-        if (client.isDurable()) {
-            String clientName = getClientName();
-            if (clientName == null) {
-                clientName = "JmsConsumer";
-            }
-            log.info("Creating durable subscriber (" + getConnection().getClientID() + ") to: " + dest.toString());
-            jmsConsumer = getSession().createDurableSubscriber((Topic) dest, clientName);
-        } else {
-            log.info("Creating non-durable consumer to: " + dest.toString());
-            jmsConsumer = getSession().createConsumer(dest);
-        }
-        return jmsConsumer;
-    }
-
-    public MessageConsumer createJmsConsumer(Destination dest, String selector, boolean noLocal) throws JMSException {
-        if (client.isDurable()) {
-            String clientName = getClientName();
-            if (clientName == null) {
-                clientName = "JmsConsumer";
-            }
-            log.info("Creating durable subscriber (" + getConnection().getClientID() + ") to: " + dest.toString());
-            jmsConsumer = getSession().createDurableSubscriber((Topic) dest, clientName, selector, noLocal);
-        } else {
-            log.info("Creating non-durable consumer to: " + dest.toString());
-            jmsConsumer = getSession().createConsumer(dest, selector, noLocal);
-        }
-        return jmsConsumer;
-    }
-
-    public MessageConsumer getJmsConsumer() {
-        return jmsConsumer;
-    }
-
-    public JmsClientProperties getClient() {
-        return client;
-    }
-
-    public void setClient(JmsClientProperties clientProps) {
-        client = (JmsConsumerProperties)clientProps;
-    }
-}
+/**
+ *
+ * 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.LogFactory;
+import org.apache.commons.logging.Log;
+import org.apache.activemq.tool.properties.JmsConsumerProperties;
+import org.apache.activemq.tool.properties.JmsClientProperties;
+
+import javax.jms.MessageConsumer;
+import javax.jms.JMSException;
+import javax.jms.ConnectionFactory;
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.Topic;
+
+import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicInteger;
+
+public class JmsConsumerClient extends AbstractJmsMeasurableClient {
+    private static final Log log = LogFactory.getLog(JmsConsumerClient.class);
+
+    protected MessageConsumer jmsConsumer;
+    protected JmsConsumerProperties client;
+
+    public JmsConsumerClient(ConnectionFactory factory) {
+        this(new JmsConsumerProperties(), factory);
+    }
+
+    public JmsConsumerClient(JmsConsumerProperties clientProps, ConnectionFactory factory) {
+        super(factory);
+        client = clientProps;
+    }
+
+    public void receiveMessages() throws JMSException {
+        if (client.isAsyncRecv()) {
+            if (client.getRecvType().equalsIgnoreCase(JmsConsumerProperties.TIME_BASED_RECEIVING)) {
+                receiveAsyncTimeBasedMessages(client.getRecvDuration());
+            } else {
+                receiveAsyncCountBasedMessages(client.getRecvCount());
+            }
+        } else {
+            if (client.getRecvType().equalsIgnoreCase(JmsConsumerProperties.TIME_BASED_RECEIVING)) {
+                receiveSyncTimeBasedMessages(client.getRecvDuration());
+            } else {
+                receiveSyncCountBasedMessages(client.getRecvCount());
+            }
+        }
+    }
+
+    public void receiveMessages(int destCount) throws JMSException {
+        this.destCount = destCount;
+        receiveMessages();
+    }
+
+    public void receiveMessages(int destIndex, int destCount) throws JMSException {
+        this.destIndex = destIndex;
+        receiveMessages(destCount);
+    }
+
+    public void receiveSyncTimeBasedMessages(long duration) throws JMSException {
+        if (getJmsConsumer() == null) {
+            createJmsConsumer();
+        }
+
+        try {
+            getConnection().start();
+
+            log.info("Starting to synchronously receive messages for " + duration + " ms...");
+            long endTime = System.currentTimeMillis() + duration;
+            while (System.currentTimeMillis() < endTime) {
+                getJmsConsumer().receive();
+                incThroughput();
+            }
+        } finally {
+            getConnection().close();
+        }
+    }
+
+    public void receiveSyncCountBasedMessages(long count) throws JMSException {
+        if (getJmsConsumer() == null) {
+            createJmsConsumer();
+        }
+
+        try {
+            getConnection().start();
+            log.info("Starting to synchronously receive " + count + " messages...");
+
+            int recvCount = 0;
+            while (recvCount < count) {
+                getJmsConsumer().receive();
+                incThroughput();
+                recvCount++;
+            }
+        } finally {
+            getConnection().close();
+        }
+    }
+
+    public void receiveAsyncTimeBasedMessages(long duration) throws JMSException {
+        if (getJmsConsumer() == null) {
+            createJmsConsumer();
+        }
+
+        getJmsConsumer().setMessageListener(new MessageListener() {
+            public void onMessage(Message msg) {
+                incThroughput();
+            }
+        });
+
+        try {
+            getConnection().start();
+            log.info("Starting to asynchronously receive messages for " + duration + " ms...");
+            try {
+                Thread.sleep(duration);
+            } catch (InterruptedException e) {
+                throw new JMSException("JMS consumer thread sleep has been interrupted. Message: " + e.getMessage());
+            }
+        } finally {
+            getConnection().close();
+        }
+    }
+
+    public void receiveAsyncCountBasedMessages(long count) throws JMSException {
+        if (getJmsConsumer() == null) {
+            createJmsConsumer();
+        }
+
+        final AtomicInteger recvCount = new AtomicInteger(0);
+        getJmsConsumer().setMessageListener(new MessageListener() {
+            public void onMessage(Message msg) {
+                incThroughput();
+                recvCount.incrementAndGet();
+                recvCount.notify();
+            }
+        });
+
+        try {
+            getConnection().start();
+            log.info("Starting to asynchronously receive " + client.getRecvCount() + " messages...");
+            try {
+                while (recvCount.get() < count) {
+                    recvCount.wait();
+                }
+            } catch (InterruptedException e) {
+                throw new JMSException("JMS consumer thread wait has been interrupted. Message: " + e.getMessage());
+            }
+        } finally {
+            getConnection().close();
+        }
+    }
+
+    public MessageConsumer createJmsConsumer() throws JMSException {
+        Destination[] dest = createDestination(destIndex, destCount);
+        return createJmsConsumer(dest[0]);
+    }
+
+    public MessageConsumer createJmsConsumer(Destination dest) throws JMSException {
+        if (client.isDurable()) {
+            String clientName = getClientName();
+            if (clientName == null) {
+                clientName = "JmsConsumer";
+            }
+            log.info("Creating durable subscriber (" + getConnection().getClientID() + ") to: " + dest.toString());
+            jmsConsumer = getSession().createDurableSubscriber((Topic) dest, clientName);
+        } else {
+            log.info("Creating non-durable consumer to: " + dest.toString());
+            jmsConsumer = getSession().createConsumer(dest);
+        }
+        return jmsConsumer;
+    }
+
+    public MessageConsumer createJmsConsumer(Destination dest, String selector, boolean noLocal) throws JMSException {
+        if (client.isDurable()) {
+            String clientName = getClientName();
+            if (clientName == null) {
+                clientName = "JmsConsumer";
+            }
+            log.info("Creating durable subscriber (" + getConnection().getClientID() + ") to: " + dest.toString());
+            jmsConsumer = getSession().createDurableSubscriber((Topic) dest, clientName, selector, noLocal);
+        } else {
+            log.info("Creating non-durable consumer to: " + dest.toString());
+            jmsConsumer = getSession().createConsumer(dest, selector, noLocal);
+        }
+        return jmsConsumer;
+    }
+
+    public MessageConsumer getJmsConsumer() {
+        return jmsConsumer;
+    }
+
+    public JmsClientProperties getClient() {
+        return client;
+    }
+
+    public void setClient(JmsClientProperties clientProps) {
+        client = (JmsConsumerProperties)clientProps;
+    }
+}

Propchange: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsConsumerClient.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message