You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2013/04/04 14:24:49 UTC
svn commit: r1464497 - in
/camel/trunk/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands:
ContextInfo.java RouteInfo.java RouteProfile.java
Author: davsclaus
Date: Thu Apr 4 12:24:49 2013
New Revision: 1464497
URL: http://svn.apache.org/r1464497
Log:
CAMEL-6237: Polished karaf commands
Modified:
camel/trunk/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/ContextInfo.java
camel/trunk/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteInfo.java
camel/trunk/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteProfile.java
Modified: camel/trunk/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/ContextInfo.java
URL: http://svn.apache.org/viewvc/camel/trunk/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/ContextInfo.java?rev=1464497&r1=1464496&r2=1464497&view=diff
==============================================================================
--- camel/trunk/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/ContextInfo.java (original)
+++ camel/trunk/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/ContextInfo.java Thu Apr 4 12:24:49 2013
@@ -97,6 +97,8 @@ public class ContextInfo extends OsgiCom
System.out.println(StringEscapeUtils.unescapeJava("\tTotal Processing Time: " + totalProcessingTime + "ms"));
Long lastProcessingTime = (Long) mBeanServer.getAttribute(contextMBean, "LastProcessingTime");
System.out.println(StringEscapeUtils.unescapeJava("\tLast Processing Time: " + lastProcessingTime + "ms"));
+ Long deltaProcessingTime = (Long) mBeanServer.getAttribute(contextMBean, "DeltaProcessingTime");
+ System.out.println(StringEscapeUtils.unescapeJava("\tDelta Processing Time: " + deltaProcessingTime + "ms"));
String load01 = (String) mBeanServer.getAttribute(contextMBean, "Load01");
String load05 = (String) mBeanServer.getAttribute(contextMBean, "Load05");
Modified: camel/trunk/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteInfo.java
URL: http://svn.apache.org/viewvc/camel/trunk/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteInfo.java?rev=1464497&r1=1464496&r2=1464497&view=diff
==============================================================================
--- camel/trunk/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteInfo.java (original)
+++ camel/trunk/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteInfo.java Thu Apr 4 12:24:49 2013
@@ -79,56 +79,63 @@ public class RouteInfo extends OsgiComma
Iterator<ObjectName> iterator = set.iterator();
if (iterator.hasNext()) {
ObjectName routeMBean = iterator.next();
- Long exchangesTotal = (Long) mBeanServer.getAttribute(routeMBean, "ExchangesTotal");
- System.out.println(StringEscapeUtils.unescapeJava("\tExchanges Total: " + exchangesTotal));
- Long exchangesCompleted = (Long) mBeanServer.getAttribute(routeMBean, "ExchangesCompleted");
- System.out.println(StringEscapeUtils.unescapeJava("\tExchanges Completed: " + exchangesCompleted));
- Long exchangesFailed = (Long) mBeanServer.getAttribute(routeMBean, "ExchangesFailed");
- System.out.println(StringEscapeUtils.unescapeJava("\tExchanges Failed: " + exchangesFailed));
- Long minProcessingTime = (Long) mBeanServer.getAttribute(routeMBean, "MinProcessingTime");
- System.out.println(StringEscapeUtils.unescapeJava("\tMin Processing Time: " + minProcessingTime + "ms"));
- Long maxProcessingTime = (Long) mBeanServer.getAttribute(routeMBean, "MaxProcessingTime");
- System.out.println(StringEscapeUtils.unescapeJava("\tMax Processing Time: " + maxProcessingTime + "ms"));
- Long meanProcessingTime = (Long) mBeanServer.getAttribute(routeMBean, "MeanProcessingTime");
- System.out.println(StringEscapeUtils.unescapeJava("\tMean Processing Time: " + meanProcessingTime + "ms"));
- Long totalProcessingTime = (Long) mBeanServer.getAttribute(routeMBean, "TotalProcessingTime");
- System.out.println(StringEscapeUtils.unescapeJava("\tTotal Processing Time: " + totalProcessingTime + "ms"));
- Long lastProcessingTime = (Long) mBeanServer.getAttribute(routeMBean, "LastProcessingTime");
- System.out.println(StringEscapeUtils.unescapeJava("\tLast Processing Time: " + lastProcessingTime + "ms"));
- String load01 = (String) mBeanServer.getAttribute(routeMBean, "Load01");
- String load05 = (String) mBeanServer.getAttribute(routeMBean, "Load05");
- String load15 = (String) mBeanServer.getAttribute(routeMBean, "Load15");
- System.out.println(StringEscapeUtils.unescapeJava("\tLoad Avg: " + load01 + ", " + load05 + ", " + load15));
- // Test for null to see if a any exchanges have been processed first to avoid NPE
- Object resetTimestampObj = mBeanServer.getAttribute(routeMBean, "ResetTimestamp");
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- if (resetTimestampObj == null) {
- // Print an empty value for scripting
- System.out.println(StringEscapeUtils.unescapeJava("\tReset Statistics Date:"));
- } else {
- Date firstExchangeTimestamp = (Date) resetTimestampObj;
- System.out.println(StringEscapeUtils.unescapeJava("\tReset Statistics Date: " + format.format(firstExchangeTimestamp)));
- }
+ // the route must be part of the camel context
+ String camelId = (String) mBeanServer.getAttribute(routeMBean, "CamelId");
+ if (camelId != null && camelId.equals(camelContext.getName())) {
+ Long exchangesTotal = (Long) mBeanServer.getAttribute(routeMBean, "ExchangesTotal");
+ System.out.println(StringEscapeUtils.unescapeJava("\tExchanges Total: " + exchangesTotal));
+ Long exchangesCompleted = (Long) mBeanServer.getAttribute(routeMBean, "ExchangesCompleted");
+ System.out.println(StringEscapeUtils.unescapeJava("\tExchanges Completed: " + exchangesCompleted));
+ Long exchangesFailed = (Long) mBeanServer.getAttribute(routeMBean, "ExchangesFailed");
+ System.out.println(StringEscapeUtils.unescapeJava("\tExchanges Failed: " + exchangesFailed));
+ Long minProcessingTime = (Long) mBeanServer.getAttribute(routeMBean, "MinProcessingTime");
+ System.out.println(StringEscapeUtils.unescapeJava("\tMin Processing Time: " + minProcessingTime + "ms"));
+ Long maxProcessingTime = (Long) mBeanServer.getAttribute(routeMBean, "MaxProcessingTime");
+ System.out.println(StringEscapeUtils.unescapeJava("\tMax Processing Time: " + maxProcessingTime + "ms"));
+ Long meanProcessingTime = (Long) mBeanServer.getAttribute(routeMBean, "MeanProcessingTime");
+ System.out.println(StringEscapeUtils.unescapeJava("\tMean Processing Time: " + meanProcessingTime + "ms"));
+ Long totalProcessingTime = (Long) mBeanServer.getAttribute(routeMBean, "TotalProcessingTime");
+ System.out.println(StringEscapeUtils.unescapeJava("\tTotal Processing Time: " + totalProcessingTime + "ms"));
+ Long lastProcessingTime = (Long) mBeanServer.getAttribute(routeMBean, "LastProcessingTime");
+ System.out.println(StringEscapeUtils.unescapeJava("\tLast Processing Time: " + lastProcessingTime + "ms"));
+ Long deltaProcessingTime = (Long) mBeanServer.getAttribute(routeMBean, "DeltaProcessingTime");
+ System.out.println(StringEscapeUtils.unescapeJava("\tDelta Processing Time: " + deltaProcessingTime + "ms"));
+ String load01 = (String) mBeanServer.getAttribute(routeMBean, "Load01");
+ String load05 = (String) mBeanServer.getAttribute(routeMBean, "Load05");
+ String load15 = (String) mBeanServer.getAttribute(routeMBean, "Load15");
+ System.out.println(StringEscapeUtils.unescapeJava("\tLoad Avg: " + load01 + ", " + load05 + ", " + load15));
- // Test for null to see if a any exchanges have been processed first to avoid NPE
- Object firstExchangeTimestampObj = mBeanServer.getAttribute(routeMBean, "FirstExchangeCompletedTimestamp");
- if (firstExchangeTimestampObj == null) {
- // Print an empty value for scripting
- System.out.println(StringEscapeUtils.unescapeJava("\tFirst Exchange Date:"));
- } else {
- Date firstExchangeTimestamp = (Date) firstExchangeTimestampObj;
- System.out.println(StringEscapeUtils.unescapeJava("\tFirst Exchange Date: " + format.format(firstExchangeTimestamp)));
- }
+ // Test for null to see if a any exchanges have been processed first to avoid NPE
+ Object resetTimestampObj = mBeanServer.getAttribute(routeMBean, "ResetTimestamp");
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ if (resetTimestampObj == null) {
+ // Print an empty value for scripting
+ System.out.println(StringEscapeUtils.unescapeJava("\tReset Statistics Date:"));
+ } else {
+ Date firstExchangeTimestamp = (Date) resetTimestampObj;
+ System.out.println(StringEscapeUtils.unescapeJava("\tReset Statistics Date: " + format.format(firstExchangeTimestamp)));
+ }
+
+ // Test for null to see if a any exchanges have been processed first to avoid NPE
+ Object firstExchangeTimestampObj = mBeanServer.getAttribute(routeMBean, "FirstExchangeCompletedTimestamp");
+ if (firstExchangeTimestampObj == null) {
+ // Print an empty value for scripting
+ System.out.println(StringEscapeUtils.unescapeJava("\tFirst Exchange Date:"));
+ } else {
+ Date firstExchangeTimestamp = (Date) firstExchangeTimestampObj;
+ System.out.println(StringEscapeUtils.unescapeJava("\tFirst Exchange Date: " + format.format(firstExchangeTimestamp)));
+ }
- // Again, check for null to avoid NPE
- Object lastExchangeCompletedTimestampObj = mBeanServer.getAttribute(routeMBean, "LastExchangeCompletedTimestamp");
- if (lastExchangeCompletedTimestampObj == null) {
- // Print an empty value for scripting
- System.out.println(StringEscapeUtils.unescapeJava("\tLast Exchange Completed Date:"));
- } else {
- Date lastExchangeCompletedTimestamp = (Date) lastExchangeCompletedTimestampObj;
- System.out.println(StringEscapeUtils.unescapeJava("\tLast Exchange Completed Date: " + format.format(lastExchangeCompletedTimestamp)));
+ // Again, check for null to avoid NPE
+ Object lastExchangeCompletedTimestampObj = mBeanServer.getAttribute(routeMBean, "LastExchangeCompletedTimestamp");
+ if (lastExchangeCompletedTimestampObj == null) {
+ // Print an empty value for scripting
+ System.out.println(StringEscapeUtils.unescapeJava("\tLast Exchange Completed Date:"));
+ } else {
+ Date lastExchangeCompletedTimestamp = (Date) lastExchangeCompletedTimestampObj;
+ System.out.println(StringEscapeUtils.unescapeJava("\tLast Exchange Completed Date: " + format.format(lastExchangeCompletedTimestamp)));
+ }
}
}
} else {
Modified: camel/trunk/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteProfile.java
URL: http://svn.apache.org/viewvc/camel/trunk/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteProfile.java?rev=1464497&r1=1464496&r2=1464497&view=diff
==============================================================================
--- camel/trunk/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteProfile.java (original)
+++ camel/trunk/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteProfile.java Thu Apr 4 12:24:49 2013
@@ -83,22 +83,27 @@ public class RouteProfile extends OsgiCo
if (iterator.hasNext()) {
ObjectName routeMBean = iterator.next();
- // TODO: add column with total time (delta for self time)
+ // the route must be part of the camel context
+ String camelId = (String) mBeanServer.getAttribute(routeMBean, "CamelId");
+ if (camelId != null && camelId.equals(camelContext.getName())) {
- String xml = (String) mBeanServer.invoke(routeMBean, "dumpRouteStatsAsXml", new Object[]{Boolean.FALSE, Boolean.TRUE}, new String[]{"boolean", "boolean"});
- RouteStatDump route = (RouteStatDump) unmarshaller.unmarshal(new StringReader(xml));
+ // TODO: add column with total time (delta for self time)
- System.out.println(String.format(HEADER_FORMAT, "Id", "Completed", "Failed", "Last (ms)", "Delta (ms)", "Mean (ms)", "Min (ms)", "Max (ms)", "Self (ms)"));
- System.out.println(String.format(OUTPUT_FORMAT, route.getId(), route.getExchangesCompleted(), route.getExchangesFailed(), route.getLastProcessingTime(),
- route.getDeltaProcessingTime(), route.getMeanProcessingTime(), route.getMinProcessingTime(), route.getMaxProcessingTime(), route.getTotalProcessingTime(), 0));
+ String xml = (String) mBeanServer.invoke(routeMBean, "dumpRouteStatsAsXml", new Object[]{Boolean.FALSE, Boolean.TRUE}, new String[]{"boolean", "boolean"});
+ RouteStatDump route = (RouteStatDump) unmarshaller.unmarshal(new StringReader(xml));
- // output in reverse order which prints the route as we want
- for (ProcessorStatDump ps : route.getProcessorStats()) {
- // the self time is the total time of the processor itself
- long selfTime = ps.getTotalProcessingTime();
- // indent route id with 2 spaces
- System.out.println(String.format(OUTPUT_FORMAT, " " + ps.getId(), ps.getExchangesCompleted(), ps.getExchangesFailed(), ps.getLastProcessingTime(),
- ps.getDeltaProcessingTime(), ps.getMeanProcessingTime(), ps.getMinProcessingTime(), ps.getMaxProcessingTime(), selfTime));
+ System.out.println(String.format(HEADER_FORMAT, "Id", "Completed", "Failed", "Last (ms)", "Delta (ms)", "Mean (ms)", "Min (ms)", "Max (ms)", "Self (ms)"));
+ System.out.println(String.format(OUTPUT_FORMAT, route.getId(), route.getExchangesCompleted(), route.getExchangesFailed(), route.getLastProcessingTime(),
+ route.getDeltaProcessingTime(), route.getMeanProcessingTime(), route.getMinProcessingTime(), route.getMaxProcessingTime(), route.getTotalProcessingTime(), 0));
+
+ // output in reverse order which prints the route as we want
+ for (ProcessorStatDump ps : route.getProcessorStats()) {
+ // the self time is the total time of the processor itself
+ long selfTime = ps.getTotalProcessingTime();
+ // indent route id with 2 spaces
+ System.out.println(String.format(OUTPUT_FORMAT, " " + ps.getId(), ps.getExchangesCompleted(), ps.getExchangesFailed(), ps.getLastProcessingTime(),
+ ps.getDeltaProcessingTime(), ps.getMeanProcessingTime(), ps.getMinProcessingTime(), ps.getMaxProcessingTime(), selfTime));
+ }
}
}
} else {