activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From foco...@apache.org
Subject svn commit: r412256 - in /incubator/activemq/trunk/tooling/maven-activemq-perf-plugin: ./ src/main/java/org/apache/activemq/tool/
Date Wed, 07 Jun 2006 02:34:18 GMT
Author: foconer
Date: Tue Jun  6 19:34:18 2006
New Revision: 412256

URL: http://svn.apache.org/viewvc?rev=412256&view=rev
Log:
Changed DataOutputStream to PrintWriter when generating the report xml file.

Modified:
    incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/pom.xml
    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/PerfMeasurementTool.java
    incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/PerfReportGenerator.java

Modified: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/pom.xml
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/pom.xml?rev=412256&r1=412255&r2=412256&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/pom.xml (original)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/pom.xml Tue Jun  6 19:34:18
2006
@@ -25,12 +25,12 @@
         <dependency>
             <groupId>incubator-activemq</groupId>
             <artifactId>activemq-core</artifactId>
-            <version>4.0-SNAPSHOT</version>
+            <version>4.1-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>incubator-activemq</groupId>
             <artifactId>activemq-console</artifactId>
-            <version>4.0-SNAPSHOT</version>
+            <version>4.1-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>incubator-activemq</groupId>

Modified: 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=412256&r1=412255&r2=412256&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSystemSupport.java
(original)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSystemSupport.java
Tue Jun  6 19:34:18 2006
@@ -54,7 +54,7 @@
         report.setTestSettings(getSettings());
         report.startGenerateReport();
 
-        performanceSampler.setDataOutputStream(report.getDataOutputStream());
+        performanceSampler.setWriter(report.getWriter());
 
         clientThreadGroup = new ThreadGroup(getThreadGroupName());
         for (int i=0; i<getNumClients(); i++) {

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=412256&r1=412255&r2=412256&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
Tue Jun  6 19:34:18 2006
@@ -19,8 +19,7 @@
 import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean;
 
 import javax.jms.JMSException;
-import java.io.DataOutputStream;
-import java.io.IOException;
+import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -38,7 +37,7 @@
     private AtomicBoolean start = new AtomicBoolean(false);
     private AtomicBoolean stop  = new AtomicBoolean(false);
     private AtomicBoolean isRunning = new AtomicBoolean(false);
-    private DataOutputStream dataDoutputStream = null;
+    private PrintWriter writer = null;
     private Properties samplerSettings = new Properties();
 
     private List perfClients = new ArrayList();
@@ -63,12 +62,12 @@
         ReflectionUtil.configureClass(this, samplerSettings);
     }
 
-    public DataOutputStream getDataOutputStream() {
-        return dataDoutputStream;
+    public PrintWriter getWriter() {
+        return writer;
     }
 
-    public void setDataOutputStream(DataOutputStream dataDoutputStream) {
-        this.dataDoutputStream = dataDoutputStream;
+    public void setWriter(PrintWriter writer) {
+        this.writer = writer;
     }
 
     public long getDuration() {
@@ -170,8 +169,8 @@
     public void sampleClients() {
         for (Iterator i = perfClients.iterator(); i.hasNext();) {
             PerfMeasurable client = (PerfMeasurable) i.next();
-            writeResult("<sample index=" + sampleIndex + " name=" + client.getClientName()
+
-                    " throughput=" + client.getThroughput() + "/>\n");
+            getWriter().println("<sample index=" + sampleIndex + " name=" + client.getClientName()
+
+                    " throughput=" + client.getThroughput() + "/>");
             client.reset();
         }
     }
@@ -184,14 +183,6 @@
                 }
             } catch (InterruptedException e) {
             }
-        }
-    }
-
-    public void writeResult(String result) {
-        try {
-            getDataOutputStream().writeChars(result);
-        } catch (IOException e) {
-            e.printStackTrace();
         }
     }
 }

