mirror of https://github.com/apache/activemq.git
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:
parent
cf0570f75e
commit
99b088dcd4
|
@ -25,12 +25,12 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>incubator-activemq</groupId>
|
<groupId>incubator-activemq</groupId>
|
||||||
<artifactId>activemq-core</artifactId>
|
<artifactId>activemq-core</artifactId>
|
||||||
<version>4.0-SNAPSHOT</version>
|
<version>4.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>incubator-activemq</groupId>
|
<groupId>incubator-activemq</groupId>
|
||||||
<artifactId>activemq-console</artifactId>
|
<artifactId>activemq-console</artifactId>
|
||||||
<version>4.0-SNAPSHOT</version>
|
<version>4.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>incubator-activemq</groupId>
|
<groupId>incubator-activemq</groupId>
|
||||||
|
|
|
@ -54,7 +54,7 @@ public abstract class JmsClientSystemSupport {
|
||||||
report.setTestSettings(getSettings());
|
report.setTestSettings(getSettings());
|
||||||
report.startGenerateReport();
|
report.startGenerateReport();
|
||||||
|
|
||||||
performanceSampler.setDataOutputStream(report.getDataOutputStream());
|
performanceSampler.setWriter(report.getWriter());
|
||||||
|
|
||||||
clientThreadGroup = new ThreadGroup(getThreadGroupName());
|
clientThreadGroup = new ThreadGroup(getThreadGroupName());
|
||||||
for (int i=0; i<getNumClients(); i++) {
|
for (int i=0; i<getNumClients(); i++) {
|
||||||
|
|
|
@ -19,8 +19,7 @@ package org.apache.activemq.tool;
|
||||||
import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean;
|
import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import javax.jms.JMSException;
|
import javax.jms.JMSException;
|
||||||
import java.io.DataOutputStream;
|
import java.io.PrintWriter;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -38,7 +37,7 @@ public class PerfMeasurementTool implements PerfEventListener, Runnable {
|
||||||
private AtomicBoolean start = new AtomicBoolean(false);
|
private AtomicBoolean start = new AtomicBoolean(false);
|
||||||
private AtomicBoolean stop = new AtomicBoolean(false);
|
private AtomicBoolean stop = new AtomicBoolean(false);
|
||||||
private AtomicBoolean isRunning = new AtomicBoolean(false);
|
private AtomicBoolean isRunning = new AtomicBoolean(false);
|
||||||
private DataOutputStream dataDoutputStream = null;
|
private PrintWriter writer = null;
|
||||||
private Properties samplerSettings = new Properties();
|
private Properties samplerSettings = new Properties();
|
||||||
|
|
||||||
private List perfClients = new ArrayList();
|
private List perfClients = new ArrayList();
|
||||||
|
@ -63,12 +62,12 @@ public class PerfMeasurementTool implements PerfEventListener, Runnable {
|
||||||
ReflectionUtil.configureClass(this, samplerSettings);
|
ReflectionUtil.configureClass(this, samplerSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataOutputStream getDataOutputStream() {
|
public PrintWriter getWriter() {
|
||||||
return dataDoutputStream;
|
return writer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDataOutputStream(DataOutputStream dataDoutputStream) {
|
public void setWriter(PrintWriter writer) {
|
||||||
this.dataDoutputStream = dataDoutputStream;
|
this.writer = writer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getDuration() {
|
public long getDuration() {
|
||||||
|
@ -170,8 +169,8 @@ public class PerfMeasurementTool implements PerfEventListener, Runnable {
|
||||||
public void sampleClients() {
|
public void sampleClients() {
|
||||||
for (Iterator i = perfClients.iterator(); i.hasNext();) {
|
for (Iterator i = perfClients.iterator(); i.hasNext();) {
|
||||||
PerfMeasurable client = (PerfMeasurable) i.next();
|
PerfMeasurable client = (PerfMeasurable) i.next();
|
||||||
writeResult("<sample index=" + sampleIndex + " name=" + client.getClientName() +
|
getWriter().println("<sample index=" + sampleIndex + " name=" + client.getClientName() +
|
||||||
" throughput=" + client.getThroughput() + "/>\n");
|
" throughput=" + client.getThroughput() + "/>");
|
||||||
client.reset();
|
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
package org.apache.activemq.tool;
|
||||||
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Properties;
|
import java.io.PrintWriter;
|
||||||
import java.util.Enumeration;
|
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 {
|
public class PerfReportGenerator {
|
||||||
|
|
||||||
private String reportDirectory = null;
|
private String reportDirectory = null;
|
||||||
private String reportName = null;
|
private String reportName = null;
|
||||||
private DataOutputStream dataOutputStream = null;
|
private PrintWriter writer = null;
|
||||||
|
|
||||||
private Properties testSettings;
|
private Properties testSettings;
|
||||||
|
|
||||||
|
@ -49,56 +58,50 @@ public class PerfReportGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
dataOutputStream = new DataOutputStream(new FileOutputStream(reportFile));
|
this.writer = new PrintWriter(new FileOutputStream(reportFile));
|
||||||
dataOutputStream.writeChars(getTestInformation().toString());
|
addTestInformation(getWriter());
|
||||||
} catch (IOException e1) {
|
} catch (IOException e1) {
|
||||||
e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopGenerateReport() {
|
public void stopGenerateReport() {
|
||||||
try {
|
this.getWriter().println("</test-result>");
|
||||||
dataOutputStream.writeChars("</test-result>\n</test-report>");
|
this.getWriter().println("</test-report>");
|
||||||
dataOutputStream.flush();
|
this.getWriter().flush();
|
||||||
dataOutputStream.close();
|
this.getWriter().close();
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getTestInformation() {
|
protected void addTestInformation(PrintWriter writer) {
|
||||||
StringBuffer buffer = new StringBuffer();
|
|
||||||
|
|
||||||
buffer.append("<test-report>\n");
|
writer.println("<test-report>");
|
||||||
buffer.append("<test-information>\n");
|
writer.println("<test-information>");
|
||||||
|
|
||||||
buffer.append("<os-name>" + System.getProperty("os.name") + "</os-name>\n");
|
writer.println("<os-name>" + System.getProperty("os.name") + "</os-name>");
|
||||||
buffer.append("<java-version>" + System.getProperty("java.version") + "</java-version>\n");
|
writer.println("<java-version>" + System.getProperty("java.version") + "</java-version>");
|
||||||
|
|
||||||
if (this.getTestSettings() != null) {
|
if (this.getTestSettings() != null) {
|
||||||
Enumeration keys = getTestSettings().propertyNames();
|
Enumeration keys = getTestSettings().propertyNames();
|
||||||
|
|
||||||
buffer.append("<client-settings>\n");
|
writer.println("<client-settings>");
|
||||||
|
|
||||||
String key;
|
String key;
|
||||||
String key2;
|
String key2;
|
||||||
while (keys.hasMoreElements()) {
|
while (keys.hasMoreElements()) {
|
||||||
key = (String) keys.nextElement();
|
key = (String) keys.nextElement();
|
||||||
key2 = key.substring(key.indexOf(".") + 1);
|
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");
|
writer.println("</test-information>");
|
||||||
buffer.append("<test-result>\n");
|
writer.println("<test-result>");
|
||||||
|
|
||||||
return buffer.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataOutputStream getDataOutputStream() {
|
public PrintWriter getWriter() {
|
||||||
return this.dataOutputStream;
|
return this.writer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue