camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1464435 - 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 11:03:41 GMT
Author: davsclaus
Date: Thu Apr  4 11:03:40 2013
New Revision: 1464435

URL: http://svn.apache.org/r1464435
Log:
CAMEL-6239: Added delta attribute to jmx performance stats, to show the +/- from last processing
time value.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedPerformanceCounterMBean.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/management/mbean/Statistic.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/RouteProfile.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedPerformanceCounterMBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedPerformanceCounterMBean.java?rev=1464435&r1=1464434&r2=1464435&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedPerformanceCounterMBean.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedPerformanceCounterMBean.java
Thu Apr  4 11:03:40 2013
@@ -53,6 +53,9 @@ public interface ManagedPerformanceCount
     @ManagedAttribute(description = "Last Processing Time [milliseconds]")
     long getLastProcessingTime() throws Exception;
 
+    @ManagedAttribute(description = "Delta Processing Time [milliseconds]")
+    long getDeltaProcessingTime() throws Exception;
+
     @ManagedAttribute(description = "Last Exchange Completed Timestamp")
     Date getLastExchangeCompletedTimestamp();
 

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=1464435&r1=1464434&r2=1464435&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 11:03:40 2013
@@ -40,6 +40,7 @@ public abstract class ManagedPerformance
     private Statistic maxProcessingTime;
     private Statistic totalProcessingTime;
     private Statistic lastProcessingTime;
+    private Statistic deltaProcessingTime;
     private Statistic meanProcessingTime;
     private Statistic firstExchangeCompletedTimestamp;
     private String firstExchangeCompletedExchangeId;
@@ -64,6 +65,7 @@ public abstract class ManagedPerformance
         this.maxProcessingTime = new Statistic("org.apache.camel.maximumProcessingTime",
this, Statistic.UpdateMode.MAXIMUM);
         this.totalProcessingTime = new Statistic("org.apache.camel.totalProcessingTime",
this, Statistic.UpdateMode.COUNTER);
         this.lastProcessingTime = new Statistic("org.apache.camel.lastProcessingTime", this,
Statistic.UpdateMode.VALUE);
+        this.deltaProcessingTime = new Statistic("org.apache.camel.deltaProcessingTime",
this, Statistic.UpdateMode.DELTA);
         this.meanProcessingTime = new Statistic("org.apache.camel.meanProcessingTime", this,
Statistic.UpdateMode.VALUE);
 
         this.firstExchangeCompletedTimestamp = new Statistic("org.apache.camel.firstExchangeCompletedTimestamp",
this, Statistic.UpdateMode.VALUE);
@@ -84,6 +86,7 @@ public abstract class ManagedPerformance
         maxProcessingTime.reset();
         totalProcessingTime.reset();
         lastProcessingTime.reset();
+        deltaProcessingTime.reset();
         meanProcessingTime.reset();
         firstExchangeCompletedTimestamp.reset();
         firstExchangeCompletedExchangeId = null;
@@ -135,6 +138,10 @@ public abstract class ManagedPerformance
         return lastProcessingTime.getValue();
     }
 
