- Added summary for CPU usage

- Fix compiler error for ActiveMQPojoSPI

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@420537 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Adrian T. Co 2006-07-10 14:19:28 +00:00
parent 9b07e4323a
commit fddc01d97c
10 changed files with 299 additions and 58 deletions

View File

@ -23,6 +23,10 @@ import org.apache.activemq.tool.reports.plugins.CpuReportPlugin;
import java.util.Map; import java.util.Map;
public abstract class AbstractPerfReportWriter implements PerformanceReportWriter { public abstract class AbstractPerfReportWriter implements PerformanceReportWriter {
public static final int REPORT_PLUGIN_THROUGHPUT = 0;
public static final int REPORT_PLUGIN_CPU = 1;
protected ReportPlugin[] plugins = new ReportPlugin[] { protected ReportPlugin[] plugins = new ReportPlugin[] {
new ThroughputReportPlugin(), new ThroughputReportPlugin(),
new CpuReportPlugin() new CpuReportPlugin()

View File

@ -23,67 +23,67 @@ public final class PerformanceStatisticsUtil {
private PerformanceStatisticsUtil() { private PerformanceStatisticsUtil() {
} }
public static long getTotalThroughput(List totalTPList) { public static long getSum(List numList) {
long totalTP = 0; long sum = 0;
if (totalTPList != null) { if (numList != null) {
for (Iterator i=totalTPList.iterator(); i.hasNext();) { for (Iterator i=numList.iterator(); i.hasNext();) {
totalTP += ((Long)i.next()).longValue(); sum += ((Long)i.next()).longValue();
} }
} else { } else {
totalTP = -1; sum = -1;
} }
return totalTP; return sum;
} }
public static long getMinThroughput(List totalTPList) { public static long getMin(List numList) {
long minTP = Long.MAX_VALUE; long min = Long.MAX_VALUE;
if (totalTPList != null) { if (numList != null) {
for (Iterator i=totalTPList.iterator(); i.hasNext();) { for (Iterator i=numList.iterator(); i.hasNext();) {
minTP = Math.min(((Long)i.next()).longValue(), minTP); min = Math.min(((Long)i.next()).longValue(), min);
} }
} else { } else {
minTP = -1; min = -1;
} }
return minTP; return min;
} }
public static long getMaxThroughput(List totalTPList) { public static long getMax(List numList) {
long maxTP = Long.MIN_VALUE; long max = Long.MIN_VALUE;
if (totalTPList != null) { if (numList != null) {
for (Iterator i=totalTPList.iterator(); i.hasNext();) { for (Iterator i=numList.iterator(); i.hasNext();) {
maxTP = Math.max(((Long)i.next()).longValue(), maxTP); max = Math.max(((Long)i.next()).longValue(), max);
} }
} else { } else {
maxTP = -1; max = -1;
} }
return maxTP; return max;
} }
public static double getAveThroughput(List totalTPList) { public static double getAve(List numList) {
double aveTP; double ave;
if (totalTPList != null) { if (numList != null) {
int sampleCount = 0; int sampleCount = 0;
long totalTP = 0; long totalTP = 0;
for (Iterator i=totalTPList.iterator(); i.hasNext();) { for (Iterator i=numList.iterator(); i.hasNext();) {
sampleCount++; sampleCount++;
totalTP += ((Long)i.next()).longValue(); totalTP += ((Long)i.next()).longValue();
} }
return (double)totalTP / (double)sampleCount; return (double)totalTP / (double)sampleCount;
} else { } else {
aveTP = -1; ave = -1;
} }
return aveTP; return ave;
} }
public static double getAveThroughputExcludingMinMax(List totalTPList) { public static double getAveEx(List numList) {
double aveTP; double ave;
long minTP = getMinThroughput(totalTPList); long minTP = getMin(numList);
long maxTP = getMaxThroughput(totalTPList); long maxTP = getMax(numList);
if (totalTPList != null) { if (numList != null) {
int sampleCount = 0; int sampleCount = 0;
long totalTP = 0; long totalTP = 0;
long sampleTP; long sampleTP;
for (Iterator i=totalTPList.iterator(); i.hasNext();) { for (Iterator i=numList.iterator(); i.hasNext();) {
sampleCount++; sampleCount++;
sampleTP = ((Long)i.next()).longValue(); sampleTP = ((Long)i.next()).longValue();
if (sampleTP != minTP && sampleTP != maxTP) { if (sampleTP != minTP && sampleTP != maxTP) {
@ -92,9 +92,9 @@ public final class PerformanceStatisticsUtil {
} }
return (double)totalTP / (double)sampleCount; return (double)totalTP / (double)sampleCount;
} else { } else {
aveTP = -1; ave = -1;
} }
return aveTP; return ave;
} }
} }

View File

@ -18,6 +18,7 @@ package org.apache.activemq.tool.reports;
import org.apache.activemq.tool.reports.plugins.ReportPlugin; import org.apache.activemq.tool.reports.plugins.ReportPlugin;
import org.apache.activemq.tool.reports.plugins.ThroughputReportPlugin; import org.apache.activemq.tool.reports.plugins.ThroughputReportPlugin;
import org.apache.activemq.tool.reports.plugins.CpuReportPlugin;
import java.util.Properties; import java.util.Properties;
import java.util.Iterator; import java.util.Iterator;
@ -40,9 +41,9 @@ public class VerbosePerfReportWriter extends AbstractPerfReportWriter {
} }
public void writeCsvData(int csvType, String csvData) { public void writeCsvData(int csvType, String csvData) {
if (csvType == ReportPlugin.REPORT_PLUGIN_THROUGHPUT) { if (csvType == REPORT_PLUGIN_THROUGHPUT) {
System.out.println("[PERF-TP]: " + csvData); System.out.println("[PERF-TP]: " + csvData);
} else if (csvType == ReportPlugin.REPORT_PLUGIN_CPU) { } else if (csvType == REPORT_PLUGIN_CPU) {
System.out.println("[PERF-CPU]: " + csvData); System.out.println("[PERF-CPU]: " + csvData);
} }
handleCsvData(csvType, csvData); handleCsvData(csvType, csvData);
@ -62,8 +63,23 @@ public class VerbosePerfReportWriter extends AbstractPerfReportWriter {
} }
public void writePerfSummary() { public void writePerfSummary() {
Map summary = getSummary(ReportPlugin.REPORT_PLUGIN_THROUGHPUT);
Map summary;
summary = getSummary(REPORT_PLUGIN_THROUGHPUT);
if (summary != null && summary.size() > 0) {
writeThroughputSummary(summary);
}
summary = getSummary(REPORT_PLUGIN_CPU);
if (summary != null && summary.size() > 0) {
writeCpuSummary(summary);
}
}
protected void writeThroughputSummary(Map summary) {
writeHeader("SYSTEM THROUGHPUT SUMMARY");
System.out.println("[PERF-TP-SUMMARY] System Total Throughput: " + summary.get(ThroughputReportPlugin.KEY_SYS_TOTAL_TP)); System.out.println("[PERF-TP-SUMMARY] System Total Throughput: " + summary.get(ThroughputReportPlugin.KEY_SYS_TOTAL_TP));
System.out.println("[PERF-TP-SUMMARY] System Total Clients: " + summary.get(ThroughputReportPlugin.KEY_SYS_TOTAL_CLIENTS)); System.out.println("[PERF-TP-SUMMARY] System Total Clients: " + summary.get(ThroughputReportPlugin.KEY_SYS_TOTAL_CLIENTS));
System.out.println("[PERF-TP-SUMMARY] System Average Throughput: " + summary.get(ThroughputReportPlugin.KEY_SYS_AVE_TP)); System.out.println("[PERF-TP-SUMMARY] System Average Throughput: " + summary.get(ThroughputReportPlugin.KEY_SYS_AVE_TP));
@ -80,6 +96,30 @@ public class VerbosePerfReportWriter extends AbstractPerfReportWriter {
System.out.println("[PERF-TP-SUMMARY] Max Client Average Throughput Excluding Min/Max: " + summary.get(ThroughputReportPlugin.KEY_MAX_CLIENT_AVE_EMM_TP)); System.out.println("[PERF-TP-SUMMARY] Max Client Average Throughput Excluding Min/Max: " + summary.get(ThroughputReportPlugin.KEY_MAX_CLIENT_AVE_EMM_TP));
} }
protected void writeCpuSummary(Map summary) {
writeHeader("SYSTEM CPU USAGE SUMMARY");
System.out.println("[PERF-CPU-SUMMARY] Total Blocks Received: " + summary.get(CpuReportPlugin.KEY_BLOCK_RECV));
System.out.println("[PERF-CPU-SUMMARY] Ave Blocks Received: " + summary.get(CpuReportPlugin.KEY_AVE_BLOCK_RECV));
System.out.println("[PERF-CPU-SUMMARY] Total Blocks Sent: " + summary.get(CpuReportPlugin.KEY_BLOCK_SENT));
System.out.println("[PERF-CPU-SUMMARY] Ave Blocks Sent: " + summary.get(CpuReportPlugin.KEY_AVE_BLOCK_SENT));
System.out.println("[PERF-CPU-SUMMARY] Total Context Switches: " + summary.get(CpuReportPlugin.KEY_CTX_SWITCH));
System.out.println("[PERF-CPU-SUMMARY] Ave Context Switches: " + summary.get(CpuReportPlugin.KEY_AVE_CTX_SWITCH));
System.out.println("[PERF-CPU-SUMMARY] Total User Time: " + summary.get(CpuReportPlugin.KEY_USER_TIME));
System.out.println("[PERF-CPU-SUMMARY] Ave User Time: " + summary.get(CpuReportPlugin.KEY_AVE_USER_TIME));
System.out.println("[PERF-CPU-SUMMARY] Total System Time: " + summary.get(CpuReportPlugin.KEY_SYS_TIME));
System.out.println("[PERF-CPU-SUMMARY] Ave System Time: " + summary.get(CpuReportPlugin.KEY_AVE_SYS_TIME));
System.out.println("[PERF-CPU-SUMMARY] Total Idle Time: " + summary.get(CpuReportPlugin.KEY_IDLE_TIME));
System.out.println("[PERF-CPU-SUMMARY] Ave Idle Time: " + summary.get(CpuReportPlugin.KEY_AVE_IDLE_TIME));
System.out.println("[PERF-CPU-SUMMARY] Total Wait Time: " + summary.get(CpuReportPlugin.KEY_WAIT_TIME));
System.out.println("[PERF-CPU-SUMMARY] Ave Wait Time: " + summary.get(CpuReportPlugin.KEY_AVE_WAIT_TIME));
}
protected void writeHeader(String header) { protected void writeHeader(String header) {
char[] border = new char[header.length() + 8]; // +8 for spacing char[] border = new char[header.length() + 8]; // +8 for spacing
Arrays.fill(border, '#'); Arrays.fill(border, '#');

View File

@ -20,6 +20,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.activemq.tool.reports.plugins.ReportPlugin; import org.apache.activemq.tool.reports.plugins.ReportPlugin;
import org.apache.activemq.tool.reports.plugins.ThroughputReportPlugin; import org.apache.activemq.tool.reports.plugins.ThroughputReportPlugin;
import org.apache.activemq.tool.reports.plugins.CpuReportPlugin;
import java.util.Properties; import java.util.Properties;
import java.util.List; import java.util.List;
@ -114,9 +115,9 @@ public class XmlFilePerfReportWriter extends AbstractPerfReportWriter {
} }
public void writeCsvData(int csvType, String csvData) { public void writeCsvData(int csvType, String csvData) {
if (csvType == ReportPlugin.REPORT_PLUGIN_THROUGHPUT) { if (csvType == REPORT_PLUGIN_THROUGHPUT) {
tempLogFileWriter.println("[TP-DATA]" + csvData); tempLogFileWriter.println("[TP-DATA]" + csvData);
} else if (csvType == ReportPlugin.REPORT_PLUGIN_CPU) { } else if (csvType == REPORT_PLUGIN_CPU) {
tempLogFileWriter.println("[CPU-DATA]" + csvData); tempLogFileWriter.println("[CPU-DATA]" + csvData);
} }
} }
@ -198,10 +199,10 @@ public class XmlFilePerfReportWriter extends AbstractPerfReportWriter {
String line; String line;
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
if (line.startsWith("[TP-DATA]")) { if (line.startsWith("[TP-DATA]")) {
handleCsvData(ReportPlugin.REPORT_PLUGIN_THROUGHPUT, line.substring("[TP-DATA]".length())); handleCsvData(REPORT_PLUGIN_THROUGHPUT, line.substring("[TP-DATA]".length()));
parsePerfCsvData("tpdata", line.substring("[TP-DATA]".length())); parsePerfCsvData("tpdata", line.substring("[TP-DATA]".length()));
} else if (line.startsWith("[CPU-DATA]")) { } else if (line.startsWith("[CPU-DATA]")) {
handleCsvData(ReportPlugin.REPORT_PLUGIN_CPU, line.substring("[CPU-DATA]".length())); handleCsvData(REPORT_PLUGIN_CPU, line.substring("[CPU-DATA]".length()));
parsePerfCsvData("cpudata", line.substring("[CPU-DATA]".length())); parsePerfCsvData("cpudata", line.substring("[CPU-DATA]".length()));
} else if (line.startsWith("[INFO]")) { } else if (line.startsWith("[INFO]")) {
xmlFileWriter.println("<info>" + line + "</info>"); xmlFileWriter.println("<info>" + line + "</info>");
@ -215,14 +216,32 @@ public class XmlFilePerfReportWriter extends AbstractPerfReportWriter {
} }
protected void writeXmlPerfSummary() { protected void writeXmlPerfSummary() {
// Write throughput summary
Map summary = getSummary(ReportPlugin.REPORT_PLUGIN_THROUGHPUT);
xmlFileWriter.println("<property name='perfSummary'>"); Map summary;
summary = getSummary(REPORT_PLUGIN_THROUGHPUT);
if (summary != null && summary.size() > 0) {
writeThroughputSummary(summary);
}
summary = getSummary(REPORT_PLUGIN_CPU);
if (summary != null && summary.size() > 0) {
writeCpuSummary(summary);
}
}
protected void writeThroughputSummary(Map summary) {
// Write throughput summary
xmlFileWriter.println("<property name='perfTpSummary'>");
xmlFileWriter.println("<props>"); xmlFileWriter.println("<props>");
String val, clientName, clientVal; String val, clientName, clientVal;
System.out.println("#########################################");
System.out.println("#### SYSTEM THROUGHPUT SUMMARY ####");
System.out.println("#########################################");
val = (String)summary.get(ThroughputReportPlugin.KEY_SYS_TOTAL_TP); val = (String)summary.get(ThroughputReportPlugin.KEY_SYS_TOTAL_TP);
System.out.println("System Total Throughput: " + val); System.out.println("System Total Throughput: " + val);
xmlFileWriter.println("<prop key='" + ThroughputReportPlugin.KEY_SYS_TOTAL_TP + "'>" + val + "</prop>"); xmlFileWriter.println("<prop key='" + ThroughputReportPlugin.KEY_SYS_TOTAL_TP + "'>" + val + "</prop>");
@ -299,6 +318,60 @@ public class XmlFilePerfReportWriter extends AbstractPerfReportWriter {
xmlFileWriter.println("</property>"); xmlFileWriter.println("</property>");
} }
protected void writeCpuSummary(Map summary) {
xmlFileWriter.println("<property name='perfTpSummary'>");
xmlFileWriter.println("<props>");
System.out.println("########################################");
System.out.println("#### SYSTEM CPU USAGE SUMMARY ####");
System.out.println("########################################");
xmlFileWriter.println("<prop key='" + CpuReportPlugin.KEY_BLOCK_RECV + "'>" + summary.get(CpuReportPlugin.KEY_BLOCK_RECV) + "</prop>");
System.out.println("Total Blocks Received: " + summary.get(CpuReportPlugin.KEY_BLOCK_RECV));
xmlFileWriter.println("<prop key='" + CpuReportPlugin.KEY_AVE_BLOCK_RECV + "'>" + summary.get(CpuReportPlugin.KEY_AVE_BLOCK_RECV) + "</prop>");
System.out.println("Ave Blocks Received: " + summary.get(CpuReportPlugin.KEY_AVE_BLOCK_RECV));
xmlFileWriter.println("<prop key='" + CpuReportPlugin.KEY_BLOCK_SENT + "'>" + summary.get(CpuReportPlugin.KEY_BLOCK_SENT) + "</prop>");
System.out.println("Total Blocks Sent: " + summary.get(CpuReportPlugin.KEY_BLOCK_SENT));
xmlFileWriter.println("<prop key='" + CpuReportPlugin.KEY_AVE_BLOCK_SENT + "'>" + summary.get(CpuReportPlugin.KEY_AVE_BLOCK_SENT) + "</prop>");
System.out.println(" Ave Blocks Sent: " + summary.get(CpuReportPlugin.KEY_AVE_BLOCK_SENT));
xmlFileWriter.println("<prop key='" + CpuReportPlugin.KEY_CTX_SWITCH + "'>" + summary.get(CpuReportPlugin.KEY_CTX_SWITCH) + "</prop>");
System.out.println("Total Context Switches: " + summary.get(CpuReportPlugin.KEY_CTX_SWITCH));
xmlFileWriter.println("<prop key='" + CpuReportPlugin.KEY_AVE_CTX_SWITCH + "'>" + summary.get(CpuReportPlugin.KEY_AVE_CTX_SWITCH) + "</prop>");
System.out.println("Ave Context Switches: " + summary.get(CpuReportPlugin.KEY_AVE_CTX_SWITCH));
xmlFileWriter.println("<prop key='" + CpuReportPlugin.KEY_USER_TIME + "'>" + summary.get(CpuReportPlugin.KEY_USER_TIME) + "</prop>");
System.out.println("Total User Time: " + summary.get(CpuReportPlugin.KEY_USER_TIME));
xmlFileWriter.println("<prop key='" + CpuReportPlugin.KEY_AVE_USER_TIME + "'>" + summary.get(CpuReportPlugin.KEY_AVE_USER_TIME) + "</prop>");
System.out.println("Ave User Time: " + summary.get(CpuReportPlugin.KEY_AVE_USER_TIME));
xmlFileWriter.println("<prop key='" + CpuReportPlugin.KEY_SYS_TIME + "'>" + summary.get(CpuReportPlugin.KEY_SYS_TIME) + "</prop>");
System.out.println("Total System Time: " + summary.get(CpuReportPlugin.KEY_SYS_TIME));
xmlFileWriter.println("<prop key='" + CpuReportPlugin.KEY_AVE_SYS_TIME + "'>" + summary.get(CpuReportPlugin.KEY_AVE_SYS_TIME) + "</prop>");
System.out.println("Ave System Time: " + summary.get(CpuReportPlugin.KEY_AVE_SYS_TIME));
xmlFileWriter.println("<prop key='" + CpuReportPlugin.KEY_IDLE_TIME + "'>" + summary.get(CpuReportPlugin.KEY_IDLE_TIME) + "</prop>");
System.out.println("Total Idle Time: " + summary.get(CpuReportPlugin.KEY_IDLE_TIME));
xmlFileWriter.println("<prop key='" + CpuReportPlugin.KEY_AVE_IDLE_TIME + "'>" + summary.get(CpuReportPlugin.KEY_AVE_IDLE_TIME) + "</prop>");
System.out.println("Ave Idle Time: " + summary.get(CpuReportPlugin.KEY_AVE_IDLE_TIME));
xmlFileWriter.println("<prop key='" + CpuReportPlugin.KEY_WAIT_TIME + "'>" + summary.get(CpuReportPlugin.KEY_WAIT_TIME) + "</prop>");
System.out.println("Total Wait Time: " + summary.get(CpuReportPlugin.KEY_WAIT_TIME));
xmlFileWriter.println("<prop key='" + CpuReportPlugin.KEY_AVE_WAIT_TIME + "'>" + summary.get(CpuReportPlugin.KEY_AVE_WAIT_TIME) + "</prop>");
System.out.println("Ave Wait Time: " + summary.get(CpuReportPlugin.KEY_AVE_WAIT_TIME));
xmlFileWriter.println("</props>");
xmlFileWriter.println("</property>");
}
protected void writeMap(String name, Map map) { protected void writeMap(String name, Map map) {
xmlFileWriter.println("<property name='" + name + "'>"); xmlFileWriter.println("<property name='" + name + "'>");
xmlFileWriter.println("<props>"); xmlFileWriter.println("<props>");

View File

@ -16,14 +16,134 @@
*/ */
package org.apache.activemq.tool.reports.plugins; package org.apache.activemq.tool.reports.plugins;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.activemq.tool.reports.PerformanceStatisticsUtil;
import java.util.Map; import java.util.Map;
import java.util.StringTokenizer;
import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
public class CpuReportPlugin implements ReportPlugin { public class CpuReportPlugin implements ReportPlugin {
private static final Log log = LogFactory.getLog(CpuReportPlugin.class);
public static final String NAME_BLOCK_RECV = "bi";
public static final String NAME_BLOCK_SENT = "bu";
public static final String NAME_CTX_SWITCH = "cs";
public static final String NAME_USER_TIME = "us";
public static final String NAME_SYS_TIME = "sy";
public static final String NAME_IDLE_TIME = "id";
public static final String NAME_WAIT_TIME = "wa";
public static final String KEY_BLOCK_RECV = "BlocksReceived";
public static final String KEY_BLOCK_SENT = "BlocksSent";
public static final String KEY_CTX_SWITCH = "ContextSwitches";
public static final String KEY_USER_TIME = "UserTime";
public static final String KEY_SYS_TIME = "SystemTime";
public static final String KEY_IDLE_TIME = "IdleTime";
public static final String KEY_WAIT_TIME = "WaitingTime";
public static final String KEY_AVE_BLOCK_RECV = "AveBlocksReceived";
public static final String KEY_AVE_BLOCK_SENT = "AveBlocksSent";
public static final String KEY_AVE_CTX_SWITCH = "AveContextSwitches";
public static final String KEY_AVE_USER_TIME = "AveUserTime";
public static final String KEY_AVE_SYS_TIME = "AveSystemTime";
public static final String KEY_AVE_IDLE_TIME = "AveIdleTime";
public static final String KEY_AVE_WAIT_TIME = "AveWaitingTime";
protected List blockRecv = new ArrayList();
protected List blockSent = new ArrayList();
protected List ctxSwitch = new ArrayList();
protected List userTime = new ArrayList();
protected List sysTime = new ArrayList();
protected List idleTime = new ArrayList();
protected List waitTime = new ArrayList();
public void handleCsvData(String csvData) { public void handleCsvData(String csvData) {
// Do nothing StringTokenizer tokenizer = new StringTokenizer(csvData, ",");
String data, key, val;
while (tokenizer.hasMoreTokens()) {
data = tokenizer.nextToken();
key = data.substring(0, data.indexOf("="));
val = data.substring(data.indexOf("=") + 1);
addToCpuList(key, val);
}
} }
public Map getSummary() { public Map getSummary() {
return null; // Do nothing long val;
Map summary = new HashMap();
if (blockRecv.size() > 0) {
val = PerformanceStatisticsUtil.getSum(blockRecv);
summary.put(KEY_BLOCK_RECV, String.valueOf(val));
summary.put(KEY_AVE_BLOCK_RECV, String.valueOf((double)val / (double)blockRecv.size()));
}
if (blockSent.size() > 0) {
val = PerformanceStatisticsUtil.getSum(blockSent);
summary.put(KEY_BLOCK_SENT, String.valueOf(val));
summary.put(KEY_AVE_BLOCK_SENT, String.valueOf((double)val / (double)blockSent.size()));
}
if (ctxSwitch.size() > 0) {
val = PerformanceStatisticsUtil.getSum(ctxSwitch);
summary.put(KEY_CTX_SWITCH, String.valueOf(val));
summary.put(KEY_AVE_CTX_SWITCH, String.valueOf((double)val / (double)ctxSwitch.size()));
}
if (userTime.size() > 0) {
val = PerformanceStatisticsUtil.getSum(userTime);
summary.put(KEY_USER_TIME, String.valueOf(val));
summary.put(KEY_AVE_USER_TIME, String.valueOf((double)val / (double)userTime.size()));
}
if (sysTime.size() > 0) {
val = PerformanceStatisticsUtil.getSum(sysTime);
summary.put(KEY_SYS_TIME, String.valueOf(val));
summary.put(KEY_AVE_SYS_TIME, String.valueOf((double)val / (double)sysTime.size()));
}
if (idleTime.size() > 0) {
val = PerformanceStatisticsUtil.getSum(idleTime);
summary.put(KEY_IDLE_TIME, String.valueOf(val));
summary.put(KEY_AVE_IDLE_TIME, String.valueOf((double)val / (double)idleTime.size()));
}
if (waitTime.size() > 0) {
val = PerformanceStatisticsUtil.getSum(waitTime);
summary.put(KEY_WAIT_TIME, String.valueOf(val));
summary.put(KEY_AVE_WAIT_TIME, String.valueOf((double)val / (double)waitTime.size()));
}
if (summary.size() > 0) {
return summary;
} else {
return null;
}
}
protected void addToCpuList(String key, String val) {
if (key.equals(NAME_BLOCK_RECV)) {
blockRecv.add(Long.valueOf(val));
} else if (key.equals(NAME_BLOCK_SENT)) {
blockSent.add(Long.valueOf(val));
} else if (key.equals(NAME_CTX_SWITCH)) {
ctxSwitch.add(Long.valueOf(val));
} else if (key.equals(NAME_USER_TIME)) {
userTime.add(Long.valueOf(val));
} else if (key.equals(NAME_SYS_TIME)) {
sysTime.add(Long.valueOf(val));
} else if (key.equals(NAME_IDLE_TIME)) {
idleTime.add(Long.valueOf(val));
} else if (key.equals(NAME_WAIT_TIME)) {
waitTime.add(Long.valueOf(val));
} else {
log.warn("Unrecognized CPU data. " + key + "=" + val);
}
} }
} }

View File

@ -19,9 +19,6 @@ package org.apache.activemq.tool.reports.plugins;
import java.util.Map; import java.util.Map;
public interface ReportPlugin { public interface ReportPlugin {
public static final int REPORT_PLUGIN_THROUGHPUT = 0;
public static final int REPORT_PLUGIN_CPU = 1;
public void handleCsvData(String csvData); public void handleCsvData(String csvData);
public Map getSummary(); public Map getSummary();
} }

View File

@ -65,6 +65,11 @@ public class ThroughputReportPlugin implements ReportPlugin {
} }
public Map getSummary() { public Map getSummary() {
// Check if tp sampler wasn't used.
if (clientThroughputs.size() == 0) {
return new HashMap();
}
long minClientTP = Long.MAX_VALUE, // TP = throughput long minClientTP = Long.MAX_VALUE, // TP = throughput
maxClientTP = Long.MIN_VALUE, maxClientTP = Long.MIN_VALUE,
minClientTotalTP = Long.MAX_VALUE, minClientTotalTP = Long.MAX_VALUE,
@ -98,19 +103,19 @@ public class ThroughputReportPlugin implements ReportPlugin {
clientTPList = (List)clientThroughputs.get(clientName); clientTPList = (List)clientThroughputs.get(clientName);
clientCount++; clientCount++;
tempLong = PerformanceStatisticsUtil.getMinThroughput(clientTPList); tempLong = PerformanceStatisticsUtil.getMin(clientTPList);
if (tempLong < minClientTP) { if (tempLong < minClientTP) {
minClientTP = tempLong; minClientTP = tempLong;
nameMinClientTP = clientName; nameMinClientTP = clientName;
} }
tempLong = PerformanceStatisticsUtil.getMaxThroughput(clientTPList); tempLong = PerformanceStatisticsUtil.getMax(clientTPList);
if (tempLong > maxClientTP) { if (tempLong > maxClientTP) {
maxClientTP = tempLong; maxClientTP = tempLong;
nameMaxClientTP = clientName; nameMaxClientTP = clientName;
} }
tempLong = PerformanceStatisticsUtil.getTotalThroughput(clientTPList); tempLong = PerformanceStatisticsUtil.getSum(clientTPList);
systemTotalTP += tempLong; // Accumulate total TP systemTotalTP += tempLong; // Accumulate total TP
if (tempLong < minClientTotalTP) { if (tempLong < minClientTotalTP) {
minClientTotalTP = tempLong; minClientTotalTP = tempLong;
@ -122,7 +127,7 @@ public class ThroughputReportPlugin implements ReportPlugin {
nameMaxClientTotalTP = clientName; nameMaxClientTotalTP = clientName;
} }
tempDouble = PerformanceStatisticsUtil.getAveThroughput(clientTPList); tempDouble = PerformanceStatisticsUtil.getAve(clientTPList);
systemAveTP += tempDouble; // Accumulate ave throughput systemAveTP += tempDouble; // Accumulate ave throughput
if (tempDouble < minClientAveTP) { if (tempDouble < minClientAveTP) {
minClientAveTP = tempDouble; minClientAveTP = tempDouble;
@ -134,7 +139,7 @@ public class ThroughputReportPlugin implements ReportPlugin {
nameMaxClientAveTP = clientName; nameMaxClientAveTP = clientName;
} }
tempDouble = PerformanceStatisticsUtil.getAveThroughputExcludingMinMax(clientTPList); tempDouble = PerformanceStatisticsUtil.getAveEx(clientTPList);
systemAveEMMTP += tempDouble; // Accumulate ave throughput excluding min/max systemAveEMMTP += tempDouble; // Accumulate ave throughput excluding min/max
if (tempDouble < minClientAveEMMTP) { if (tempDouble < minClientAveEMMTP) {
minClientAveEMMTP = tempDouble; minClientAveEMMTP = tempDouble;

View File

@ -3,6 +3,7 @@ package org.apache.activemq.tool.sampler;
import org.apache.activemq.tool.sampler.plugins.CpuSamplerPlugin; import org.apache.activemq.tool.sampler.plugins.CpuSamplerPlugin;
import org.apache.activemq.tool.sampler.plugins.LinuxCpuSamplerPlugin; import org.apache.activemq.tool.sampler.plugins.LinuxCpuSamplerPlugin;
import org.apache.activemq.tool.reports.plugins.ReportPlugin; import org.apache.activemq.tool.reports.plugins.ReportPlugin;
import org.apache.activemq.tool.reports.AbstractPerfReportWriter;
import java.io.IOException; import java.io.IOException;
@ -28,7 +29,7 @@ public class CpuSamplerTask extends AbstractPerformanceSampler {
public void sampleData() { public void sampleData() {
if (plugin != null && perfReportWriter != null) { if (plugin != null && perfReportWriter != null) {
perfReportWriter.writeCsvData(ReportPlugin.REPORT_PLUGIN_CPU, "index=" + sampleIndex + "," + plugin.getCpuUtilizationStats()); perfReportWriter.writeCsvData(AbstractPerfReportWriter.REPORT_PLUGIN_CPU, "index=" + sampleIndex + "," + plugin.getCpuUtilizationStats());
} }
} }

View File

@ -1,6 +1,7 @@
package org.apache.activemq.tool.sampler; package org.apache.activemq.tool.sampler;
import org.apache.activemq.tool.reports.plugins.ReportPlugin; import org.apache.activemq.tool.reports.plugins.ReportPlugin;
import org.apache.activemq.tool.reports.AbstractPerfReportWriter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
@ -21,7 +22,7 @@ public class ThroughputSamplerTask extends AbstractPerformanceSampler {
for (Iterator i = clients.iterator(); i.hasNext();) { for (Iterator i = clients.iterator(); i.hasNext();) {
MeasurableClient client = (MeasurableClient) i.next(); MeasurableClient client = (MeasurableClient) i.next();
if (perfReportWriter != null) { if (perfReportWriter != null) {
perfReportWriter.writeCsvData(ReportPlugin.REPORT_PLUGIN_THROUGHPUT, perfReportWriter.writeCsvData(AbstractPerfReportWriter.REPORT_PLUGIN_THROUGHPUT,
"index=" + sampleIndex + ",clientName=" + client.getClientName() + "index=" + sampleIndex + ",clientName=" + client.getClientName() +
",throughput=" + client.getThroughput()); ",throughput=" + client.getThroughput());
} }

View File

@ -78,7 +78,7 @@ public class ActiveMQPojoSPI implements SPIConnectionFactory {
setting = settings.getProperty(KEY_ASYNC_DISPATCH); setting = settings.getProperty(KEY_ASYNC_DISPATCH);
if (setting != null && setting.length() > 0) { if (setting != null && setting.length() > 0) {
factory.setAsyncDispatch(Boolean.getBoolean(setting)); factory.setDispatchAsync(Boolean.getBoolean(setting));
} }
setting = settings.getProperty(KEY_ASYNC_SESSION); setting = settings.getProperty(KEY_ASYNC_SESSION);