mirror of https://github.com/apache/activemq.git
initial support for generating report xml file.
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@411835 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7976ad976e
commit
264f0a3732
|
@ -296,7 +296,6 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!--
|
||||
<plugin>
|
||||
<groupId>incubator-activemq</groupId>
|
||||
<artifactId>maven-activemq-perf-plugin</artifactId>
|
||||
|
@ -305,7 +304,6 @@
|
|||
<configFile>src/release/conf/activemq.xml</configFile>
|
||||
</configuration>
|
||||
</plugin>
|
||||
-->
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ package org.apache.activemq.maven;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.activemq.tool.JmsConsumerClient;
|
||||
import org.apache.activemq.tool.JmsConsumerSystem;
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
|
||||
|
@ -33,43 +33,198 @@ public class ConsumerMojo
|
|||
extends AbstractMojo {
|
||||
|
||||
/**
|
||||
* @parameter expression="${url}" default-value="tcp://localhost:61616"
|
||||
* @parameter expression="${sampler.durable}" default-value="60000"
|
||||
* @required
|
||||
*/
|
||||
private String url;
|
||||
private String duration;
|
||||
|
||||
/**
|
||||
* @parameter expression="${topic}" default-value="true"
|
||||
* @parameter expression="${sampler.interval}" default-value="5000"
|
||||
* @required
|
||||
*/
|
||||
private String topic;
|
||||
private String interval;
|
||||
|
||||
/**
|
||||
* @parameter expression="${subject}" default-value="FOO.BAR"
|
||||
* @parameter expression="${sampler.rampUpTime}" default-value="10000"
|
||||
* @required
|
||||
*/
|
||||
private String subject;
|
||||
private String rampUpTime;
|
||||
|
||||
/**
|
||||
* @parameter expression="${durable}" default-value="false"
|
||||
* @parameter expression="${sampler.rampDownTime}" default-value="10000"
|
||||
* @required
|
||||
*/
|
||||
private String rampDownTime;
|
||||
|
||||
/**
|
||||
* @parameter expression="${client.spiClass}" default-value="org.apache.activemq.tool.spi.ActiveMQPojoSPI"
|
||||
* @required
|
||||
*/
|
||||
private String spiClass;
|
||||
|
||||
/**
|
||||
* @parameter expression="${client.sessTransacted}" default-value="false"
|
||||
* @required
|
||||
*/
|
||||
private String sessTransacted;
|
||||
|
||||
/**
|
||||
* @parameter expression="${client.sessAckMode}" default-value="autoAck"
|
||||
* @required
|
||||
*/
|
||||
private String sessAckMode;
|
||||
|
||||
/**
|
||||
* @parameter expression="${client.destName}" default-value="topic://FOO.BAR.TEST"
|
||||
* @required
|
||||
*/
|
||||
private String destName;
|
||||
|
||||
/**
|
||||
* @parameter expression="${client.destCount}" default-value="1"
|
||||
* @required
|
||||
*/
|
||||
private String destCount;
|
||||
|
||||
/**
|
||||
* @parameter expression="${client.destComposite}" default-value="false"
|
||||
* @required
|
||||
*/
|
||||
private String destComposite;
|
||||
|
||||
/**
|
||||
* @parameter expression="${consumer.durable}" default-value="false"
|
||||
* @required
|
||||
*/
|
||||
private String durable;
|
||||
|
||||
/**
|
||||
* @parameter expression="${maximumMessage}" default-value="10"
|
||||
* @parameter expression="${consumer.asyncRecv}" default-value="true"
|
||||
* @required
|
||||
*/
|
||||
private String maximumMessage;
|
||||
private String asyncRecv;
|
||||
|
||||
/**
|
||||
* @parameter expression="${consumer.recvCount}" default-value="1000"
|
||||
* @required
|
||||
*/
|
||||
private String recvCount;
|
||||
|
||||
/**
|
||||
* @parameter expression="${consumer.recvDuration}" default-value="60000"
|
||||
* @required
|
||||
*/
|
||||
private String recvDuration;
|
||||
|
||||
/**
|
||||
* @parameter expression="${consumer.recvType}" default-value="time"
|
||||
* @required
|
||||
*/
|
||||
private String recvType;
|
||||
|
||||
/**
|
||||
* @parameter expression="${factory.brokerUrl}" default-value="tcp://localhost:61616"
|
||||
* @required
|
||||
*/
|
||||
private String brokerUrl;
|
||||
|
||||
/**
|
||||
* @parameter expression="${factory.optimAck}" default-value="true"
|
||||
* @required
|
||||
*/
|
||||
private String optimAck;
|
||||
|
||||
/**
|
||||
* @parameter expression="${factory.optimDispatch}" default-value="true"
|
||||
* @required
|
||||
*/
|
||||
private String optimDispatch;
|
||||
|
||||
/**
|
||||
* @parameter expression="${factory.prefetchQueue}" default-value="10"
|
||||
* @required
|
||||
*/
|
||||
private String prefetchQueue;
|
||||
|
||||
/**
|
||||
* @parameter expression="${factory.prefetchTopic}" default-value="10"
|
||||
* @required
|
||||
*/
|
||||
private String prefetchTopic;
|
||||
|
||||
/**
|
||||
* @parameter expression="${factory.useRetroactive}" default-value="false"
|
||||
* @required
|
||||
*/
|
||||
private String useRetroactive;
|
||||
|
||||
/**
|
||||
* @parameter expression="${sysTest.numClients}" default-value="5"
|
||||
* @required
|
||||
*/
|
||||
private String numClients;
|
||||
|
||||
/**
|
||||
* @parameter expression="${sysTest.totalDests}" default-value="5"
|
||||
* @required
|
||||
*/
|
||||
private String totalDests;
|
||||
|
||||
/**
|
||||
* @parameter expression="${sysTest.destDistro}" default-value="all"
|
||||
* @required
|
||||
*/
|
||||
private String destDistro;
|
||||
|
||||
/**
|
||||
* @parameter expression="${sysTest.reportDirectory}" default-value="${project.build.directory}/test-perf"
|
||||
* @required
|
||||
*/
|
||||
private String reportDirectory;
|
||||
|
||||
public void execute()
|
||||
throws MojoExecutionException {
|
||||
|
||||
String[] args = {url, topic, subject, durable, maximumMessage};
|
||||
try {
|
||||
JmsConsumerClient.main(args);
|
||||
JmsConsumerSystem.main(createArgument());
|
||||
} catch (JMSException e) {
|
||||
throw new MojoExecutionException("Error Executing Consumer: " + e.getMessage());
|
||||
throw new MojoExecutionException(e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String[] createArgument() {
|
||||
String[] options = new String[25];
|
||||
options[0] = "-Dsampler.duration=" + duration; // 1 min
|
||||
options[1] = "-Dsampler.interval=" + interval; // 5 secs
|
||||
options[2] = "-Dsampler.rampUpTime=" + rampUpTime; // 10 secs
|
||||
options[3] = "-Dsampler.rampDownTime=" + rampDownTime; // 10 secs
|
||||
|
||||
options[4] = "-Dclient.spiClass=" + spiClass;
|
||||
options[5] = "-Dclient.sessTransacted=" + sessTransacted;
|
||||
options[6] = "-Dclient.sessAckMode=" + sessAckMode;
|
||||
options[7] = "-Dclient.destName=" + destName;
|
||||
options[8] = "-Dclient.destCount=" + destCount;
|
||||
options[9] = "-Dclient.destComposite=" + destComposite;
|
||||
|
||||
options[10] = "-Dconsumer.durable=" + durable;
|
||||
options[11] = "-Dconsumer.asyncRecv=" + asyncRecv;
|
||||
options[12] = "-Dconsumer.recvCount=" + recvCount; // 1000 messages
|
||||
options[13] = "-Dconsumer.recvDuration=" + recvDuration; // 1 min
|
||||
options[14] = "-Dconsumer.recvType=" + recvType;
|
||||
|
||||
options[15] = "-Dfactory.brokerUrl=" + brokerUrl;
|
||||
options[16] = "-Dfactory.optimAck=" + optimAck;
|
||||
options[17] = "-Dfactory.optimDispatch=" + optimDispatch;
|
||||
options[18] = "-Dfactory.prefetchQueue=" + prefetchQueue;
|
||||
options[19] = "-Dfactory.prefetchTopic=" + prefetchTopic;
|
||||
options[20] = "-Dfactory.useRetroactive=" + useRetroactive;
|
||||
|
||||
options[21] = "-DsysTest.numClients=" + numClients;
|
||||
options[22] = "-DsysTest.totalDests=" + totalDests;
|
||||
options[23] = "-DsysTest.destDistro=" + destDistro;
|
||||
options[24] = "-DsysTest.reportDirectory=" + reportDirectory;
|
||||
|
||||
return options;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
package org.apache.activemq.maven;
|
||||
|
||||
import org.apache.activemq.tool.JmsProducerClient;
|
||||
import org.apache.activemq.tool.JmsProducerSystem;
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
|
||||
import javax.jms.JMSException;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
|
@ -33,44 +31,159 @@ public class ProducerMojo
|
|||
extends AbstractMojo {
|
||||
|
||||
/**
|
||||
* @parameter expression="${url}" default-value="tcp://localhost:61616"
|
||||
* @parameter expression="${sampler.durable}" default-value="60000"
|
||||
* @required
|
||||
*/
|
||||
private String url;
|
||||
private String duration;
|
||||
|
||||
/**
|
||||
* @parameter expression="${topic}" default-value="true"
|
||||
* @parameter expression="${sampler.interval}" default-value="5000"
|
||||
* @required
|
||||
*/
|
||||
private String topic;
|
||||
private String interval;
|
||||
|
||||
/**
|
||||
* @parameter expression="${subject}" default-value="FOO.BAR"
|
||||
* @parameter expression="${sampler.rampUpTime}" default-value="10000"
|
||||
* @required
|
||||
*/
|
||||
private String subject;
|
||||
private String rampUpTime;
|
||||
|
||||
/**
|
||||
* @parameter expression="${durable}" default-value="false"
|
||||
* @parameter expression="${sampler.rampDownTime}" default-value="10000"
|
||||
* @required
|
||||
*/
|
||||
private String durable;
|
||||
private String rampDownTime;
|
||||
|
||||
/**
|
||||
* @parameter expression="${messageCount}" default-value="10"
|
||||
* @parameter expression="${client.spiClass}" default-value="org.apache.activemq.tool.spi.ActiveMQPojoSPI"
|
||||
* @required
|
||||
*/
|
||||
private String messageCount;
|
||||
private String spiClass;
|
||||
|
||||
/**
|
||||
* @parameter expression="${messageSize}" default-value="255"
|
||||
* @parameter expression="${client.sessTransacted}" default-value="false"
|
||||
* @required
|
||||
*/
|
||||
private String sessTransacted;
|
||||
|
||||
/**
|
||||
* @parameter expression="${client.sessAckMode}" default-value="autoAck"
|
||||
* @required
|
||||
*/
|
||||
private String sessAckMode;
|
||||
|
||||
/**
|
||||
* @parameter expression="${client.destName}" default-value="topic://FOO.BAR.TEST"
|
||||
* @required
|
||||
*/
|
||||
private String destName;
|
||||
|
||||
/**
|
||||
* @parameter expression="${client.destCount}" default-value="1"
|
||||
* @required
|
||||
*/
|
||||
private String destCount;
|
||||
|
||||
/**
|
||||
* @parameter expression="${client.destComposite}" default-value="false"
|
||||
* @required
|
||||
*/
|
||||
private String destComposite;
|
||||
|
||||
/**
|
||||
* @parameter expression="${producer.messageSize}" default-value="1024"
|
||||
* @required
|
||||
*/
|
||||
private String messageSize;
|
||||
|
||||
/**
|
||||
* @parameter expression="${producer.sendCount}" default-value="1000"
|
||||
* @required
|
||||
*/
|
||||
private String sendCount;
|
||||
|
||||
/**
|
||||
* @parameter expression="${producer.sendDuration}" default-value="60000"
|
||||
* @required
|
||||
*/
|
||||
private String sendDuration;
|
||||
|
||||
/**
|
||||
* @parameter expression="${producer.sendType}" default-value="time"
|
||||
* @required
|
||||
*/
|
||||
private String sendType;
|
||||
|
||||
/**
|
||||
* @parameter expression="${factory.brokerUrl}" default-value="tcp://localhost:61616"
|
||||
* @required
|
||||
*/
|
||||
private String brokerUrl;
|
||||
|
||||
/**
|
||||
* @parameter expression="${factory.asyncSend}" default-value="true"
|
||||
* @required
|
||||
*/
|
||||
private String asyncSend;
|
||||
|
||||
/**
|
||||
* @parameter expression="${sysTest.numClients}" default-value="5"
|
||||
* @required
|
||||
*/
|
||||
private String numClients;
|
||||
|
||||
/**
|
||||
* @parameter expression="${sysTest.totalDests}" default-value="5"
|
||||
* @required
|
||||
*/
|
||||
private String totalDests;
|
||||
|
||||
/**
|
||||
* @parameter expression="${sysTest.destDistro}" default-value="all"
|
||||
* @required
|
||||
*/
|
||||
private String destDistro;
|
||||
|
||||
/**
|
||||
* @parameter expression="${sysTest.reportDirectory}" default-value="${project.build.directory}/test-perf"
|
||||
* @required
|
||||
*/
|
||||
private String reportDirectory;
|
||||
|
||||
|
||||
public void execute()
|
||||
throws MojoExecutionException {
|
||||
|
||||
String[] args = {url, topic, subject, durable, messageCount, messageSize};
|
||||
try {
|
||||
JmsProducerClient.main(args);
|
||||
} catch (JMSException e) {
|
||||
throw new MojoExecutionException("Error executing Producer: " + e.getMessage());
|
||||
}
|
||||
JmsProducerSystem.main(createArgument());
|
||||
}
|
||||
|
||||
public String[] createArgument() {
|
||||
String[] options = new String[25];
|
||||
options[0] = "-Dsampler.duration=" + duration; // 1 min
|
||||
options[1] = "-Dsampler.interval=" + interval; // 5 secs
|
||||
options[2] = "-Dsampler.rampUpTime=" + rampUpTime; // 10 secs
|
||||
options[3] = "-Dsampler.rampDownTime=" + rampDownTime; // 10 secs
|
||||
|
||||
options[4] = "-Dclient.spiClass=" + spiClass;
|
||||
options[5] = "-Dclient.sessTransacted=" + sessTransacted;
|
||||
options[6] = "-Dclient.sessAckMode=" + sessAckMode;
|
||||
options[7] = "-Dclient.destName=" + destName;
|
||||
options[8] = "-Dclient.destCount=" + destCount;
|
||||
options[9] = "-Dclient.destComposite=" + destComposite;
|
||||
|
||||
options[10] = "-Dproducer.messageSize="+messageSize;
|
||||
options[11] = "-Dproducer.sendCount="+sendCount; // 1000 messages
|
||||
options[12] = "-Dproducer.sendDuration="+sendDuration; // 1 min
|
||||
options[13] = "-Dproducer.sendType="+sendType;
|
||||
|
||||
options[14] = "-Dfactory.brokerUrl="+brokerUrl;
|
||||
options[15] = "-Dfactory.asyncSend="+asyncSend;
|
||||
|
||||
options[21] = "-DsysTest.numClients=" + numClients;
|
||||
options[22] = "-DsysTest.totalDests=" + totalDests;
|
||||
options[23] = "-DsysTest.destDistro=" + destDistro;
|
||||
options[24] = "-DsysTest.reportDirectory=" + reportDirectory;
|
||||
|
||||
return options;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ public abstract class JmsClientSystemSupport {
|
|||
protected Properties jmsClientSettings = new Properties();
|
||||
protected ThreadGroup clientThreadGroup;
|
||||
protected PerfMeasurementTool performanceSampler;
|
||||
protected String reportDirectory;
|
||||
|
||||
protected int numClients = 1;
|
||||
protected int totalDests = 1;
|
||||
|
@ -48,6 +49,13 @@ public abstract class JmsClientSystemSupport {
|
|||
performanceSampler = new PerfMeasurementTool();
|
||||
performanceSampler.setSamplerSettings(samplerSettings);
|
||||
|
||||
PerfReportGenerator report = new PerfReportGenerator();
|
||||
report.setReportDirectory(this.getReportDirectory());
|
||||
report.setReportName(this.getClass().toString());
|
||||
report.startGenerateReport();
|
||||
|
||||
performanceSampler.setDataOutputStream(report.getDataOutputStream());
|
||||
|
||||
clientThreadGroup = new ThreadGroup(getThreadGroupName());
|
||||
for (int i=0; i<getNumClients(); i++) {
|
||||
final Properties clientSettings = new Properties();
|
||||
|
@ -65,6 +73,9 @@ public abstract class JmsClientSystemSupport {
|
|||
}
|
||||
|
||||
performanceSampler.startSampler();
|
||||
performanceSampler.waitForSamplerToFinish(0);
|
||||
|
||||
report.stopGenerateReport();
|
||||
}
|
||||
|
||||
protected void distributeDestinations(String distroType, int clientIndex, int numClients, int numDests, Properties clientSettings) {
|
||||
|
@ -161,6 +172,14 @@ public abstract class JmsClientSystemSupport {
|
|||
}
|
||||
}
|
||||
|
||||
public String getReportDirectory(){
|
||||
return reportDirectory;
|
||||
}
|
||||
|
||||
public void setReportDirectory(String reportDirectory){
|
||||
this.reportDirectory = reportDirectory;
|
||||
}
|
||||
|
||||
public Properties getSysTestSettings() {
|
||||
return sysTestSettings;
|
||||
}
|
||||
|
|
|
@ -253,7 +253,7 @@ public class JmsConsumerClient extends JmsPerformanceSupport {
|
|||
}
|
||||
|
||||
public static void main(String[] args) throws JMSException {
|
||||
String[] options = new String[21];
|
||||
/*String[] options = new String[21];
|
||||
options[0] = "-Dsampler.duration=60000"; // 1 min
|
||||
options[1] = "-Dsampler.interval=5000"; // 5 secs
|
||||
options[2] = "-Dsampler.rampUpTime=10000"; // 10 secs
|
||||
|
@ -279,7 +279,7 @@ public class JmsConsumerClient extends JmsPerformanceSupport {
|
|||
options[19] = "-Dfactory.prefetchTopic=32767";
|
||||
options[20] = "-Dfactory.useRetroactive=false";
|
||||
|
||||
args = options;
|
||||
args = options; */
|
||||
|
||||
Properties samplerSettings = new Properties();
|
||||
Properties consumerSettings = new Properties();
|
||||
|
|
|
@ -52,7 +52,7 @@ public class JmsConsumerSystem extends JmsClientSystemSupport {
|
|||
}
|
||||
|
||||
public static void main(String[] args) throws JMSException {
|
||||
String[] options = new String[24];
|
||||
/*String[] options = new String[24];
|
||||
options[0] = "-Dsampler.duration=60000"; // 1 min
|
||||
options[1] = "-Dsampler.interval=5000"; // 5 secs
|
||||
options[2] = "-Dsampler.rampUpTime=10000"; // 10 secs
|
||||
|
@ -82,7 +82,7 @@ public class JmsConsumerSystem extends JmsClientSystemSupport {
|
|||
options[22] = "-DsysTest.totalDests=5";
|
||||
options[23] = "-DsysTest.destDistro=all";
|
||||
|
||||
args = options;
|
||||
args = options;*/
|
||||
|
||||
Properties sysSettings = new Properties();
|
||||
for (int i=0; i<args.length; i++) {
|
||||
|
@ -97,6 +97,7 @@ public class JmsConsumerSystem extends JmsClientSystemSupport {
|
|||
}
|
||||
|
||||
JmsConsumerSystem sysTest = new JmsConsumerSystem();
|
||||
sysTest.setReportDirectory("./target/Test-perf");
|
||||
sysTest.setSettings(sysSettings);
|
||||
sysTest.runSystemTest();
|
||||
}
|
||||
|
|
|
@ -291,7 +291,7 @@ public class JmsProducerClient extends JmsPerformanceSupport {
|
|||
}
|
||||
|
||||
public static void main(String[] args) throws JMSException {
|
||||
String[] options = new String[16];
|
||||
/*String[] options = new String[16];
|
||||
options[0] = "-Dsampler.duration=60000"; // 1 min
|
||||
options[1] = "-Dsampler.interval=5000"; // 5 secs
|
||||
options[2] = "-Dsampler.rampUpTime=10000"; // 10 secs
|
||||
|
@ -312,7 +312,7 @@ public class JmsProducerClient extends JmsPerformanceSupport {
|
|||
options[14] = "-Dfactory.brokerUrl=tcp://localhost:61616";
|
||||
options[15] = "-Dfactory.asyncSend=true";
|
||||
|
||||
args = options;
|
||||
args = options;*/
|
||||
|
||||
Properties samplerSettings = new Properties();
|
||||
Properties producerSettings = new Properties();
|
||||
|
|
|
@ -52,7 +52,7 @@ public class JmsProducerSystem extends JmsClientSystemSupport {
|
|||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String[] options = new String[19];
|
||||
/*String[] options = new String[19];
|
||||
options[0] = "-Dsampler.duration=60000"; // 1 min
|
||||
options[1] = "-Dsampler.interval=5000"; // 5 secs
|
||||
options[2] = "-Dsampler.rampUpTime=10000"; // 10 secs
|
||||
|
@ -77,7 +77,7 @@ public class JmsProducerSystem extends JmsClientSystemSupport {
|
|||
options[17] = "-DsysTest.totalDests=5";
|
||||
options[18] = "-DsysTest.destDistro=all";
|
||||
|
||||
args = options;
|
||||
args = options;*/
|
||||
|
||||
Properties sysSettings = new Properties();
|
||||
|
||||
|
@ -93,6 +93,7 @@ public class JmsProducerSystem extends JmsClientSystemSupport {
|
|||
}
|
||||
|
||||
JmsProducerSystem sysTest = new JmsProducerSystem();
|
||||
sysTest.setReportDirectory("./target/Test-perf");
|
||||
sysTest.setSettings(sysSettings);
|
||||
sysTest.runSystemTest();
|
||||
}
|
||||
|
|
|
@ -19,23 +19,26 @@ package org.apache.activemq.tool;
|
|||
import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import javax.jms.JMSException;
|
||||
import java.util.List;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
public class PerfMeasurementTool implements PerfEventListener, Runnable {
|
||||
public static final String PREFIX_CONFIG_SYSTEM_TEST = "sampler.";
|
||||
|
||||
private long duration = 5 * 60 * 1000; // 5 mins by default test duration
|
||||
private long interval = 1000; // 1 sec sample interval
|
||||
private long rampUpTime = 1 * 60 * 1000; // 1 min default test ramp up time
|
||||
private long duration = 5 * 60 * 1000; // 5 mins by default test duration
|
||||
private long interval = 1000; // 1 sec sample interval
|
||||
private long rampUpTime = 1 * 60 * 1000; // 1 min default test ramp up time
|
||||
private long rampDownTime = 1 * 60 * 1000; // 1 min default test ramp down time
|
||||
private long sampleIndex = 0;
|
||||
private long sampleIndex = 0;
|
||||
|
||||
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 DataOutputStream dataDoutputStream = null;
|
||||
private Properties samplerSettings = new Properties();
|
||||
|
||||
private List perfClients = new ArrayList();
|
||||
|
@ -46,7 +49,7 @@ public class PerfMeasurementTool implements PerfEventListener, Runnable {
|
|||
}
|
||||
|
||||
public void registerClient(PerfMeasurable[] clients) {
|
||||
for (int i=0; i<clients.length; i++) {
|
||||
for (int i = 0; i < clients.length; i++) {
|
||||
registerClient(clients[i]);
|
||||
}
|
||||
}
|
||||
|
@ -60,6 +63,14 @@ public class PerfMeasurementTool implements PerfEventListener, Runnable {
|
|||
ReflectionUtil.configureClass(this, samplerSettings);
|
||||
}
|
||||
|
||||
public DataOutputStream getDataOutputStream() {
|
||||
return dataDoutputStream;
|
||||
}
|
||||
|
||||
public void setDataOutputStream(DataOutputStream dataDoutputStream) {
|
||||
this.dataDoutputStream = dataDoutputStream;
|
||||
}
|
||||
|
||||
public long getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
@ -135,8 +146,8 @@ public class PerfMeasurementTool implements PerfEventListener, Runnable {
|
|||
}
|
||||
|
||||
// Let's reset the throughput first and start getting the samples
|
||||
for (Iterator i=perfClients.iterator(); i.hasNext();) {
|
||||
PerfMeasurable client = (PerfMeasurable)i.next();
|
||||
for (Iterator i = perfClients.iterator(); i.hasNext();) {
|
||||
PerfMeasurable client = (PerfMeasurable) i.next();
|
||||
client.reset();
|
||||
}
|
||||
|
||||
|
@ -157,10 +168,10 @@ public class PerfMeasurementTool implements PerfEventListener, Runnable {
|
|||
}
|
||||
|
||||
public void sampleClients() {
|
||||
for (Iterator i=perfClients.iterator(); i.hasNext();) {
|
||||
PerfMeasurable client = (PerfMeasurable)i.next();
|
||||
System.out.println("<sample index=" + sampleIndex + " name=" + client.getClientName() +
|
||||
" throughput=" + client.getThroughput() + "/>");
|
||||
for (Iterator i = perfClients.iterator(); i.hasNext();) {
|
||||
PerfMeasurable client = (PerfMeasurable) i.next();
|
||||
writeResult("<sample index=" + sampleIndex + " name=" + client.getClientName() +
|
||||
" throughput=" + client.getThroughput() + "/>\n");
|
||||
client.reset();
|
||||
}
|
||||
}
|
||||
|
@ -175,4 +186,12 @@ public class PerfMeasurementTool implements PerfEventListener, Runnable {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void writeResult(String result) {
|
||||
try {
|
||||
getDataOutputStream().writeChars(result);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
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;
|
||||
|
||||
/**
|
||||
* 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 Properties clientSetting;
|
||||
|
||||
public PerfReportGenerator() {
|
||||
}
|
||||
|
||||
public PerfReportGenerator(String reportDirectory, String reportName) {
|
||||
this.setReportDirectory(reportDirectory);
|
||||
this.setReportName(reportName);
|
||||
}
|
||||
|
||||
public void startGenerateReport() {
|
||||
|
||||
setReportDirectory(reportDirectory);
|
||||
setReportName(reportName);
|
||||
|
||||
File reportDir = new File(getReportDirectory());
|
||||
|
||||
// Create output directory if it doesn't exist.
|
||||
if (!reportDir.exists()) {
|
||||
reportDir.mkdirs();
|
||||
}
|
||||
|
||||
File reportFile = null;
|
||||
if (reportDir != null) {
|
||||
reportFile = new File(reportDirectory + File.separator + reportName + ".xml");
|
||||
}
|
||||
|
||||
try {
|
||||
dataOutputStream = new DataOutputStream(new FileOutputStream(reportFile));
|
||||
dataOutputStream.writeChars(getTestInformation().toString());
|
||||
} 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.
|
||||
}
|
||||
}
|
||||
|
||||
protected String getTestInformation() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
|
||||
buffer.append("<test-report>\n");
|
||||
buffer.append("<test-information>\n");
|
||||
buffer.append("<os-name>" + System.getProperty("os.name") + "</os-name>\n");
|
||||
buffer.append("<java-version>" + System.getProperty("java.version") + "</java-version>\n");
|
||||
buffer.append("</test-information>\n");
|
||||
buffer.append("<test-result>\n");
|
||||
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
public DataOutputStream getDataOutputStream() {
|
||||
return this.dataOutputStream;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue