camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject camel git commit: CAMEL-8824: Add startTimestamp to JMX attributes
Date Tue, 02 Jun 2015 08:04:05 GMT
Repository: camel
Updated Branches:
  refs/heads/master de1037475 -> 43bdad7da


CAMEL-8824: Add startTimestamp to JMX attributes


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/43bdad7d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/43bdad7d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/43bdad7d

Branch: refs/heads/master
Commit: 43bdad7da75cda447cce2d921f68a6aa123d5547
Parents: de10374
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Tue Jun 2 09:43:42 2015 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Tue Jun 2 09:43:42 2015 +0200

----------------------------------------------------------------------
 .../camel/api/management/mbean/ManagedCounterMBean.java  |  3 +++
 .../apache/camel/management/mbean/ManagedCounter.java    |  8 ++++++++
 .../management/mbean/ManagedPerformanceCounter.java      |  1 +
 .../java/org/apache/camel/util/CamelContextStatDump.java | 11 +++++++++++
 .../main/java/org/apache/camel/util/RouteStatDump.java   | 11 +++++++++++
 .../org/apache/camel/commands/ContextInfoCommand.java    |  9 +++++++++
 .../java/org/apache/camel/commands/RouteInfoCommand.java |  9 +++++++++
 7 files changed, 52 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/43bdad7d/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedCounterMBean.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedCounterMBean.java
