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/12 07:06:29 UTC
[2/2] camel git commit: CAMEL-11895: camel-hystrix - Expose state of
circuit breaker on JMX mbean / java api on processor.
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/82d77149
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/82d77149
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/82d77149
Branch: refs/heads/camel-2.20.x
Commit: 82d77149a1de459add8e45a3e6854ed84eeb5e8d
Parents: 6ac4066
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Oct 11 15:25:41 2017 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Oct 12 09:06:17 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/82d77149/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/82d77149/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);