svn commit: r663666 - in /activemq/camel/trunk/camel-core/src: main/java/org/apache/camel/management/PerformanceCounter.java test/java/org/apache/camel/management/JmxInstrumentationUsingDefaultsTest.java

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r663666 - in /activemq/camel/trunk/camel-core/src: main/java/org/apache/camel/management/PerformanceCounter.java test/java/org/apache/camel/management/JmxInstrumentationUsingDefaultsTest.java

hadrian-3
Author: hadrian
Date: Thu Jun  5 10:18:24 2008
New Revision: 663666

URL: http://svn.apache.org/viewvc?rev=663666&view=rev
Log:
CAMEL-578.  Patch applied with thanks!

Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/PerformanceCounter.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingDefaultsTest.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/PerformanceCounter.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/PerformanceCounter.java?rev=663666&r1=663665&r2=663666&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/PerformanceCounter.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/PerformanceCounter.java Thu Jun  5 10:18:24 2008
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.management;
 
+import java.util.Date;
 import java.util.concurrent.atomic.AtomicLong;
 
 import org.springframework.jmx.export.annotation.ManagedAttribute;
@@ -29,6 +30,8 @@
     private long minProcessingTime = -1L;
     private long maxProcessingTime = -1L;
     private double totalProcessingTime;
+    private Date lastExchangeCompletionTime;
+    private Date firstExchangeCompletionTime;
 
     @Override
     @ManagedOperation(description = "Reset counters")
@@ -38,6 +41,9 @@
         minProcessingTime = 0L;
         maxProcessingTime = 0L;
         totalProcessingTime = 0;
+        lastExchangeCompletionTime = null;
+        firstExchangeCompletionTime = null;
+
     }
 
     @ManagedAttribute(description = "Number of successful exchanges")
@@ -66,6 +72,16 @@
         return maxProcessingTime;
     }
 
+    @ManagedAttribute(description = "Last Exchange Completed Timestamp")
+    public synchronized Date getLastExchangeCompletionTime() {
+        return lastExchangeCompletionTime;
+    }
+
+    @ManagedAttribute(description = "First Exchange Completed Timestamp")
+    public synchronized Date getFirstExchangeCompletionTime() {
+        return firstExchangeCompletionTime;
+    }
+
     public synchronized void completedExchange(long time) {
         increment();
         numCompleted.incrementAndGet();
@@ -76,6 +92,11 @@
         if (time > maxProcessingTime) {
             maxProcessingTime = time;
         }
+        Date timestamp = new Date();
+        if (firstExchangeCompletionTime == null) {
+            firstExchangeCompletionTime = timestamp;
+        }
+        lastExchangeCompletionTime = timestamp;
     }
 
     public void completedExchange() {

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingDefaultsTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingDefaultsTest.java?rev=663666&r1=663665&r2=663666&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingDefaultsTest.java (original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingDefaultsTest.java Thu Jun  5 10:18:24 2008
@@ -115,6 +115,12 @@
         assertTrue(valueofMeanProcessingTime >= valueofMinProcessingTime
                    && valueofMeanProcessingTime <= valueofMaxProcessingTime);
 
+        assertNotNull("Expected first completion time to be available",
+                mbs.getAttribute(pcob, "FirstExchangeCompletionTime"));
+        
+        assertNotNull("Expected last completion time to be available",
+                mbs.getAttribute(pcob, "LastExchangeCompletionTime"));
+
     }
 
     protected void enableJmx() {