+    public long getDeltaProcessingTime() throws Exception {
+        return deltaProcessingTime.getValue();
+    }
+
     public Date getLastExchangeCompletedTimestamp() {
         long value = lastExchangeCompletedTimestamp.getValue();
         return value > 0 ? new Date(value) : null;
@@ -195,6 +202,7 @@ public abstract class ManagedPerformance
         maxProcessingTime.updateValue(time);
         totalProcessingTime.updateValue(time);
         lastProcessingTime.updateValue(time);
+        deltaProcessingTime.updateValue(time);
 
         long now = new Date().getTime();
         if (firstExchangeCompletedTimestamp.getUpdateCount() == 0) {
@@ -249,6 +257,7 @@ public abstract class ManagedPerformance
         sb.append(String.format(" maxProcessingTime=\"%s\"", maxProcessingTime.getValue()));
         sb.append(String.format(" totalProcessingTime=\"%s\"", totalProcessingTime.getValue()));
         sb.append(String.format(" lastProcessingTime=\"%s\"", lastProcessingTime.getValue()));
+        sb.append(String.format(" deltaProcessingTime=\"%s\"", deltaProcessingTime.getValue()));
         sb.append(String.format(" meanProcessingTime=\"%s\"", meanProcessingTime.getValue()));
 
         if (fullStats) {

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/Statistic.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/Statistic.java?rev=1464435&r1=1464434&r2=1464435&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/Statistic.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/Statistic.java
Thu Apr  4 11:03:40 2013
@@ -29,6 +29,9 @@ public class Statistic {
      * <li>DIFFERENCE - A statistic with this update mode is a value that represents
the difference
      * between the last two recorded values (or the initial value if two updates have
      * not been recorded).</li>
+     * <li>DELTA - A statistic with this update mode is a value that represents the
delta
+     * between the last two recorded values (or the initial value if two updates have
+     * not been recorded). This value can be negative if the delta goes up or down.</li>
      * <li>COUNTER - A statistic with this update mode interprets updates as increments
(positive values)
      * or decrements (negative values) to the current value.</li>
      * <li>MAXIMUM - A statistic with this update mode is a value that represents the
maximum value
@@ -38,10 +41,11 @@ public class Statistic {
      * <ul>
      */
     public enum UpdateMode {
-        VALUE, DIFFERENCE, COUNTER, MAXIMUM, MINIMUM
+        VALUE, DIFFERENCE, DELTA, COUNTER, MAXIMUM, MINIMUM
     }
 
     private final UpdateMode updateMode;
+    private long lastValue;
     private long value;
     private long updateCount;
 
@@ -70,6 +74,12 @@ public class Statistic {
                 this.value = -this.value;
             }
             break;
+        case DELTA:
+            if (updateCount > 0) {
+                this.lastValue = this.value;
+            }
+            this.value = newValue;
+            break;
         case MAXIMUM:
             // initialize value at first time
             if (this.updateCount == 0 || this.value < newValue) {
@@ -92,7 +102,15 @@ public class Statistic {
     }
 
     public synchronized long getValue() {
-        return this.value;
+        if (updateMode == UpdateMode.DELTA) {
+            if (updateCount == 0) {
+                return this.value;
+            } else {
+                return this.value - this.lastValue;
+            }
+        } else {
+            return this.value;
+        }
     }
 
     public synchronized long getUpdateCount() {
@@ -101,6 +119,7 @@ public class Statistic {
 
     public synchronized void reset() {
         this.value = 0;
+        this.lastValue = 0;
         this.updateCount = 0;
     }
 

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=1464435&r1=1464434&r2=1464435&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 11:03:40 2013
@@ -59,6 +59,9 @@ public final class ProcessorStatDump {
     private Long lastProcessingTime;
 
     @XmlAttribute
+    private Long deltaProcessingTime;
+
+    @XmlAttribute
     private Long meanProcessingTime;
 
     @XmlAttribute
@@ -168,6 +171,14 @@ public final class ProcessorStatDump {
         this.lastProcessingTime = lastProcessingTime;
     }
 
+    public Long getDeltaProcessingTime() {
+        return deltaProcessingTime;
+    }
+
+    public void setDeltaProcessingTime(Long deltaProcessingTime) {
+        this.deltaProcessingTime = deltaProcessingTime;
+    }
+
     public Long getMeanProcessingTime() {
         return meanProcessingTime;
     }

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=1464435&r1=1464434&r2=1464435&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 11:03:40 2013
@@ -60,6 +60,9 @@ public final class RouteStatDump {
     private Long lastProcessingTime;
 
     @XmlAttribute
+    private Long deltaProcessingTime;
+
+    @XmlAttribute
     private Long meanProcessingTime;
 
     @XmlAttribute
@@ -167,6 +170,14 @@ public final class RouteStatDump {
         this.lastProcessingTime = lastProcessingTime;
     }
 
+    public Long getDeltaProcessingTime() {
+        return deltaProcessingTime;
+    }
+
+    public void setDeltaProcessingTime(Long deltaProcessingTime) {
+        this.deltaProcessingTime = deltaProcessingTime;
+    }
+
     public Long getMeanProcessingTime() {
         return meanProcessingTime;
     }

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=1464435&r1=1464434&r2=1464435&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 11:03:40 2013
@@ -32,6 +32,9 @@ public class ManagedRoutePerformanceCoun
         MBeanServer mbeanServer = getMBeanServer();
         ObjectName on = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=routes,name=\"route1\"");
 
+        Long delta = (Long) mbeanServer.getAttribute(on, "DeltaProcessingTime");
+        assertEquals(0, delta.intValue());
+
         getMockEndpoint("mock:result").expectedMessageCount(1);
 
         template.asyncSendBody("direct:start", "Hello World");
@@ -55,9 +58,11 @@ public class ManagedRoutePerformanceCoun
         Long completed = (Long) mbeanServer.getAttribute(on, "ExchangesCompleted");
         assertEquals(1, completed.longValue());
 
+        delta = (Long) mbeanServer.getAttribute(on, "DeltaProcessingTime");
         Long last = (Long) mbeanServer.getAttribute(on, "LastProcessingTime");
         Long total = (Long) mbeanServer.getAttribute(on, "TotalProcessingTime");
 
+        assertNotNull(delta);
         assertTrue("Should take around 3 sec: was " + last, last > 2900);
         assertTrue("Should take around 3 sec: was " + total, total > 2900);
 
@@ -66,9 +71,11 @@ public class ManagedRoutePerformanceCoun
 
         completed = (Long) mbeanServer.getAttribute(on, "ExchangesCompleted");
         assertEquals(2, completed.longValue());
+        delta = (Long) mbeanServer.getAttribute(on, "DeltaProcessingTime");
         last = (Long) mbeanServer.getAttribute(on, "LastProcessingTime");
         total = (Long) mbeanServer.getAttribute(on, "TotalProcessingTime");
 
+        assertNotNull(delta);
         assertTrue("Should take around 3 sec: was " + last, last > 2900);
         assertTrue("Should be around 5 sec now: was " + total, total > 4900);
 

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=1464435&r1=1464434&r2=1464435&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 11:03:40 2013
@@ -41,8 +41,8 @@ import org.apache.karaf.util.StringEscap
 @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]";
+    protected static final String HEADER_FORMAT = "%-30s %10s %10s %12s %12s %12s %12s %12s
%12s";
+    protected static final String OUTPUT_FORMAT = "[%-28s] [%8d] [%8d] [%10d] [%10d] [%10d]
[%10d] [%10d] [%10d]";
 
     @Argument(index = 0, name = "route", description = "The Camel route ID.", required =
true, multiValued = false)
     String route;
@@ -87,9 +87,9 @@ public class RouteProfile extends OsgiCo
                     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(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.getMeanProcessingTime(), route.getMinProcessingTime(),
route.getMaxProcessingTime(), route.getTotalProcessingTime(), 0));
+                            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()) {
@@ -97,7 +97,7 @@ public class RouteProfile extends OsgiCo
                         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));
+                                ps.getDeltaProcessingTime(), ps.getMeanProcessingTime(),
ps.getMinProcessingTime(), ps.getMaxProcessingTime(), selfTime));
                     }
                 }
             } else {



Mime
View raw message