camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1327401 - in /camel/branches/camel-2.9.x: ./ platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/ platforms/karaf/commands/src/main/resources/OSGI-INF/
Date Wed, 18 Apr 2012 07:29:33 GMT
Author: davsclaus
Date: Wed Apr 18 07:29:32 2012
New Revision: 1327401

URL: http://svn.apache.org/viewvc?rev=1327401&view=rev
Log:
CAMEL-4470: Load avg added to Camel karaf command. Thanks to Scott England-Sullivan for the
patch.

Added:
    camel/branches/camel-2.9.x/platforms/karaf/commands/src/main/resources/OSGI-INF/bundle.info
      - copied unchanged from r1327399, camel/trunk/platforms/karaf/commands/src/main/resources/OSGI-INF/bundle.info
Modified:
    camel/branches/camel-2.9.x/   (props changed)
    camel/branches/camel-2.9.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/ContextInfo.java
    camel/branches/camel-2.9.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteInfo.java

Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
  Merged /camel/trunk:r1327399

Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: camel/branches/camel-2.9.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/ContextInfo.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/ContextInfo.java?rev=1327401&r1=1327400&r2=1327401&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/ContextInfo.java
(original)
+++ camel/branches/camel-2.9.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/ContextInfo.java
Wed Apr 18 07:29:32 2012
@@ -16,9 +16,16 @@
  */
 package org.apache.camel.karaf.commands;
 
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
 import org.apache.camel.Route;
+import org.apache.camel.management.DefaultManagementAgent;
 import org.apache.felix.gogo.commands.Argument;
 import org.apache.felix.gogo.commands.Command;
 import org.apache.karaf.shell.console.OsgiCommandSupport;
@@ -52,6 +59,18 @@ public class ContextInfo extends OsgiCom
         System.out.println(StringEscapeUtils.unescapeJava("\tVersion: " + camelContext.getVersion()));
         System.out.println(StringEscapeUtils.unescapeJava("\tStatus: " + camelContext.getStatus()));
         System.out.println(StringEscapeUtils.unescapeJava("\tUptime: " + camelContext.getUptime()));
+        
+        MBeanServer mBeanServer = camelContext.getManagementStrategy().getManagementAgent().getMBeanServer();
+        Set<ObjectName> set = mBeanServer.queryNames(new ObjectName(DefaultManagementAgent.DEFAULT_DOMAIN
+ ":type=context,name=\"" + name + "\",*"), null);
+        Iterator<ObjectName> iterator = set.iterator();
+        if (iterator.hasNext()) {
+            ObjectName contextMBean = iterator.next();
+            String load01 = (String) mBeanServer.getAttribute(contextMBean, "Load01");
+            String load05 = (String) mBeanServer.getAttribute(contextMBean, "Load05");
+            String load15 = (String) mBeanServer.getAttribute(contextMBean, "Load15");
+            System.out.println(StringEscapeUtils.unescapeJava("\tLoad Avg: " + load01 + ",
" + load05 + ", " + load15));
+        }
+        
         System.out.println("");
         System.out.println(StringEscapeUtils.unescapeJava("\u001B[1mAdvanced\u001B[0m"));
         System.out.println(StringEscapeUtils.unescapeJava("\tAuto Startup: " + camelContext.isAutoStartup()));
@@ -83,6 +102,7 @@ public class ContextInfo extends OsgiCom
         for (String language : camelContext.getLanguageNames()) {
             System.out.println(StringEscapeUtils.unescapeJava("\t" + language));
         }
+        
         return null;
     }
 

Modified: camel/branches/camel-2.9.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteInfo.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteInfo.java?rev=1327401&r1=1327400&r2=1327401&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteInfo.java
(original)
+++ camel/branches/camel-2.9.x/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RouteInfo.java
Wed Apr 18 07:29:32 2012
@@ -92,7 +92,11 @@ public class RouteInfo extends OsgiComma
                 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");



Mime
View raw message