camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1464396 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/api/management/mbean/ camel-core/src/main/java/org/apache/camel/management/mbean/ camel-core/src/main/java/org/apache/camel/util/ camel-core/src/test/java/org/apache/came...
Date Thu, 04 Apr 2013 09:35:00 GMT
Author: davsclaus
Date: Thu Apr  4 09:35:00 2013
New Revision: 1464396

URL: http://svn.apache.org/r1464396
Log:
CAMEL-6239: Added resetTimstamp attribute to JMX so we know for how long we have gather stats.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedCounterMBean.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCounter.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedPerformanceCounter.java
    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
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRoutePerformanceCounterTest.java
    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

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedCounterMBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedCounterMBean.java?rev=1464396&r1=1464395&r2=1464396&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedCounterMBean.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedCounterMBean.java
Thu Apr  4 09:35:00 2013
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.api.management.mbean;
 
+import java.util.Date;
+
 import org.apache.camel.api.management.ManagedAttribute;
 import org.apache.camel.api.management.ManagedOperation;
 
@@ -24,6 +26,9 @@ public interface ManagedCounterMBean {
     @ManagedOperation(description = "Reset counters")
     void reset();
 
+    @ManagedAttribute(description = "Timestamp when the stats was last reset or initially
started")
+    Date getResetTimestamp();
+
     @ManagedAttribute(description = "Total number of exchanges")
     long getExchangesTotal() throws Exception;
 

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCounter.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCounter.java?rev=1464396&r1=1464395&r2=1464396&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCounter.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCounter.java
Thu Apr  4 09:35:00 2013
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.management.mbean;
 
+import java.util.Date;
+
 import org.apache.camel.api.management.ManagedResource;
 import org.apache.camel.api.management.mbean.ManagedCounterMBean;
 import org.apache.camel.spi.ManagementStrategy;
@@ -23,13 +25,22 @@ import org.apache.camel.spi.ManagementSt
 @ManagedResource(description = "Managed Counter")
 public abstract class ManagedCounter implements ManagedCounterMBean {
     protected Statistic exchangesTotal;
+    protected Statistic resetTimestamp;
 
     public void init(ManagementStrategy strategy) {
         this.exchangesTotal = new Statistic("org.apache.camel.exchangesTotal", this, Statistic.UpdateMode.COUNTER);
+        this.resetTimestamp = new Statistic("org.apache.camel.resetTimestamp", this, Statistic.UpdateMode.VALUE);
+        resetTimestamp.updateValue(new Date().getTime());
     }
 
     public synchronized void reset() {
         exchangesTotal.reset();
+        resetTimestamp.updateValue(new Date().getTime());
+    }
+
+    public Date getResetTimestamp() {
+        long value = resetTimestamp.getValue();
+        return value > 0 ? new Date(value) : null;
     }
 
     public long getExchangesTotal() throws Exception {

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedPerformanceCounter.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedPerformanceCounter.java?rev=1464396&r1=1464395&r2=1464396&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedPerformanceCounter.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedPerformanceCounter.java
Thu Apr  4 09:35:00 2013
@@ -252,6 +252,7 @@ public abstract class ManagedPerformance
         sb.append(String.format(" meanProcessingTime=\"%s\"", meanProcessingTime.getValue()));
 
         if (fullStats) {
+            sb.append(String.format(" resetTimestamp=\"%s\"", dateAsString(resetTimestamp.getValue())));
             sb.append(String.format(" firstExchangeCompletedTimestamp=\"%s\"", dateAsString(firstExchangeCompletedTimestamp.getValue())));
             sb.append(String.format(" firstExchangeCompletedExchangeId=\"%s\"", nullSafe(firstExchangeCompletedExchangeId)));
             sb.append(String.format(" firstExchangeFailureTimestamp=\"%s\"", dateAsString(firstExchangeFailureTimestamp.getValue())));

Modified: 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=1464396&r1=1464395&r2=1464396&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/ProcessorStatDump.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/ProcessorStatDump.java Thu
Apr  4 09:35:00 2013
@@ -62,6 +62,9 @@ public final class ProcessorStatDump {
     private Long meanProcessingTime;
 
     @XmlAttribute
+    private String resetTimestamp;
+
+    @XmlAttribute
     private String firstExchangeCompletedTimestamp;
 
     @XmlAttribute
@@ -173,6 +176,14 @@ public final class ProcessorStatDump {
         this.meanProcessingTime = meanProcessingTime;
     }
 
+    public String getResetTimestamp() {
+        return resetTimestamp;
+    }
+
+    public void setResetTimestamp(String resetTimestamp) {
+        this.resetTimestamp = resetTimestamp;
+    }
+
     public String getFirstExchangeCompletedTimestamp() {
         return firstExchangeCompletedTimestamp;
     }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/RouteStatDump.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/RouteStatDump.java?rev=1464396&r1=1464395&r2=1464396&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/RouteStatDump.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/RouteStatDump.java Thu Apr
 4 09:35:00 2013
@@ -63,6 +63,9 @@ public final class RouteStatDump {
     private Long meanProcessingTime;
 
     @XmlAttribute
+    private String resetTimestamp;
+
+    @XmlAttribute
     private String firstExchangeCompletedTimestamp;
 
     @XmlAttribute
@@ -172,6 +175,14 @@ public final class RouteStatDump {
         this.meanProcessingTime = meanProcessingTime;
     }
 
+    public String getResetTimestamp() {
+        return resetTimestamp;
+    }
+
+    public void setResetTimestamp(String resetTimestamp) {
+        this.resetTimestamp = resetTimestamp;
+    }
+
     public String getFirstExchangeCompletedTimestamp() {
         return firstExchangeCompletedTimestamp;
     }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRoutePerformanceCounterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRoutePerformanceCounterTest.java?rev=1464396&r1=1464395&r2=1464396&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRoutePerformanceCounterTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRoutePerformanceCounterTest.java
Thu Apr  4 09:35:00 2013
@@ -72,6 +72,9 @@ public class ManagedRoutePerformanceCoun
         assertTrue("Should take around 3 sec: was " + last, last > 2900);
         assertTrue("Should be around 5 sec now: was " + total, total > 4900);
 
+        Date reset = (Date) mbeanServer.getAttribute(on, "ResetTimestamp");
+        assertNotNull(reset);
+
         Date lastFailed = (Date) mbeanServer.getAttribute(on, "LastExchangeFailureTimestamp");
         Date firstFailed = (Date) mbeanServer.getAttribute(on, "FirstExchangeFailureTimestamp");
         assertNull(lastFailed);

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=1464396&r1=1464395&r2=1464396&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 09:35:00 2013
@@ -104,8 +104,18 @@ public class ContextInfo extends OsgiCom
                 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(contextMBean,
"FirstExchangeCompletedTimestamp");
+                Object resetTimestampObj = mBeanServer.getAttribute(contextMBean, "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(contextMBean,
"FirstExchangeCompletedTimestamp");
                 if (firstExchangeTimestampObj == null) {
                     // Print an empty value for scripting
                     System.out.println(StringEscapeUtils.unescapeJava("\tFirst Exchange Date:"));

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=1464396&r1=1464395&r2=1464396&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 09:35:00 2013
@@ -101,8 +101,18 @@ public class RouteInfo extends OsgiComma
                     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");
+                    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:"));



Mime
View raw message