use of org.apache.camel.util.ProcessorStatDump in project camel by apache.
the class RouteProfileCommand method executeOnRoute.
@Override
public void executeOnRoute(CamelController camelController, String contextName, String routeId, PrintStream out, PrintStream err) throws Exception {
JAXBContext context = JAXBContext.newInstance(RouteStatDump.class);
Unmarshaller unmarshaller = context.createUnmarshaller();
// write new header for new camel context
if (previousCamelContextName == null || !previousCamelContextName.equals(contextName)) {
out.println("");
out.println(stringEscape.unescapeJava("[1mProfile[0m"));
out.println(stringEscape.unescapeJava("\tCamel Context: " + contextName));
out.println(String.format(HEADER_FORMAT, "Id", "Count", "Last (ms)", "Delta (ms)", "Mean (ms)", "Min (ms)", "Max (ms)", "Total (ms)", "Self (ms)"));
}
String xml = camelController.getRouteStatsAsXml(routeId, contextName, true, true);
if (xml != null) {
RouteStatDump route = (RouteStatDump) unmarshaller.unmarshal(new StringReader(xml));
long count = route.getExchangesCompleted() + route.getExchangesFailed();
out.println(String.format(OUTPUT_FORMAT, route.getId(), count, route.getLastProcessingTime(), route.getDeltaProcessingTime(), route.getMeanProcessingTime(), route.getMinProcessingTime(), route.getMaxProcessingTime(), route.getTotalProcessingTime(), route.getSelfProcessingTime()));
for (ProcessorStatDump ps : route.getProcessorStats()) {
// the self time is the total time of the processor itself
long selfTime = ps.getTotalProcessingTime();
count = ps.getExchangesCompleted() + ps.getExchangesFailed();
// indent route id with 2 spaces
out.println(String.format(OUTPUT_FORMAT, " " + ps.getId(), count, ps.getLastProcessingTime(), ps.getDeltaProcessingTime(), ps.getMeanProcessingTime(), ps.getMinProcessingTime(), ps.getMaxProcessingTime(), ps.getAccumulatedProcessingTime(), selfTime));
}
}
// we want to group routes from the same context in the same table
previousCamelContextName = contextName;
}
Aggregations