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 2022/02/07 10:11:00 UTC
[camel] 01/02: CAMEL-17587: camel-health - Make Health Check API simpler
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit df1d150dc73c8bb4d118cafcf9a4f33a8c5c1a44
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Feb 7 10:56:55 2022 +0100
CAMEL-17587: camel-health - Make Health Check API simpler
---
...nsumerHealthCheckErrorDisabledConsumerTest.java | 4 -
.../TelegramConsumerHealthCheckErrorTest.java | 7 --
.../camel/health/HealthCheckConfiguration.java | 89 +---------------
.../org/apache/camel/health/HealthCheckFilter.java | 2 +-
.../apache/camel/impl/health/HealthCheckTest.java | 108 -------------------
.../camel/impl/health/AbstractHealthCheck.java | 116 ++++-----------------
.../impl/health/HealthCheckRegistryRepository.java | 3 -
...althCheckConfigurationPropertiesConfigurer.java | 18 ----
.../org/apache/camel/main/BaseMainSupport.java | 3 -
.../camel/main/MainHealthCheckConfigTest.java | 6 --
.../api/management/mbean/CamelOpenMBeanTypes.java | 9 +-
.../camel/management/mbean/ManagedCamelHealth.java | 10 +-
.../ROOT/pages/camel-3x-upgrade-guide-3_16.adoc | 28 +++--
13 files changed, 51 insertions(+), 352 deletions(-)
diff --git a/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/TelegramConsumerHealthCheckErrorDisabledConsumerTest.java b/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/TelegramConsumerHealthCheckErrorDisabledConsumerTest.java
index 1544d99..a9424bb 100644
--- a/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/TelegramConsumerHealthCheckErrorDisabledConsumerTest.java
+++ b/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/TelegramConsumerHealthCheckErrorDisabledConsumerTest.java
@@ -45,14 +45,10 @@ public class TelegramConsumerHealthCheckErrorDisabledConsumerTest extends Telegr
// enabling routes health check is a bit cumbersome via low-level Java code
HealthCheckRegistry hcr = context.getExtension(HealthCheckRegistry.class);
HealthCheckRepository repo = hcr.getRepository("routes").orElse((HealthCheckRepository) hcr.resolveById("routes"));
- // add some slack so the check should fail 5 times in a row to be DOWN
- repo.addConfiguration("*", HealthCheckConfiguration.builder().failureThreshold(5).build());
repo.setEnabled(true);
hcr.register(repo);
// enabling consumers health check is a bit cumbersome via low-level Java code
repo = hcr.getRepository("consumers").orElse((HealthCheckRepository) hcr.resolveById("consumers"));
- // add some slack so the check should fail 5 times in a row to be DOWN
- repo.addConfiguration("consumer:telegram", HealthCheckConfiguration.builder().failureThreshold(5).build());
// turn off all consumer health checks
repo.addConfiguration("consumer:*", HealthCheckConfiguration.builder().enabled(false).build());
repo.setEnabled(true);
diff --git a/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/TelegramConsumerHealthCheckErrorTest.java b/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/TelegramConsumerHealthCheckErrorTest.java
index 64890a4..25f586e 100644
--- a/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/TelegramConsumerHealthCheckErrorTest.java
+++ b/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/TelegramConsumerHealthCheckErrorTest.java
@@ -26,7 +26,6 @@ import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.component.telegram.util.TelegramMockRoutes;
import org.apache.camel.component.telegram.util.TelegramTestSupport;
import org.apache.camel.health.HealthCheck;
-import org.apache.camel.health.HealthCheckConfiguration;
import org.apache.camel.health.HealthCheckRegistry;
import org.apache.camel.health.HealthCheckRepository;
import org.awaitility.Awaitility;
@@ -46,8 +45,6 @@ public class TelegramConsumerHealthCheckErrorTest extends TelegramTestSupport {
HealthCheckRegistry hcr = context.getExtension(HealthCheckRegistry.class);
HealthCheckRepository repo
= hcr.getRepository("consumers").orElse((HealthCheckRepository) hcr.resolveById("consumers"));
- // add some slack so the check should fail 5 times in a row to be DOWN
- repo.addConfiguration("consumer:telegram", HealthCheckConfiguration.builder().failureThreshold(5).build());
repo.setEnabled(true);
hcr.register(repo);
@@ -59,10 +56,6 @@ public class TelegramConsumerHealthCheckErrorTest extends TelegramTestSupport {
HealthCheckRegistry hcr = context.getExtension(HealthCheckRegistry.class);
HealthCheckRepository repo = hcr.getRepository("consumers").get();
- // should not be DOWN from the start
- boolean down = repo.stream().anyMatch(h -> h.call().getState().equals(HealthCheck.State.DOWN));
- Assertions.assertFalse(down, "None health-check should be DOWN");
-
// wait until HC is DOWN
Awaitility.waitAtMost(5, TimeUnit.SECONDS).until(
() -> repo.stream().anyMatch(h -> h.call().getState().equals(HealthCheck.State.DOWN)));
diff --git a/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckConfiguration.java b/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckConfiguration.java
index 22eaeb9..9d7199e 100644
--- a/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckConfiguration.java
+++ b/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckConfiguration.java
@@ -16,22 +16,17 @@
*/
package org.apache.camel.health;
-import java.time.Duration;
-
import org.apache.camel.RuntimeCamelException;
-import org.apache.camel.util.ObjectHelper;
-import org.apache.camel.util.TimeUtils;
/**
* Configuration for {@link HealthCheck}.
*/
public class HealthCheckConfiguration implements Cloneable {
+ // TODO: Can we avoid this as there are no configuration: only enabled true|false
+
private String parent;
private boolean enabled = true;
- private long interval;
- private int failureThreshold;
- private int successThreshold;
// *************************************************
// Properties
@@ -61,39 +56,6 @@ public class HealthCheckConfiguration implements Cloneable {
this.enabled = enabled;
}
- public long getInterval() {
- return interval;
- }
-
- /**
- * Set the check interval in milli seconds.
- */
- public void setInterval(long interval) {
- this.interval = interval;
- }
-
- public int getFailureThreshold() {
- return failureThreshold;
- }
-
- /**
- * Set the number of failure before reporting the service as un-healthy.
- */
- public void setFailureThreshold(int failureThreshold) {
- this.failureThreshold = failureThreshold;
- }
-
- public int getSuccessThreshold() {
- return successThreshold;
- }
-
- /**
- * Set the number of success before reporting the service as healthy.
- */
- public void setSuccessThreshold(int successThreshold) {
- this.successThreshold = successThreshold;
- }
-
public HealthCheckConfiguration copy() {
try {
return (HealthCheckConfiguration) super.clone();
@@ -113,9 +75,6 @@ public class HealthCheckConfiguration implements Cloneable {
public static final class Builder implements org.apache.camel.Builder<HealthCheckConfiguration> {
private String parent;
private Boolean enabled;
- private Long interval;
- private Integer failureThreshold;
- private Integer successThreshold;
private Builder() {
}
@@ -128,15 +87,6 @@ public class HealthCheckConfiguration implements Cloneable {
if (this.enabled == null) {
this.enabled = template.enabled;
}
- if (this.interval == null) {
- this.interval = template.interval;
- }
- if (this.failureThreshold == null) {
- this.failureThreshold = template.failureThreshold;
- }
- if (this.successThreshold == null) {
- this.successThreshold = template.successThreshold;
- }
}
return this;
@@ -152,32 +102,6 @@ public class HealthCheckConfiguration implements Cloneable {
return this;
}
- public Builder interval(Duration interval) {
- this.interval = interval.toMillis();
- return this;
- }
-
- public Builder interval(String interval) {
- return ObjectHelper.isNotEmpty(interval)
- ? interval(TimeUtils.toMilliSeconds(interval))
- : this;
- }
-
- public Builder interval(long interval) {
- this.interval = interval;
- return this;
- }
-
- public Builder failureThreshold(int failureThreshold) {
- this.failureThreshold = failureThreshold;
- return this;
- }
-
- public Builder successThreshold(int successThreshold) {
- this.successThreshold = successThreshold;
- return this;
- }
-
@Override
public HealthCheckConfiguration build() {
HealthCheckConfiguration conf = new HealthCheckConfiguration();
@@ -187,15 +111,6 @@ public class HealthCheckConfiguration implements Cloneable {
if (enabled != null) {
conf.setEnabled(enabled);
}
- if (interval != null) {
- conf.setInterval(interval);
- }
- if (failureThreshold != null) {
- conf.setFailureThreshold(failureThreshold);
- }
- if (successThreshold != null) {
- conf.setSuccessThreshold(successThreshold);
- }
return conf;
}
}
diff --git a/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckFilter.java b/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckFilter.java
index 480ed0e..2481104 100644
--- a/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckFilter.java
+++ b/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckFilter.java
@@ -17,7 +17,7 @@
package org.apache.camel.health;
/**
- * Health check filter definition.
+ * Health check filter.
*/
@FunctionalInterface
public interface HealthCheckFilter {
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/health/HealthCheckTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/health/HealthCheckTest.java
index 1fe145d..1af8fb9 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/health/HealthCheckTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/health/HealthCheckTest.java
@@ -24,7 +24,6 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class HealthCheckTest {
@@ -54,113 +53,6 @@ public class HealthCheckTest {
assertFalse(result.getDetails().containsKey(AbstractHealthCheck.CHECK_ENABLED));
}
- @Test
- public void testInterval() throws Exception {
- MyHealthCheck check = new MyHealthCheck();
- check.setState(HealthCheck.State.UP);
- check.getConfiguration().setEnabled(true);
- check.getConfiguration().setInterval(1000);
-
- HealthCheck.Result result1 = check.call();
- assertEquals(HealthCheck.State.UP, result1.getState());
-
- Thread.sleep(100);
-
- HealthCheck.Result result2 = check.call();
- assertEquals(HealthCheck.State.UP, result2.getState());
- assertEquals(result1.getDetails().get(AbstractHealthCheck.INVOCATION_TIME),
- result2.getDetails().get(AbstractHealthCheck.INVOCATION_TIME));
- assertEquals(result1.getDetails().get(AbstractHealthCheck.INVOCATION_COUNT),
- result2.getDetails().get(AbstractHealthCheck.INVOCATION_COUNT));
- assertNotEquals(check.getMetaData().get(AbstractHealthCheck.INVOCATION_ATTEMPT_TIME),
- result2.getDetails().get(AbstractHealthCheck.INVOCATION_TIME));
-
- Thread.sleep(1250);
-
- HealthCheck.Result result3 = check.call();
- assertEquals(HealthCheck.State.UP, result3.getState());
- assertNotEquals(result2.getDetails().get(AbstractHealthCheck.INVOCATION_TIME),
- result3.getDetails().get(AbstractHealthCheck.INVOCATION_TIME));
- assertNotEquals(result2.getDetails().get(AbstractHealthCheck.INVOCATION_COUNT),
- result3.getDetails().get(AbstractHealthCheck.INVOCATION_COUNT));
- assertEquals(check.getMetaData().get(AbstractHealthCheck.INVOCATION_ATTEMPT_TIME),
- result3.getDetails().get(AbstractHealthCheck.INVOCATION_TIME));
- }
-
- @Test
- public void testFailureThreshold() throws Exception {
- MyHealthCheck check = new MyHealthCheck();
- check.setState(HealthCheck.State.DOWN);
- check.getConfiguration().setEnabled(true);
- check.getConfiguration().setFailureThreshold(3);
-
- HealthCheck.Result result;
-
- for (int i = 0; i < check.getConfiguration().getFailureThreshold(); i++) {
- result = check.call();
-
- assertEquals(HealthCheck.State.UP, result.getState());
- assertEquals(i + 1, result.getDetails().get(AbstractHealthCheck.INVOCATION_COUNT));
- assertEquals(i + 1, result.getDetails().get(AbstractHealthCheck.FAILURE_COUNT));
- }
-
- assertEquals(HealthCheck.State.DOWN, check.call().getState());
- }
-
- @Test
- public void testSuccessThreshold() throws Exception {
- MyHealthCheck check = new MyHealthCheck();
- check.setState(HealthCheck.State.UP);
- check.getConfiguration().setEnabled(true);
- check.getConfiguration().setSuccessThreshold(2);
-
- HealthCheck.Result result;
-
- for (int i = 0; i < check.getConfiguration().getSuccessThreshold(); i++) {
- result = check.call();
-
- assertEquals(HealthCheck.State.DOWN, result.getState());
- assertEquals(i + 1, result.getDetails().get(AbstractHealthCheck.INVOCATION_COUNT));
- assertEquals(i + 1, result.getDetails().get(AbstractHealthCheck.SUCCESS_COUNT));
- }
-
- assertEquals(HealthCheck.State.UP, check.call().getState());
- }
-
- @Test
- public void testIntervalThreshold() throws Exception {
- MyHealthCheck check = new MyHealthCheck();
- check.setState(HealthCheck.State.DOWN);
- check.getConfiguration().setEnabled(true);
- check.getConfiguration().setInterval(500);
- check.getConfiguration().setFailureThreshold(3);
-
- HealthCheck.Result result;
- int icount;
- int fcount;
-
- for (int i = 0; i < check.getConfiguration().getFailureThreshold(); i++) {
- result = check.call();
-
- icount = (int) result.getDetails().get(AbstractHealthCheck.INVOCATION_COUNT);
- fcount = (int) result.getDetails().get(AbstractHealthCheck.FAILURE_COUNT);
-
- assertEquals(HealthCheck.State.UP, result.getState());
- assertEquals(i + 1, icount);
- assertEquals(i + 1, fcount);
-
- result = check.call();
-
- assertEquals(HealthCheck.State.UP, result.getState());
- assertEquals(icount, result.getDetails().get(AbstractHealthCheck.INVOCATION_COUNT));
- assertEquals(fcount, result.getDetails().get(AbstractHealthCheck.FAILURE_COUNT));
-
- Thread.sleep(550);
- }
-
- assertEquals(HealthCheck.State.DOWN, check.call().getState());
- }
-
// ********************************
//
// ********************************
diff --git a/core/camel-health/src/main/java/org/apache/camel/impl/health/AbstractHealthCheck.java b/core/camel-health/src/main/java/org/apache/camel/impl/health/AbstractHealthCheck.java
index 4e70c7e..acd9264 100644
--- a/core/camel-health/src/main/java/org/apache/camel/impl/health/AbstractHealthCheck.java
+++ b/core/camel-health/src/main/java/org/apache/camel/impl/health/AbstractHealthCheck.java
@@ -16,7 +16,6 @@
*/
package org.apache.camel.impl.health;
-import java.time.Duration;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Collections;
@@ -45,10 +44,7 @@ public abstract class AbstractHealthCheck implements HealthCheck, CamelContextAw
private final String group;
private final String id;
private final ConcurrentMap<String, Object> meta;
-
private HealthCheckConfiguration configuration;
- private HealthCheck.Result lastResult;
- private ZonedDateTime lastInvocation;
protected AbstractHealthCheck(String id) {
this(null, id, null);
@@ -119,19 +115,14 @@ public abstract class AbstractHealthCheck implements HealthCheck, CamelContextAw
synchronized (lock) {
final HealthCheckConfiguration conf = getConfiguration();
final HealthCheckResultBuilder builder = HealthCheckResultBuilder.on(this);
- final ZonedDateTime now = ZonedDateTime.now();
final boolean enabled = conf.isEnabled();
- final long interval = conf.getInterval();
- final int failureThreshold = conf.getFailureThreshold();
- final int successThreshold = conf.getSuccessThreshold();
// Extract relevant information from meta data.
int invocationCount = (Integer) meta.getOrDefault(INVOCATION_COUNT, 0);
int failureCount = (Integer) meta.getOrDefault(FAILURE_COUNT, 0);
int successCount = (Integer) meta.getOrDefault(SUCCESS_COUNT, 0);
- String invocationTime = now.format(DateTimeFormatter.ISO_ZONED_DATE_TIME);
- boolean call = true;
+ String invocationTime = ZonedDateTime.now().format(DateTimeFormatter.ISO_ZONED_DATE_TIME);
// Set common meta-data
meta.put(INVOCATION_ATTEMPT_TIME, invocationTime);
@@ -145,94 +136,33 @@ public abstract class AbstractHealthCheck implements HealthCheck, CamelContextAw
return builder.unknown().build();
}
- // check if the last invocation is far enough to have this check invoked
- // again without violating the interval configuration.
- if (lastResult != null && lastInvocation != null && interval > 0) {
- Duration elapsed = Duration.between(lastInvocation, now);
+ LOGGER.debug("Invoke health-check {}/{}", getGroup(), getId());
+ doCall(builder, options);
- if (elapsed.compareTo(Duration.ofMillis(interval)) < 0) {
- LOGGER.debug("health-check {}/{} won't be invoked as interval ({}) is not yet expired (last-invocation={})",
- getGroup(),
- getId(),
- elapsed,
- lastInvocation);
+ // State should be set here
+ ObjectHelper.notNull(builder.state(), "Response State");
- call = false;
- }
+ if (builder.state() == State.DOWN) {
+ // reset success since it failed
+ successCount = 0;
+ } else if (builder.state() == State.UP) {
+ // reset failure since it ok
+ failureCount = 0;
}
- // Invoke the check.
- if (call) {
- LOGGER.debug("Invoke health-check {}/{}", getGroup(), getId());
-
- doCall(builder, options);
-
- // State should be set here
- ObjectHelper.notNull(builder.state(), "Response State");
-
- if (builder.state() == State.DOWN) {
- // reset success since it failed
- successCount = 0;
-
- // If the service is un-healthy but the number of time it
- // has been consecutively reported in this state is less
- // than the threshold configured, mark it as UP. This is
- // used to avoid false positive in case of glitches.
- if (failureCount++ < failureThreshold) {
- LOGGER.debug(
- "Health-check {}/{} has status DOWN but failure count ({}) is less than configured threshold ({})",
- getGroup(),
- getId(),
- failureCount,
- failureThreshold);
-
- builder.up();
- }
- } else if (builder.state() == State.UP) {
- // reset failure since it ok
- failureCount = 0;
-
- // If the service is healthy but the number of time it
- // has been consecutively reported in this state is less
- // than the threshold configured, mark it as DOWN. This is
- // used to avoid false positive in case of glitches.
- if (successCount++ < successThreshold) {
- LOGGER.debug(
- "Health-check {}/{} has status UP but success count ({}) is less than configured threshold ({})",
- getGroup(),
- getId(),
- successCount,
- successThreshold);
-
- builder.down();
- }
- }
-
- meta.put(INVOCATION_TIME, invocationTime);
- meta.put(INVOCATION_COUNT, ++invocationCount);
- meta.put(FAILURE_COUNT, failureCount);
- meta.put(SUCCESS_COUNT, successCount);
-
- // Copy some of the meta-data bits to the response attributes so the
- // response caches the health-check state at the time of the invocation.
- builder.detail(INVOCATION_TIME, meta.get(INVOCATION_TIME));
- builder.detail(INVOCATION_COUNT, meta.get(INVOCATION_COUNT));
- builder.detail(FAILURE_COUNT, meta.get(FAILURE_COUNT));
- builder.detail(SUCCESS_COUNT, meta.get(SUCCESS_COUNT));
-
- // update last invocation time.
- lastInvocation = now;
- } else if (lastResult != null) {
- lastResult.getMessage().ifPresent(builder::message);
- lastResult.getError().ifPresent(builder::error);
-
- builder.state(lastResult.getState());
- builder.details(lastResult.getDetails());
- }
+ meta.put(INVOCATION_TIME, invocationTime);
+ meta.put(INVOCATION_COUNT, ++invocationCount);
+ meta.put(FAILURE_COUNT, failureCount);
+ meta.put(SUCCESS_COUNT, successCount);
- lastResult = builder.build();
+ // Copy some meta-data bits to the response attributes so the
+ // response caches the health-check state at the time of the invocation.
+ builder.detail(INVOCATION_TIME, meta.get(INVOCATION_TIME));
+ builder.detail(INVOCATION_COUNT, meta.get(INVOCATION_COUNT));
+ builder.detail(FAILURE_COUNT, meta.get(FAILURE_COUNT));
+ builder.detail(SUCCESS_COUNT, meta.get(SUCCESS_COUNT));
- return lastResult;
+ return builder.build();
}
}
@@ -262,7 +192,7 @@ public abstract class AbstractHealthCheck implements HealthCheck, CamelContextAw
/**
* Invoke the health check.
*
- * @see {@link HealthCheck#call(Map)}
+ * @see HealthCheck#call(Map)
*/
protected abstract void doCall(HealthCheckResultBuilder builder, Map<String, Object> options);
}
diff --git a/core/camel-health/src/main/java/org/apache/camel/impl/health/HealthCheckRegistryRepository.java b/core/camel-health/src/main/java/org/apache/camel/impl/health/HealthCheckRegistryRepository.java
index 516581e..6db6238 100644
--- a/core/camel-health/src/main/java/org/apache/camel/impl/health/HealthCheckRegistryRepository.java
+++ b/core/camel-health/src/main/java/org/apache/camel/impl/health/HealthCheckRegistryRepository.java
@@ -101,9 +101,6 @@ public class HealthCheckRegistryRepository implements CamelContextAware, HealthC
HealthCheckConfiguration hcc = matchConfiguration(hc.getId());
if (hcc != null) {
hc.getConfiguration().setEnabled(hcc.isEnabled());
- hc.getConfiguration().setInterval(hcc.getInterval());
- hc.getConfiguration().setFailureThreshold(hcc.getFailureThreshold());
- hc.getConfiguration().setSuccessThreshold(hcc.getSuccessThreshold());
}
}
return hc;
diff --git a/core/camel-main/src/generated/java/org/apache/camel/main/HealthCheckConfigurationPropertiesConfigurer.java b/core/camel-main/src/generated/java/org/apache/camel/main/HealthCheckConfigurationPropertiesConfigurer.java
index 53c42cd..3ac7b62 100644
--- a/core/camel-main/src/generated/java/org/apache/camel/main/HealthCheckConfigurationPropertiesConfigurer.java
+++ b/core/camel-main/src/generated/java/org/apache/camel/main/HealthCheckConfigurationPropertiesConfigurer.java
@@ -23,14 +23,8 @@ public class HealthCheckConfigurationPropertiesConfigurer extends org.apache.cam
switch (ignoreCase ? name.toLowerCase() : name) {
case "enabled":
case "Enabled": target.setEnabled(property(camelContext, boolean.class, value)); return true;
- case "failurethreshold":
- case "FailureThreshold": target.setFailureThreshold(property(camelContext, int.class, value)); return true;
- case "interval":
- case "Interval": target.setInterval(property(camelContext, long.class, value)); return true;
case "parent":
case "Parent": target.setParent(property(camelContext, java.lang.String.class, value)); return true;
- case "successthreshold":
- case "SuccessThreshold": target.setSuccessThreshold(property(camelContext, int.class, value)); return true;
default: return false;
}
}
@@ -40,14 +34,8 @@ public class HealthCheckConfigurationPropertiesConfigurer extends org.apache.cam
switch (ignoreCase ? name.toLowerCase() : name) {
case "enabled":
case "Enabled": return boolean.class;
- case "failurethreshold":
- case "FailureThreshold": return int.class;
- case "interval":
- case "Interval": return long.class;
case "parent":
case "Parent": return java.lang.String.class;
- case "successthreshold":
- case "SuccessThreshold": return int.class;
default: return null;
}
}
@@ -58,14 +46,8 @@ public class HealthCheckConfigurationPropertiesConfigurer extends org.apache.cam
switch (ignoreCase ? name.toLowerCase() : name) {
case "enabled":
case "Enabled": return target.isEnabled();
- case "failurethreshold":
- case "FailureThreshold": return target.getFailureThreshold();
- case "interval":
- case "Interval": return target.getInterval();
case "parent":
case "Parent": return target.getParent();
- case "successthreshold":
- case "SuccessThreshold": return target.getSuccessThreshold();
default: return null;
}
}
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
index deb63b4..92f3d8c 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
@@ -1082,9 +1082,6 @@ public abstract class BaseMainSupport extends BaseService {
if (hc instanceof HealthCheck) {
((HealthCheck) hc).getConfiguration().setParent(hcc.getParent());
((HealthCheck) hc).getConfiguration().setEnabled(hcc.isEnabled());
- ((HealthCheck) hc).getConfiguration().setFailureThreshold(hcc.getFailureThreshold());
- ((HealthCheck) hc).getConfiguration().setSuccessThreshold(hcc.getSuccessThreshold());
- ((HealthCheck) hc).getConfiguration().setInterval(hcc.getInterval());
} else if (hc instanceof HealthCheckRepository) {
((HealthCheckRepository) hc).addConfiguration(id, hcc);
}
diff --git a/core/camel-main/src/test/java/org/apache/camel/main/MainHealthCheckConfigTest.java b/core/camel-main/src/test/java/org/apache/camel/main/MainHealthCheckConfigTest.java
index 15d6178..4342e11 100644
--- a/core/camel-main/src/test/java/org/apache/camel/main/MainHealthCheckConfigTest.java
+++ b/core/camel-main/src/test/java/org/apache/camel/main/MainHealthCheckConfigTest.java
@@ -86,8 +86,6 @@ public class MainHealthCheckConfigTest {
main.configure().addRoutesBuilder(new Routes());
main.addInitialProperty("camel.health.config[custom].parent", "registry-health-check-repository");
main.addInitialProperty("camel.health.config[custom].enabled", "false");
- main.addInitialProperty("camel.health.config[custom].interval", "20s");
- main.addInitialProperty("camel.health.config[custom].failure-threshold", "10");
main.start();
try {
@@ -103,8 +101,6 @@ public class MainHealthCheckConfigTest {
// This configuration will be overridden by the camel-main config properties
healthCheck.getConfiguration().setEnabled(true);
- healthCheck.getConfiguration().setInterval(10);
- healthCheck.getConfiguration().setFailureThreshold(5);
camelContext.getRegistry().bind("custom", healthCheck);
HealthCheckRegistry healthCheckRegistry = camelContext.getExtension(HealthCheckRegistry.class);
@@ -123,8 +119,6 @@ public class MainHealthCheckConfigTest {
HealthCheckConfiguration configuration = myCustomCheck.getConfiguration();
assertNotNull(configuration);
assertFalse(configuration.isEnabled());
- assertEquals(20000, configuration.getInterval());
- assertEquals(10, configuration.getFailureThreshold());
} finally {
main.stop();
}
diff --git a/core/camel-management-api/src/main/java/org/apache/camel/api/management/mbean/CamelOpenMBeanTypes.java b/core/camel-management-api/src/main/java/org/apache/camel/api/management/mbean/CamelOpenMBeanTypes.java
index 8b18b24..c12a5e0 100644
--- a/core/camel-management-api/src/main/java/org/apache/camel/api/management/mbean/CamelOpenMBeanTypes.java
+++ b/core/camel-management-api/src/main/java/org/apache/camel/api/management/mbean/CamelOpenMBeanTypes.java
@@ -236,16 +236,13 @@ public final class CamelOpenMBeanTypes {
"healthDetails", "Health Details",
new String[] {
"id", "group", "state", "enabled", "message", "failureUri", "failureCount", "failureStackTrace",
- "readiness", "liveness",
- "interval", "successThreshold", "failureThreshold" },
+ "readiness", "liveness" },
new String[] {
"ID", "Group", "State", "Enabled", "Message", "Failure Uri", "Failure Count", "Failure StackTrace",
- "Readiness", "Liveness",
- "Interval", "Success Threshold", "Failure Threshold" },
+ "Readiness", "Liveness" },
new OpenType[] {
SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.STRING,
- SimpleType.STRING, SimpleType.INTEGER, SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN,
- SimpleType.LONG, SimpleType.INTEGER, SimpleType.INTEGER });
+ SimpleType.STRING, SimpleType.INTEGER, SimpleType.STRING, SimpleType.BOOLEAN, SimpleType.BOOLEAN });
}
public static TabularType camelHealthDetailsTabularType() throws OpenDataException {
diff --git a/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedCamelHealth.java b/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedCamelHealth.java
index aa3f886..b76f851 100644
--- a/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedCamelHealth.java
+++ b/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedCamelHealth.java
@@ -132,10 +132,7 @@ public class ManagedCamelHealth implements ManagedCamelHealthMBean {
"failureCount",
"failureStackTrace",
"readiness",
- "liveness",
- "interval",
- "successThreshold",
- "failureThreshold"
+ "liveness"
},
new Object[] {
result.getCheck().getId(),
@@ -147,10 +144,7 @@ public class ManagedCamelHealth implements ManagedCamelHealthMBean {
failureCount,
stacktrace,
result.getCheck().isReadiness(),
- result.getCheck().isLiveness(),
- result.getCheck().getConfiguration().getInterval(),
- result.getCheck().getConfiguration().getSuccessThreshold(),
- result.getCheck().getConfiguration().getFailureThreshold()
+ result.getCheck().isLiveness()
});
answer.put(data);
diff --git a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_16.adoc b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_16.adoc
index 66f0728..ff26a48 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_16.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_16.adoc
@@ -6,13 +6,6 @@ from both 3.0 to 3.1 and 3.1 to 3.2.
== Upgrading Camel 3.15 to 3.16
-=== camel-main
-
-The option `camel.main.packageScanRouteBuilders` has been renamed to `camel.main.basePackageScan`.
-
-Using configuration classes must now implement the interface `org.apache.camel.main.CamelConfiguration`
-and the `configure` method now takes a `CamelContext` as argument.
-
=== camel-core
Change the default from `Override` to `Ignore` in the `TypeConverterExists` option,
@@ -22,7 +15,7 @@ Previously when Camel detected a duplicate type converter during startup, Camel
override the existing converter and log a WARN. A more correct behaviour would be
to keep the existing and ignore the duplicate.
-=== Saga EIP
+==== Saga EIP
Removed the deprecated `timeoutInMilliseconds` option, use `timeout` instead.
@@ -58,6 +51,25 @@ To:
</saga>
----
+=== camel-health
+
+The `HealthCheck` API has been simplified and removed the following configurations:
+
+- interval
+- success threshold
+- failure threshold
+
+These options would complicate health checks as they affect the outcome of health checks.
+It is better the checks always execute and the responsibility of the monitoring systems
+how to deal with interval between checks and thresholds.
+
+=== camel-main
+
+The option `camel.main.packageScanRouteBuilders` has been renamed to `camel.main.basePackageScan`.
+
+Using configuration classes must now implement the interface `org.apache.camel.main.CamelConfiguration`
+and the `configure` method now takes a `CamelContext` as argument.
+
=== camel-any23
The option `baseURI` is renamed to `baseUri`.