camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1464155 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/util/ camel-core/src/main/resources/org/apache/camel/util/ platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/ platforms/karaf/commands/src/main/resou...
Date Wed, 03 Apr 2013 18:46:25 GMT
Author: davsclaus
Date: Wed Apr  3 18:46:25 2013
New Revision: 1464155

URL: http://svn.apache.org/r1464155
Log:
CAMEL-6237: Karaf camel command for profiling routes. Work in progress.

Added:
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/ProcessorStatDump.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/RouteStatDump.java
      - copied, changed from r1463986, camel/trunk/camel-core/src/main/java/org/apache/camel/util/MessageDump.java
    camel/trunk/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteProfile.java
      - copied, changed from r1463986, camel/trunk/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteInfo.java
Modified:
    camel/trunk/camel-core/src/main/resources/org/apache/camel/util/jaxb.index
    camel/trunk/platforms/karaf/commands/src/main/resources/OSGI-INF/blueprint/camel-commands.xml

Added: camel/trunk/camel-core/src/main/java/org/apache/camel/util/ProcessorStatDump.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ProcessorStatDump.java?rev=1464155&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/ProcessorStatDump.java (added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/ProcessorStatDump.java Wed
Apr  3 18:46:25 2013
@@ -0,0 +1,229 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.camel.util;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * A model of a route stat dump from {@link org.apache.camel.api.management.mbean.ManagedRouteMBean#dumpRouteAsXml()}.
+ */
+@XmlRootElement(name = "processorStat")
+@XmlAccessorType(XmlAccessType.FIELD)
+public final class ProcessorStatDump {
+
+    @XmlAttribute
+    private String id;
+
+    @XmlAttribute
+    private Long exchangesCompleted;
+
+    @XmlAttribute
+    private Long exchangesFailed;
+
+    @XmlAttribute
+    private Long failuresHandled;
+
+    @XmlAttribute
+    private Long redeliveries;
+
+    @XmlAttribute
+    private Long minProcessingTime;
+
+    @XmlAttribute
+    private Long maxProcessingTime;
+
+    @XmlAttribute
+    private Long totalProcessingTime;
+
+    @XmlAttribute
+    private Long lastProcessingTime;
+
+    @XmlAttribute
+    private Long meanProcessingTime;
+
+    @XmlAttribute
+    private String firstExchangeCompletedTimestamp;
+
+    @XmlAttribute
+    private String firstExchangeCompletedExchangeId;
+
+    @XmlAttribute
+    private String firstExchangeFailureTimestamp;
+
+    @XmlAttribute
+    private String firstExchangeFailureExchangeId;
+
+    @XmlAttribute
+    private String lastExchangeCompletedTimestamp;
+
+    @XmlAttribute
+    private String lastExchangeCompletedExchangeId;
+
+    @XmlAttribute
+    private String lastExchangeFailureTimestamp;
+
+    @XmlAttribute
+    private String lastExchangeFailureExchangeId;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public Long getExchangesCompleted() {
+        return exchangesCompleted;
+    }
+
+    public void setExchangesCompleted(Long exchangesCompleted) {
+        this.exchangesCompleted = exchangesCompleted;
+    }
+
+    public Long getExchangesFailed() {
+        return exchangesFailed;
+    }
+
+    public void setExchangesFailed(Long exchangesFailed) {
+        this.exchangesFailed = exchangesFailed;
+    }
+
+    public Long getFailuresHandled() {
+        return failuresHandled;
+    }
+
+    public void setFailuresHandled(Long failuresHandled) {
+        this.failuresHandled = failuresHandled;
+    }
+
+    public Long getRedeliveries() {
+        return redeliveries;
+    }
+
+    public void setRedeliveries(Long redeliveries) {
+        this.redeliveries = redeliveries;
+    }
+
+    public Long getMinProcessingTime() {
+        return minProcessingTime;
+    }
+
+    public void setMinProcessingTime(Long minProcessingTime) {
+        this.minProcessingTime = minProcessingTime;
+    }
+
+    public Long getMaxProcessingTime() {
+        return maxProcessingTime;
+    }
+
+    public void setMaxProcessingTime(Long maxProcessingTime) {
+        this.maxProcessingTime = maxProcessingTime;
+    }
+
+    public Long getTotalProcessingTime() {
+        return totalProcessingTime;
+    }
+
+    public void setTotalProcessingTime(Long totalProcessingTime) {
+        this.totalProcessingTime = totalProcessingTime;
+    }
+
+    public Long getLastProcessingTime() {
+        return lastProcessingTime;
+    }
+
+    public void setLastProcessingTime(Long lastProcessingTime) {
+        this.lastProcessingTime = lastProcessingTime;
+    }
+
+    public Long getMeanProcessingTime() {
+        return meanProcessingTime;
+    }
+
+    public void setMeanProcessingTime(Long meanProcessingTime) {
+        this.meanProcessingTime = meanProcessingTime;
+    }
+
+    public String getFirstExchangeCompletedTimestamp() {
+        return firstExchangeCompletedTimestamp;
+    }
+
+    public void setFirstExchangeCompletedTimestamp(String firstExchangeCompletedTimestamp)
{
+        this.firstExchangeCompletedTimestamp = firstExchangeCompletedTimestamp;
+    }
+
+    public String getFirstExchangeCompletedExchangeId() {
+        return firstExchangeCompletedExchangeId;
+    }
+
+    public void setFirstExchangeCompletedExchangeId(String firstExchangeCompletedExchangeId)
{
+        this.firstExchangeCompletedExchangeId = firstExchangeCompletedExchangeId;
+    }
+
+    public String getFirstExchangeFailureTimestamp() {
+        return firstExchangeFailureTimestamp;
+    }
+
+    public void setFirstExchangeFailureTimestamp(String firstExchangeFailureTimestamp) {
+        this.firstExchangeFailureTimestamp = firstExchangeFailureTimestamp;
+    }
+
+    public String getFirstExchangeFailureExchangeId() {
+        return firstExchangeFailureExchangeId;
+    }
+
+    public void setFirstExchangeFailureExchangeId(String firstExchangeFailureExchangeId)
{
+        this.firstExchangeFailureExchangeId = firstExchangeFailureExchangeId;
+    }
+
+    public String getLastExchangeCompletedTimestamp() {
+        return lastExchangeCompletedTimestamp;
+    }
+
+    public void setLastExchangeCompletedTimestamp(String lastExchangeCompletedTimestamp)
{
+        this.lastExchangeCompletedTimestamp = lastExchangeCompletedTimestamp;
+    }
+
+    public String getLastExchangeCompletedExchangeId() {
+        return lastExchangeCompletedExchangeId;
+    }
+
+    public void setLastExchangeCompletedExchangeId(String lastExchangeCompletedExchangeId)
{
+        this.lastExchangeCompletedExchangeId = lastExchangeCompletedExchangeId;
+    }
+
+    public String getLastExchangeFailureTimestamp() {
+        return lastExchangeFailureTimestamp;
+    }
+
+    public void setLastExchangeFailureTimestamp(String lastExchangeFailureTimestamp) {
+        this.lastExchangeFailureTimestamp = lastExchangeFailureTimestamp;
+    }
+
+    public String getLastExchangeFailureExchangeId() {
+        return lastExchangeFailureExchangeId;
+    }
+
+    public void setLastExchangeFailureExchangeId(String lastExchangeFailureExchangeId) {
+        this.lastExchangeFailureExchangeId = lastExchangeFailureExchangeId;
+    }
+
+}

Copied: camel/trunk/camel-core/src/main/java/org/apache/camel/util/RouteStatDump.java (from
r1463986, camel/trunk/camel-core/src/main/java/org/apache/camel/util/MessageDump.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/RouteStatDump.java?p2=camel/trunk/camel-core/src/main/java/org/apache/camel/util/RouteStatDump.java&p1=camel/trunk/camel-core/src/main/java/org/apache/camel/util/MessageDump.java&r1=1463986&r2=1464155&rev=1464155&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/MessageDump.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/RouteStatDump.java Wed Apr
 3 18:46:25 2013
@@ -21,117 +21,229 @@ import javax.xml.bind.annotation.XmlAcce
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlElementRef;
 import javax.xml.bind.annotation.XmlElementWrapper;
 import javax.xml.bind.annotation.XmlElements;
 import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlValue;
 
 /**
- * A model of a message dump from {@link MessageHelper#dumpAsXml(org.apache.camel.Message)}.
+ * A model of a route stat dump from {@link org.apache.camel.api.management.mbean.ManagedRouteMBean#dumpRouteAsXml()}.
  */
-@XmlRootElement(name = "message")
+@XmlRootElement(name = "routeStat")
 @XmlAccessorType(XmlAccessType.FIELD)
-public final class MessageDump {
+public final class RouteStatDump {
 
-    @XmlRootElement(name = "header")
-    @XmlAccessorType(XmlAccessType.FIELD)
-    public static class Header {
+    @XmlAttribute
+    private String id;
 
-        @XmlAttribute
-        private String key;
+    @XmlAttribute
+    private Long exchangesCompleted;
 
-        @XmlAttribute
-        private String type;
+    @XmlAttribute
+    private Long exchangesFailed;
 
-        @XmlValue
-        private String value;
+    @XmlAttribute
+    private Long failuresHandled;
 
-        public String getKey() {
-            return key;
-        }
+    @XmlAttribute
+    private Long redeliveries;
 
-        public void setKey(String key) {
-            this.key = key;
-        }
+    @XmlAttribute
+    private Long minProcessingTime;
 
-        public String getType() {
-            return type;
-        }
+    @XmlAttribute
+    private Long maxProcessingTime;
 
-        public void setType(String type) {
-            this.type = type;
-        }
+    @XmlAttribute
+    private Long totalProcessingTime;
 
-        public String getValue() {
-            return value;
-        }
+    @XmlAttribute
+    private Long lastProcessingTime;
 
-        public void setValue(String value) {
-            this.value = value;
-        }
-    }
+    @XmlAttribute
+    private Long meanProcessingTime;
 
-    @XmlRootElement(name = "body")
-    @XmlAccessorType(XmlAccessType.FIELD)
-    public static class Body {
+    @XmlAttribute
+    private String firstExchangeCompletedTimestamp;
 
-        @XmlAttribute
-        private String type;
+    @XmlAttribute
+    private String firstExchangeCompletedExchangeId;
 
-        @XmlValue
-        private String value;
+    @XmlAttribute
+    private String firstExchangeFailureTimestamp;
 
-        public String getType() {
-            return type;
-        }
+    @XmlAttribute
+    private String firstExchangeFailureExchangeId;
 
-        public void setType(String type) {
-            this.type = type;
-        }
+    @XmlAttribute
+    private String lastExchangeCompletedTimestamp;
 
-        public String getValue() {
-            return value;
-        }
+    @XmlAttribute
+    private String lastExchangeCompletedExchangeId;
 
-        public void setValue(String value) {
-            this.value = value;
-        }
-    }
+    @XmlAttribute
+    private String lastExchangeFailureTimestamp;
 
     @XmlAttribute
-    private String exchangeId;
+    private String lastExchangeFailureExchangeId;
 
-    @XmlElementWrapper(name = "headers")
+    @XmlElementWrapper(name = "processorStats")
     @XmlElements({
-        @XmlElement(type = Header.class, name = "header")
+            @XmlElement(type = ProcessorStatDump.class, name = "processorStat")
     })
-    private List<Header> headers;
+    private List<ProcessorStatDump> processorStats;
 
-    @XmlElementRef
-    private Body body;
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
 
-    public String getExchangeId() {
-        return exchangeId;
+    public Long getExchangesCompleted() {
+        return exchangesCompleted;
     }
 
-    public void setExchangeId(String exchangeId) {
-        this.exchangeId = exchangeId;
+    public void setExchangesCompleted(Long exchangesCompleted) {
+        this.exchangesCompleted = exchangesCompleted;
     }
 
-    public List<Header> getHeaders() {
-        return headers;
+    public Long getExchangesFailed() {
+        return exchangesFailed;
     }
 
-    public void setHeaders(List<Header> headers) {
-        this.headers = headers;
+    public void setExchangesFailed(Long exchangesFailed) {
+        this.exchangesFailed = exchangesFailed;
     }
 
-    public Body getBody() {
-        return body;
+    public Long getFailuresHandled() {
+        return failuresHandled;
     }
 
-    public void setBody(Body body) {
-        this.body = body;
+    public void setFailuresHandled(Long failuresHandled) {
+        this.failuresHandled = failuresHandled;
     }
+
+    public Long getRedeliveries() {
+        return redeliveries;
+    }
+
+    public void setRedeliveries(Long redeliveries) {
+        this.redeliveries = redeliveries;
+    }
+
+    public Long getMinProcessingTime() {
+        return minProcessingTime;
+    }
+
+    public void setMinProcessingTime(Long minProcessingTime) {
+        this.minProcessingTime = minProcessingTime;
+    }
+
+    public Long getMaxProcessingTime() {
+        return maxProcessingTime;
+    }
+
+    public void setMaxProcessingTime(Long maxProcessingTime) {
+        this.maxProcessingTime = maxProcessingTime;
+    }
+
+    public Long getTotalProcessingTime() {
+        return totalProcessingTime;
+    }
+
+    public void setTotalProcessingTime(Long totalProcessingTime) {
+        this.totalProcessingTime = totalProcessingTime;
+    }
+
+    public Long getLastProcessingTime() {
+        return lastProcessingTime;
+    }
+
+    public void setLastProcessingTime(Long lastProcessingTime) {
+        this.lastProcessingTime = lastProcessingTime;
+    }
+
+    public Long getMeanProcessingTime() {
+        return meanProcessingTime;
+    }
+
+    public void setMeanProcessingTime(Long meanProcessingTime) {
+        this.meanProcessingTime = meanProcessingTime;
+    }
+
+    public String getFirstExchangeCompletedTimestamp() {
+        return firstExchangeCompletedTimestamp;
+    }
+
+    public void setFirstExchangeCompletedTimestamp(String firstExchangeCompletedTimestamp)
{
+        this.firstExchangeCompletedTimestamp = firstExchangeCompletedTimestamp;
+    }
+
+    public String getFirstExchangeCompletedExchangeId() {
+        return firstExchangeCompletedExchangeId;
+    }
+
+    public void setFirstExchangeCompletedExchangeId(String firstExchangeCompletedExchangeId)
{
+        this.firstExchangeCompletedExchangeId = firstExchangeCompletedExchangeId;
+    }
+
+    public String getFirstExchangeFailureTimestamp() {
+        return firstExchangeFailureTimestamp;
+    }
+
+    public void setFirstExchangeFailureTimestamp(String firstExchangeFailureTimestamp) {
+        this.firstExchangeFailureTimestamp = firstExchangeFailureTimestamp;
+    }
+
+    public String getFirstExchangeFailureExchangeId() {
+        return firstExchangeFailureExchangeId;
+    }
+
+    public void setFirstExchangeFailureExchangeId(String firstExchangeFailureExchangeId)
{
+        this.firstExchangeFailureExchangeId = firstExchangeFailureExchangeId;
+    }
+
+    public String getLastExchangeCompletedTimestamp() {
+        return lastExchangeCompletedTimestamp;
+    }
+
+    public void setLastExchangeCompletedTimestamp(String lastExchangeCompletedTimestamp)
{
+        this.lastExchangeCompletedTimestamp = lastExchangeCompletedTimestamp;
+    }
+
+    public String getLastExchangeCompletedExchangeId() {
+        return lastExchangeCompletedExchangeId;
+    }
+
+    public void setLastExchangeCompletedExchangeId(String lastExchangeCompletedExchangeId)
{
+        this.lastExchangeCompletedExchangeId = lastExchangeCompletedExchangeId;
+    }
+
+    public String getLastExchangeFailureTimestamp() {
+        return lastExchangeFailureTimestamp;
+    }
+
+    public void setLastExchangeFailureTimestamp(String lastExchangeFailureTimestamp) {
+        this.lastExchangeFailureTimestamp = lastExchangeFailureTimestamp;
+    }
+
+    public String getLastExchangeFailureExchangeId() {
+        return lastExchangeFailureExchangeId;
+    }
+
+    public void setLastExchangeFailureExchangeId(String lastExchangeFailureExchangeId) {
+        this.lastExchangeFailureExchangeId = lastExchangeFailureExchangeId;
+    }
+
+    public List<ProcessorStatDump> getProcessorStats() {
+        return processorStats;
+    }
+
+    public void setProcessorStats(List<ProcessorStatDump> processorStats) {
+        this.processorStats = processorStats;
+    }
+
 }
+
+

Modified: camel/trunk/camel-core/src/main/resources/org/apache/camel/util/jaxb.index
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/resources/org/apache/camel/util/jaxb.index?rev=1464155&r1=1464154&r2=1464155&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/resources/org/apache/camel/util/jaxb.index (original)
+++ camel/trunk/camel-core/src/main/resources/org/apache/camel/util/jaxb.index Wed Apr  3
18:46:25 2013
@@ -14,4 +14,6 @@
 ## See the License for the specific language governing permissions and
 ## limitations under the License.
 ## ------------------------------------------------------------------------
-MessageDump
\ No newline at end of file
+MessageDump
+ProcessorStatDump
+RouteStatDump

Copied: camel/trunk/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteProfile.java
(from r1463986, 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/RouteProfile.java?p2=camel/trunk/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteProfile.java&p1=camel/trunk/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteInfo.java&r1=1463986&r2=1464155&rev=1464155&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/RouteProfile.java
Wed Apr  3 18:46:25 2013
@@ -16,30 +16,33 @@
  */
 package org.apache.camel.karaf.commands;
 
-import java.text.SimpleDateFormat;
-import java.util.Date;
+import java.io.StringReader;
 import java.util.Iterator;
 import java.util.Set;
-
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Route;
 import org.apache.camel.management.DefaultManagementAgent;
-import org.apache.camel.model.ModelHelper;
-import org.apache.camel.model.RouteDefinition;
 import org.apache.camel.spi.ManagementAgent;
+import org.apache.camel.util.ProcessorStatDump;
+import org.apache.camel.util.RouteStatDump;
 import org.apache.felix.gogo.commands.Argument;
 import org.apache.felix.gogo.commands.Command;
 import org.apache.karaf.shell.console.OsgiCommandSupport;
 import org.apache.karaf.util.StringEscapeUtils;
 
 /**
- * Command to display detailed information about a Camel route.
+ * Command to display profile information about a Camel route.
  */
-@Command(scope = "camel", name = "route-info", description = "Display information about a
Camel route.")
-public class RouteInfo extends OsgiCommandSupport {
+@Command(scope = "camel", name = "route-profile", description = "Display profile information
about a Camel route.")
+public class RouteProfile extends OsgiCommandSupport {
+
+    protected static final String HEADER_FORMAT = "%-30s %10s %10s %12s %12s %12s %12s %12s";
+    protected static final String OUTPUT_FORMAT = "[%-28s] [%8d] [%8d] [%10d] [%10d] [%10d]
[%10d] [%10d]";
 
     @Argument(index = 0, name = "route", description = "The Camel route ID.", required =
true, multiValued = false)
     String route;
@@ -61,15 +64,13 @@ public class RouteInfo extends OsgiComma
             return null;
         }
 
+        JAXBContext context = JAXBContext.newInstance(RouteStatDump.class);
+        Unmarshaller unmarshaller = context.createUnmarshaller();
+
         System.out.println(StringEscapeUtils.unescapeJava("\u001B[1m\u001B[33mCamel Route
" + camelRoute.getId() + "\u001B[0m"));
         System.out.println(StringEscapeUtils.unescapeJava("\tCamel Context: " + camelRoute.getRouteContext().getCamelContext().getName()));
         System.out.println("");
-        System.out.println(StringEscapeUtils.unescapeJava("\u001B[1mProperties\u001B[0m"));
-        for (String property : camelRoute.getProperties().keySet()) {
-            System.out.println(StringEscapeUtils.unescapeJava("\t\t" + property + " = " +
camelRoute.getProperties().get(property)));
-        }
-        System.out.println("");
-        System.out.println(StringEscapeUtils.unescapeJava("\u001B[1mStatistics\u001B[0m"));
+        System.out.println(StringEscapeUtils.unescapeJava("\u001B[1mProfile\u001B[0m"));
         CamelContext camelContext = camelRoute.getRouteContext().getCamelContext();
         if (camelContext != null) {
             ManagementAgent agent = camelContext.getManagementStrategy().getManagementAgent();
@@ -79,58 +80,33 @@ 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 firstExchangeTimestampObj = mBeanServer.getAttribute(routeMBean,
"FirstExchangeCompletedTimestamp");
-                    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-                    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)));
+                    // TODO: add a row with the route endpoint, so you can see that
+                    // TODO: add column with total time (delta for self time)
+                    // TODO: ensure the jmx mbeans for processors is sorted correctly
+
+                    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));
+
+                    System.out.println(String.format(HEADER_FORMAT, "Id", "Completed", "Failed",
"Last (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.getMeanProcessingTime(), route.getMinProcessingTime(),
route.getMaxProcessingTime(), route.getTotalProcessingTime(), 0));
+
+                    // output in reverse order which prints the route as we want
+                    for (int i = route.getProcessorStats().size() - 1; i >= 0; i--) {
+                        ProcessorStatDump ps = route.getProcessorStats().get(i);
+                        // 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.getMeanProcessingTime(), ps.getMinProcessingTime(), ps.getMaxProcessingTime(),
selfTime));
                     }
                 }
             } else {
                 System.out.println("");
                 System.out.println(StringEscapeUtils.unescapeJava("\u001B[31mJMX Agent of
Camel is not reachable. Maybe it has been disabled on the Camel context"));
-                System.out.println(StringEscapeUtils.unescapeJava("In consequence, some statistics
are not available.\u001B[0m"));
+                System.out.println(StringEscapeUtils.unescapeJava("In consequence, profile
are not available.\u001B[0m"));
             }
-
-            System.out.println("");
-            System.out.println(StringEscapeUtils.unescapeJava("\u001B[1mDefinition\u001B[0m"));
-            RouteDefinition definition = camelController.getRouteDefinition(route, camelRoute.getRouteContext().getCamelContext().getName());
-            System.out.println(StringEscapeUtils.unescapeJava(ModelHelper.dumpModelAsXml(definition)));
         }
         return null;
     }

Modified: camel/trunk/platforms/karaf/commands/src/main/resources/OSGI-INF/blueprint/camel-commands.xml
URL: http://svn.apache.org/viewvc/camel/trunk/platforms/karaf/commands/src/main/resources/OSGI-INF/blueprint/camel-commands.xml?rev=1464155&r1=1464154&r2=1464155&view=diff
==============================================================================
--- camel/trunk/platforms/karaf/commands/src/main/resources/OSGI-INF/blueprint/camel-commands.xml
(original)
+++ camel/trunk/platforms/karaf/commands/src/main/resources/OSGI-INF/blueprint/camel-commands.xml
Wed Apr  3 18:46:25 2013
@@ -68,6 +68,15 @@
                 <null/>
             </completers>
         </command>
+        <command name="camel/route-profile">
+            <action class="org.apache.camel.karaf.commands.RouteProfile">
+                <property name="camelController" ref="camelController"/>
+            </action>
+            <completers>
+                <ref component-id="routeCompleter"/>
+                <null/>
+            </completers>
+        </command>
         <command name="camel/route-show">
             <action class="org.apache.camel.karaf.commands.RouteShow">
                 <property name="camelController" ref="camelController"/>



Mime
View raw message