camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/2] camel git commit: CAMEL-7974: Circuit break store state on exchange
Date Fri, 07 Aug 2015 15:13:00 GMT
CAMEL-7974: Circuit break store state on exchange


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

Branch: refs/heads/master
Commit: 98e8657e25bc08987252dddca292cbbe4c59e2f3
Parents: 68c6c1a
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Fri Aug 7 17:20:08 2015 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Fri Aug 7 17:20:08 2015 +0200

----------------------------------------------------------------------
 .../loadbalancer/CircuitBreakerLoadBalancer.java  | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/98e8657e/camel-core/src/main/java/org/apache/camel/processor/loadbalancer/CircuitBreakerLoadBalancer.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/processor/loadbalancer/CircuitBreakerLoadBalancer.java
b/camel-core/src/main/java/org/apache/camel/processor/loadbalancer/CircuitBreakerLoadBalancer.java
index 3f3c484..7445a57 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/loadbalancer/CircuitBreakerLoadBalancer.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/loadbalancer/CircuitBreakerLoadBalancer.java
@@ -204,14 +204,7 @@ public class CircuitBreakerLoadBalancer extends LoadBalancerSupport implements
T
 
     public String dumpState() {
         int num = state.get();
-        String state;
-        if (num == 0) {
-            state = "closed";
-        } else if (num == 1) {
-            state = "half open";
-        } else {
-            state = "open";
-        }
+        String state = stateAsString(num);
         if (lastFailure > 0) {
             return String.format("State %s, failures %d, closed since %d", state, failures.get(),
System.currentTimeMillis() - lastFailure);
         } else {
@@ -226,7 +219,7 @@ public class CircuitBreakerLoadBalancer extends LoadBalancerSupport implements
T
         }
 
         // store state as exchange property
-        exchange.setProperty(Exchange.CIRCUIT_BREAKER_STATE, stateAsString());
+        exchange.setProperty(Exchange.CIRCUIT_BREAKER_STATE, stateAsString(state.get()));
 
         AsyncProcessor albp = AsyncProcessorConverterHelper.convert(processor);
         // Added a callback for processing the exchange in the callback
@@ -259,14 +252,13 @@ public class CircuitBreakerLoadBalancer extends LoadBalancerSupport
implements T
         return true;
     }
 
-    private String stateAsString() {
-        int num = state.get();
+    private static String stateAsString(int num) {
         if (num == STATE_CLOSED) {
             return "closed";
         } else if (num == STATE_HALF_OPEN) {
-            return "halfOpen";
+            return "half opened";
         } else {
-            return "open";
+            return "opened";
         }
     }
 


Mime
View raw message