You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2017/10/11 13:26:00 UTC

camel git commit: CAMEL-11895: camel-hystrix - Expose state of circuit breaker on JMX mbean / java api on processor.

Repository: camel
Updated Branches:
  refs/heads/master 8aa628ff0 -> ebf7b80c2


CAMEL-11895: camel-hystrix - Expose state of circuit breaker on JMX mbean / java api on processor.


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

Branch: refs/heads/master
Commit: ebf7b80c23006551f44000befa9a4347817ff97e
Parents: 8aa628f
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Oct 11 15:25:41 2017 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Oct 11 15:25:51 2017 +0200

----------------------------------------------------------------------
 .../component/hystrix/processor/HystrixProcessor.java     | 10 ++++++++++
 .../hystrix/processor/HystrixManagementTest.java          |  3 +++
 2 files changed, 13 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ebf7b80c/components/camel-hystrix/src/main/java/org/apache/camel/component/hystrix/processor/HystrixProcessor.java
----------------------------------------------------------------------
diff --git a/components/camel-hystrix/src/main/java/org/apache/camel/component/hystrix/processor/HystrixProcessor.java b/components/camel-hystrix/src/main/java/org/apache/camel/component/hystrix/processor/HystrixProcessor.java
index 3993a264..dddd2ad 100644
--- a/components/camel-hystrix/src/main/java/org/apache/camel/component/hystrix/processor/HystrixProcessor.java
+++ b/components/camel-hystrix/src/main/java/org/apache/camel/component/hystrix/processor/HystrixProcessor.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.hystrix.processor;
 import java.util.ArrayList;
 import java.util.List;
 
+import com.netflix.hystrix.HystrixCircuitBreaker;
 import com.netflix.hystrix.HystrixCommand;
 import com.netflix.hystrix.HystrixCommandGroupKey;
 import com.netflix.hystrix.HystrixCommandKey;
@@ -144,6 +145,15 @@ public class HystrixProcessor extends ServiceSupport implements AsyncProcessor,
         return 0;
     }
 
+    @ManagedAttribute
+    public boolean isCircuitBreakerOpen() {
+        HystrixCircuitBreaker cb = HystrixCircuitBreaker.Factory.getInstance(commandKey);
+        if (cb != null) {
+            return cb.isOpen();
+        }
+        return false;
+    }
+
     @Override
     public String getId() {
         return id;

http://git-wip-us.apache.org/repos/asf/camel/blob/ebf7b80c/components/camel-hystrix/src/test/java/org/apache/camel/component/hystrix/processor/HystrixManagementTest.java
----------------------------------------------------------------------
diff --git a/components/camel-hystrix/src/test/java/org/apache/camel/component/hystrix/processor/HystrixManagementTest.java b/components/camel-hystrix/src/test/java/org/apache/camel/component/hystrix/processor/HystrixManagementTest.java
index 4cb3db9..f281a05 100644
--- a/components/camel-hystrix/src/test/java/org/apache/camel/component/hystrix/processor/HystrixManagementTest.java
+++ b/components/camel-hystrix/src/test/java/org/apache/camel/component/hystrix/processor/HystrixManagementTest.java
@@ -76,6 +76,9 @@ public class HystrixManagementTest extends CamelTestSupport {
         Long errorCount = (Long) mbeanServer.getAttribute(on, "HystrixErrorCount");
         assertEquals(0, errorCount.longValue());
 
+        Boolean open = (Boolean) mbeanServer.getAttribute(on, "CircuitBreakerOpen");
+        assertEquals(false, open.booleanValue());
+
         // let it gather for a while
         Thread.sleep(1000);