Modified: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/PerfReportGenerator.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/PerfReportGenerator.java?rev=412256&r1=412255&r2=412256&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/PerfReportGenerator.java
(original)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/PerfReportGenerator.java
Tue Jun  6 19:34:18 2006
@@ -1,25 +1,34 @@
+/**
+ *
+ * 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 java.io.DataOutputStream;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
-import java.util.Properties;
+import java.io.PrintWriter;
 import java.util.Enumeration;
-import java.util.Iterator;
+import java.util.Properties;
 
-/**
- * Created by IntelliJ IDEA.
- * User: admin
- * Date: Jun 5, 2006
- * Time: 10:57:52 AM
- * To change this template use File | Settings | File Templates.
- */
 public class PerfReportGenerator {
 
     private String reportDirectory = null;
     private String reportName = null;
-    private DataOutputStream dataOutputStream = null;
+    private PrintWriter writer = null;
 
     private Properties testSettings;
 
@@ -44,61 +53,55 @@
 
         File reportFile = null;
         if (reportDir != null) {
-            String filename = (this.getReportName()).substring(this.getReportName().lastIndexOf(".")+1)+"-"+createReportName(getTestSettings());
+            String filename = (this.getReportName()).substring(this.getReportName().lastIndexOf(".")
+ 1) + "-" + createReportName(getTestSettings());
             reportFile = new File(this.getReportDirectory() + File.separator + filename +
".xml");
         }
 
         try {
-            dataOutputStream = new DataOutputStream(new FileOutputStream(reportFile));
-            dataOutputStream.writeChars(getTestInformation().toString());
+            this.writer = new PrintWriter(new FileOutputStream(reportFile));
+            addTestInformation(getWriter());
         } catch (IOException e1) {
             e1.printStackTrace();  //To change body of catch statement use File | Settings
| File Templates.
         }
     }
 
     public void stopGenerateReport() {
-        try {
-            dataOutputStream.writeChars("</test-result>\n</test-report>");
-            dataOutputStream.flush();
-            dataOutputStream.close();
-        } catch (IOException e) {
-            e.printStackTrace();  //To change body of catch statement use File | Settings
| File Templates.
-        }
+        this.getWriter().println("</test-result>");
+        this.getWriter().println("</test-report>");
+        this.getWriter().flush();
+        this.getWriter().close();
     }
 
-    protected String getTestInformation() {
-        StringBuffer buffer = new StringBuffer();
+    protected void addTestInformation(PrintWriter writer) {
 
-        buffer.append("<test-report>\n");
-        buffer.append("<test-information>\n");
+        writer.println("<test-report>");
+        writer.println("<test-information>");
 
-        buffer.append("<os-name>" + System.getProperty("os.name") + "</os-name>\n");
-        buffer.append("<java-version>" + System.getProperty("java.version") + "</java-version>\n");
+        writer.println("<os-name>" + System.getProperty("os.name") + "</os-name>");
+        writer.println("<java-version>" + System.getProperty("java.version") + "</java-version>");
 
-        if(this.getTestSettings()!=null){
+        if (this.getTestSettings() != null) {
             Enumeration keys = getTestSettings().propertyNames();
 
-            buffer.append("<client-settings>\n");
+            writer.println("<client-settings>");
 
             String key;
             String key2;
-            while(keys.hasMoreElements()){
+            while (keys.hasMoreElements()) {
                 key = (String) keys.nextElement();
-                key2 = key.substring(key.indexOf(".")+1);
-                buffer.append("<" + key2 +">" + getTestSettings().get(key) + "</"
+ key2 +">\n");
+                key2 = key.substring(key.indexOf(".") + 1);
+                writer.println("<" + key2 + ">" + getTestSettings().get(key) + "</"
+ key2 + ">");
             }
 
-            buffer.append("</client-settings>\n");
+            writer.println("</client-settings>");
         }
 
-        buffer.append("</test-information>\n");
-        buffer.append("<test-result>\n");
-
-        return buffer.toString();
+        writer.println("</test-information>");
+        writer.println("<test-result>");
     }
 
-    public DataOutputStream getDataOutputStream() {
-        return this.dataOutputStream;
+    public PrintWriter getWriter() {
+        return this.writer;
     }
 
 
@@ -115,22 +118,22 @@
     }
 
     public String createReportName(Properties testSettings) {
-        if(testSettings!=null){
-            String[] keys = {"client.destCount","consumer.asyncRecv","consumer.durable",
-                             "producer.messageSize","sysTest.numClients","sysTest.totalDests"};
+        if (testSettings != null) {
+            String[] keys = {"client.destCount", "consumer.asyncRecv", "consumer.durable",
+                             "producer.messageSize", "sysTest.numClients", "sysTest.totalDests"};
 
             StringBuffer buffer = new StringBuffer();
             String key;
             String val;
             String temp;
-            for(int i=0;i<keys.length;i++){
+            for (int i = 0; i < keys.length; i++) {
                 key = keys[i];
                 val = testSettings.getProperty(key);
 
-                if(val==null)continue;
+                if (val == null) continue;
 
-                temp = key.substring(key.indexOf(".")+1);
-                buffer.append(temp+val);
+                temp = key.substring(key.indexOf(".") + 1);
+                buffer.append(temp + val);
             }
 
             return buffer.toString();



Mime
View raw message