b/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedCounterMBean.java
index 3f23e86..1fd60ea 100644
--- a/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedCounterMBean.java
+++ b/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedCounterMBean.java
@@ -26,6 +26,9 @@ public interface ManagedCounterMBean {
     @ManagedOperation(description = "Reset counters")
     void reset();
 
+    @ManagedAttribute(description = "Timestamp when the stats was initially started")
+    Date getStartTimestamp();
+
     @ManagedAttribute(description = "Timestamp when the stats was last reset or initially
started")
     Date getResetTimestamp();
 

http://git-wip-us.apache.org/repos/asf/camel/blob/43bdad7d/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCounter.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCounter.java
b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCounter.java
index 5db34c7..84907b9 100644
--- a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCounter.java
+++ b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCounter.java
@@ -25,11 +25,14 @@ import org.apache.camel.spi.ManagementStrategy;
 @ManagedResource(description = "Managed Counter")
 public abstract class ManagedCounter implements ManagedCounterMBean {
     protected Statistic exchangesTotal;
+    protected Statistic startTimestamp;
     protected Statistic resetTimestamp;
 
     public void init(ManagementStrategy strategy) {
         this.exchangesTotal = new Statistic("org.apache.camel.exchangesTotal", this, Statistic.UpdateMode.COUNTER);
+        this.startTimestamp = new Statistic("org.apache.camel.startTimestamp", this, Statistic.UpdateMode.VALUE);
         this.resetTimestamp = new Statistic("org.apache.camel.resetTimestamp", this, Statistic.UpdateMode.VALUE);
+        startTimestamp.updateValue(new Date().getTime());
         resetTimestamp.updateValue(new Date().getTime());
     }
 
@@ -38,6 +41,11 @@ public abstract class ManagedCounter implements ManagedCounterMBean {
         resetTimestamp.updateValue(new Date().getTime());
     }
 
+    public Date getStartTimestamp() {
+        long value = startTimestamp.getValue();
+        return value > 0 ? new Date(value) : null;
+    }
+
     public Date getResetTimestamp() {
         long value = resetTimestamp.getValue();
         return value > 0 ? new Date(value) : null;

http://git-wip-us.apache.org/repos/asf/camel/blob/43bdad7d/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedPerformanceCounter.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedPerformanceCounter.java
b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedPerformanceCounter.java
index 07c7f95..fe1320c 100644
--- a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedPerformanceCounter.java
+++ b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedPerformanceCounter.java
@@ -272,6 +272,7 @@ public abstract class ManagedPerformanceCounter extends ManagedCounter
implement
         sb.append(String.format(" meanProcessingTime=\"%s\"", meanProcessingTime.getValue()));
 
         if (fullStats) {
+            sb.append(String.format(" startTimestamp=\"%s\"", dateAsString(startTimestamp.getValue())));
             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)));

http://git-wip-us.apache.org/repos/asf/camel/blob/43bdad7d/camel-core/src/main/java/org/apache/camel/util/CamelContextStatDump.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/CamelContextStatDump.java b/camel-core/src/main/java/org/apache/camel/util/CamelContextStatDump.java
index 08680c3..ebe539a 100644
--- a/camel-core/src/main/java/org/apache/camel/util/CamelContextStatDump.java
+++ b/camel-core/src/main/java/org/apache/camel/util/CamelContextStatDump.java
@@ -75,6 +75,9 @@ public final class CamelContextStatDump {
     private Long selfProcessingTime;
 
     @XmlAttribute
+    private String startTimestamp;
+
+    @XmlAttribute
     private String resetTimestamp;
 
     @XmlAttribute
@@ -219,6 +222,14 @@ public final class CamelContextStatDump {
         this.exchangesInflight = exchangesInflight;
     }
 
+    public String getStartTimestamp() {
+        return startTimestamp;
+    }
+
+    public void setStartTimestamp(String startTimestamp) {
+        this.startTimestamp = startTimestamp;
+    }
+
     public String getResetTimestamp() {
         return resetTimestamp;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/43bdad7d/camel-core/src/main/java/org/apache/camel/util/RouteStatDump.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/RouteStatDump.java b/camel-core/src/main/java/org/apache/camel/util/RouteStatDump.java
index 9079384..d27f4b8 100644
--- a/camel-core/src/main/java/org/apache/camel/util/RouteStatDump.java
+++ b/camel-core/src/main/java/org/apache/camel/util/RouteStatDump.java
@@ -75,6 +75,9 @@ public final class RouteStatDump {
     private Long selfProcessingTime;
 
     @XmlAttribute
+    private String startTimestamp;
+
+    @XmlAttribute
     private String resetTimestamp;
 
     @XmlAttribute
@@ -219,6 +222,14 @@ public final class RouteStatDump {
         this.exchangesInflight = exchangesInflight;
     }
 
+    public String getStartTimestamp() {
+        return startTimestamp;
+    }
+
+    public void setStartTimestamp(String startTimestamp) {
+        this.startTimestamp = startTimestamp;
+    }
+
     public String getResetTimestamp() {
         return resetTimestamp;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/43bdad7d/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/ContextInfoCommand.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/ContextInfoCommand.java
b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/ContextInfoCommand.java
index 4a31da49..d2a9731 100644
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/ContextInfoCommand.java
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/ContextInfoCommand.java
@@ -195,6 +195,15 @@ public class ContextInfoCommand extends AbstractCamelCommand {
             out.println(stringEscape.unescapeJava("\tLast Processing Time: " + stat.getLastProcessingTime()
+ " ms"));
             out.println(stringEscape.unescapeJava("\tDelta Processing Time: " + stat.getDeltaProcessingTime()
+ " ms"));
 
+            if (isEmpty(stat.getStartTimestamp())) {
+                // Print an empty value for scripting
+                out.println(stringEscape.unescapeJava("\tStart Statistics Date:"));
+            } else {
+                Date date = new SimpleDateFormat(XML_TIMESTAMP_FORMAT).parse(stat.getStartTimestamp());
+                String text = new SimpleDateFormat(OUTPUT_TIMESTAMP_FORMAT).format(date);
+                out.println(stringEscape.unescapeJava("\tStart Statistics Date: " + text));
+            }
+
             // Test for null to see if a any exchanges have been processed first to avoid
NPE
             if (isEmpty(stat.getResetTimestamp())) {
                 // Print an empty value for scripting

http://git-wip-us.apache.org/repos/asf/camel/blob/43bdad7d/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteInfoCommand.java
----------------------------------------------------------------------
diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteInfoCommand.java
b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteInfoCommand.java
index f75fbc8..49bc4c1 100644
--- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteInfoCommand.java
+++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/RouteInfoCommand.java
@@ -76,6 +76,15 @@ public class RouteInfoCommand extends AbstractRouteCommand {
             out.println(stringEscape.unescapeJava("\tLast Processing Time: " + route.getLastProcessingTime()
+ " ms"));
             out.println(stringEscape.unescapeJava("\tDelta Processing Time: " + route.getDeltaProcessingTime()
+ " ms"));
 
+            if (isEmpty(route.getStartTimestamp())) {
+                // Print an empty value for scripting
+                out.println(stringEscape.unescapeJava("\tStart Statistics Date:"));
+            } else {
+                Date date = new SimpleDateFormat(XML_TIMESTAMP_FORMAT).parse(route.getStartTimestamp());
+                String text = new SimpleDateFormat(OUTPUT_TIMESTAMP_FORMAT).format(date);
+                out.println(stringEscape.unescapeJava("\tStart Statistics Date: " + text));
+            }
+
             // Test for null to see if a any exchanges have been processed first to avoid
NPE
             if (isEmpty(route.getResetTimestamp())) {
                 // Print an empty value for scripting


Mime
View raw message