cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject [2/6] git commit: [CXF-5847]:Add operation to enable/disable ResponseTimeCounter
Date Mon, 07 Jul 2014 06:44:07 GMT
[CXF-5847]:Add operation to enable/disable ResponseTimeCounter


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

Branch: refs/heads/master
Commit: b7f754d0d6ec278c29907c4503ecac5d91ee81c3
Parents: b246f43
Author: Jim Ma <ema@apache.org>
Authored: Mon Jul 7 11:22:24 2014 +0800
Committer: Jim Ma <ema@apache.org>
Committed: Mon Jul 7 14:43:38 2014 +0800

----------------------------------------------------------------------
 .../management/counters/ResponseTimeCounter.java   | 17 ++++++++++++++++-
 .../counters/ResponseTimeCounterMBean.java         |  4 +++-
 2 files changed, 19 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/b7f754d0/rt/management/src/main/java/org/apache/cxf/management/counters/ResponseTimeCounter.java
----------------------------------------------------------------------
diff --git a/rt/management/src/main/java/org/apache/cxf/management/counters/ResponseTimeCounter.java
b/rt/management/src/main/java/org/apache/cxf/management/counters/ResponseTimeCounter.java
index 86ce8cb..4d051cf 100644
--- a/rt/management/src/main/java/org/apache/cxf/management/counters/ResponseTimeCounter.java
+++ b/rt/management/src/main/java/org/apache/cxf/management/counters/ResponseTimeCounter.java
@@ -36,12 +36,16 @@ public class ResponseTimeCounter implements ResponseTimeCounterMBean,
Counter {
     private long totalHandlingTime;    
     private long maxHandlingTime;
     private long minHandlingTime = Integer.MAX_VALUE;
+    private boolean enabled = true;
     
     public ResponseTimeCounter(ObjectName on) {
         objectName = on;     
     }
     
     public void  increase(MessageHandlingTimeRecorder mhtr) {
+        if (!enabled) {
+            return;
+        }
         invocations.getAndIncrement();
         FaultMode faultMode = mhtr.getFaultMode();
         if (null == faultMode) {
@@ -80,7 +84,7 @@ public class ResponseTimeCounter implements ResponseTimeCounterMBean, Counter
{
         if (maxHandlingTime < handlingTime) {
             maxHandlingTime = handlingTime;
         }
-        if (minHandlingTime > handlingTime) {
+        if (minHandlingTime == 0 | minHandlingTime > handlingTime) {
             minHandlingTime = handlingTime;
         }
     }
@@ -138,6 +142,17 @@ public class ResponseTimeCounter implements ResponseTimeCounterMBean,
Counter {
     
     public Number getTotalHandlingTime() {        
         return totalHandlingTime;
+    }
+
+    @Override
+    public void enable(boolean value) {
+        enabled = value;
+        
+    }
+
+    @Override
+    public boolean isEnabled() {
+        return enabled;
     }  
 
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/b7f754d0/rt/management/src/main/java/org/apache/cxf/management/counters/ResponseTimeCounterMBean.java
----------------------------------------------------------------------
diff --git a/rt/management/src/main/java/org/apache/cxf/management/counters/ResponseTimeCounterMBean.java
b/rt/management/src/main/java/org/apache/cxf/management/counters/ResponseTimeCounterMBean.java
index 116948a..d435c9b 100644
--- a/rt/management/src/main/java/org/apache/cxf/management/counters/ResponseTimeCounterMBean.java
+++ b/rt/management/src/main/java/org/apache/cxf/management/counters/ResponseTimeCounterMBean.java
@@ -33,6 +33,8 @@ public interface ResponseTimeCounterMBean {
     Number getAvgResponseTime();
     Number getMaxResponseTime();
     Number getMinResponseTime();   
-    Number getTotalHandlingTime();
+    Number getTotalHandlingTime();   
     void reset();
+    void enable(boolean value);
+    boolean isEnabled();
 }
\ No newline at end of file


Mime
View raw message