Changed DataOutputStream to PrintWriter when generating the report xml file.

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@412256 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Frederick G. Oconer 2006-06-07 02:34:18 +00:00
parent cf0570f75e
commit 99b088dcd4
4 changed files with 60 additions and 66 deletions

View File

@ -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>

View File

@ -54,7 +54,7 @@ public abstract class JmsClientSystemSupport {
report.setTestSettings(getSettings());
report.startGenerateReport();
performanceSampler.setDataOutputStream(report.getDataOutputStream());
performanceSampler.setWriter(report.getWriter());
clientThreadGroup = new ThreadGroup(getThreadGroupName());
for (int i=0; i<getNumClients(); i++) {

View File

@ -19,8 +19,7 @@ package org.apache.activemq.tool;
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 @@ public class PerfMeasurementTool implements PerfEventListener, Runnable {
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 @@ public class PerfMeasurementTool implements PerfEventListener, Runnable {
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 class PerfMeasurementTool implements PerfEventListener, Runnable {
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();
}
}
@ -186,12 +185,4 @@ public class PerfMeasurementTool implements PerfEventListener, Runnable {
}
}
}
public void writeResult(String result) {
try {
getDataOutputStream().writeChars(result);
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@ -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;
@ -49,56 +58,50 @@ public class PerfReportGenerator {
}
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) {
Enumeration keys = getTestSettings().propertyNames();
buffer.append("<client-settings>\n");
writer.println("<client-settings>");
String key;
String key2;
while (keys.hasMoreElements()) {
key = (String) keys.nextElement();
key2 = key.substring(key.indexOf(".") + 1);
buffer.append("<" + key2 +">" + getTestSettings().get(key) + "</" + key2 +">\n");
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;
}