This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git
The following commit(s) were added to refs/heads/master by this push:
new 5f44053 CAMEL-15134: camel-health - Make routes health check
discoverable via classpath. And remove JMX evaluators and make it simpler API
to use.
5f44053 is described below
commit 5f44053535189ab6d3b1bd0b53b4c42266013ba3
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri May 29 12:34:15 2020 +0200
CAMEL-15134: camel-health - Make routes health check discoverable via
classpath. And remove JMX evaluators and make it simpler API to use.
---
.../src/main/docs/spring-boot.adoc | 15 +-
.../health/AbstractHealthCheckConfiguration.java | 34 ----
.../health/HealthCheckRoutesAutoConfiguration.java | 108 +----------
.../health/HealthCheckRoutesConfiguration.java | 212 ---------------------
.../health/HealthCheckVerboseConfiguration.java | 1 +
.../boot/health/HealthCheckRegistryTest.java | 90 ---------
6 files changed, 6 insertions(+), 454 deletions(-)
diff --git a/core/camel-spring-boot/src/main/docs/spring-boot.adoc
b/core/camel-spring-boot/src/main/docs/spring-boot.adoc
index e94f1eb..cd25c38 100644
--- a/core/camel-spring-boot/src/main/docs/spring-boot.adoc
+++ b/core/camel-spring-boot/src/main/docs/spring-boot.adoc
@@ -92,7 +92,7 @@ When using spring-boot with Spring Boot make sure to use the
following Maven dep
----
-The component supports 139 options, which are listed below.
+The component supports 126 options, which are listed below.
@@ -137,19 +137,6 @@ The component supports 139 options, which are listed below.
| *camel.component.properties.system-properties-mode* | Sets the JVM system
property mode (0 = never, 1 = fallback, 2 = override). The default mode
(override) is to use system properties if present, and override any existing
properties. OS environment variable mode is checked before JVM system property
mode | 2 | Integer
| *camel.dataformat.enabled* | Global option to enable/disable dataformat
auto-configuration, default is true. | true | Boolean
| *camel.health.check.routes.enabled* | Global option to enable/disable Camel
extended health check for routes, default is false. | false | Boolean
-| *camel.health.check.routes.threshold* | General health check configurations.
| | Map
-| *camel.health.check.routes.thresholds.exchanges-failed* | Number of failed
exchanges. | | Long
-| *camel.health.check.routes.thresholds.exchanges-inflight* | Number of
inflight exchanges. | | Long
-| *camel.health.check.routes.thresholds.external-redeliveries* | Number of
external initiated redeliveries (such as from JMS broker). | | Long
-| *camel.health.check.routes.thresholds.last-processing-time.failures* | The
threshold of number of failures. | | Integer
-| *camel.health.check.routes.thresholds.last-processing-time.threshold* | The
threshold value. | | String
-| *camel.health.check.routes.thresholds.max-processing-time.failures* | The
threshold of number of failures. | | Integer
-| *camel.health.check.routes.thresholds.max-processing-time.threshold* | The
threshold value. | | String
-| *camel.health.check.routes.thresholds.mean-processing-time.failures* | The
threshold of number of failures. | | Integer
-| *camel.health.check.routes.thresholds.mean-processing-time.threshold* | The
threshold value. | | String
-| *camel.health.check.routes.thresholds.min-processing-time.failures* | The
threshold of number of failures. | | Integer
-| *camel.health.check.routes.thresholds.min-processing-time.threshold* | The
threshold value. | | String
-| *camel.health.check.routes.thresholds.redeliveries* | Number of redeliveries
(internal only). | | Long
| *camel.health.enabled* | Global option to enable/disable camel health bean,
default is true. | true | Boolean
| *camel.language.enabled* | Global option to enable/disable language
auto-configuration, default is true. | true | Boolean
| *camel.springboot.allow-use-original-message* | Sets whether to allow access
to the original message from Camel's error handler, or from
org.apache.camel.spi.UnitOfWork.getOriginalInMessage(). Turning this off can
optimize performance, as defensive copy of the original message is not needed.
Default is false. | false | Boolean
diff --git
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/health/AbstractHealthCheckConfiguration.java
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/health/AbstractHealthCheckConfiguration.java
index 9b04eb3..09304f0 100644
---
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/health/AbstractHealthCheckConfiguration.java
+++
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/health/AbstractHealthCheckConfiguration.java
@@ -25,16 +25,6 @@ public abstract class AbstractHealthCheckConfiguration {
private Boolean enabled;
/**
- * Set the check interval.
- */
- private String interval;
-
- /**
- * Set the number of failure before reporting the service as un-healthy.
- */
- private Integer failureThreshold;
-
- /**
* Set if the check associated to this configuration is enabled or not.
*/
public Boolean isEnabled() {
@@ -48,36 +38,12 @@ public abstract class AbstractHealthCheckConfiguration {
this.enabled = enabled;
}
- public String getInterval() {
- return interval;
- }
-
- /**
- * Set the check interval.
- */
- public void setInterval(String interval) {
- this.interval = interval;
- }
-
- public Integer getFailureThreshold() {
- return failureThreshold;
- }
-
- /**
- * Set the number of failure before reporting the service as un-healthy.
- */
- public void setFailureThreshold(Integer failureThreshold) {
- this.failureThreshold = failureThreshold;
- }
-
/**
* Convert this configuration to a {@link HealthCheckConfiguration} using
default values.
*/
public HealthCheckConfiguration asHealthCheckConfiguration() {
return HealthCheckConfiguration.builder()
.enabled(this.isEnabled())
- .interval(this.getInterval())
- .failureThreshold(this.getFailureThreshold())
.build();
}
}
diff --git
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/health/HealthCheckRoutesAutoConfiguration.java
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/health/HealthCheckRoutesAutoConfiguration.java
index f4c1296..e9fc712 100644
---
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/health/HealthCheckRoutesAutoConfiguration.java
+++
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/health/HealthCheckRoutesAutoConfiguration.java
@@ -16,13 +16,10 @@
*/
package org.apache.camel.spring.boot.health;
-import org.apache.camel.catalog.impl.TimePatternConverter;
import org.apache.camel.health.HealthCheckRepository;
-import org.apache.camel.impl.health.RoutePerformanceCounterEvaluators;
import org.apache.camel.impl.health.RoutesHealthCheckRepository;
import org.apache.camel.spring.boot.CamelAutoConfiguration;
import org.apache.camel.spring.boot.util.GroupCondition;
-import org.apache.camel.util.ObjectHelper;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
@@ -42,108 +39,11 @@ public class HealthCheckRoutesAutoConfiguration {
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
@ConditionalOnMissingBean(RoutesHealthCheckRepository.class)
public HealthCheckRepository
routesHealthCheckRepository(HealthCheckRoutesConfiguration configuration) {
- final RoutesHealthCheckRepository repository = new
RoutesHealthCheckRepository();
- final HealthCheckRoutesConfiguration.ThresholdsConfiguration
thresholds = configuration.getThresholds();
-
- if (thresholds.getExchangesFailed() != null) {
-
repository.addEvaluator(RoutePerformanceCounterEvaluators.exchangesFailed(thresholds.getExchangesFailed()));
- }
- if (thresholds.getExchangesInflight() != null) {
-
repository.addEvaluator(RoutePerformanceCounterEvaluators.exchangesInflight(thresholds.getExchangesInflight()));
- }
- if (thresholds.getRedeliveries() != null) {
-
repository.addEvaluator(RoutePerformanceCounterEvaluators.redeliveries(thresholds.getRedeliveries()));
- }
- if (thresholds.getExternalRedeliveries() != null) {
-
repository.addEvaluator(RoutePerformanceCounterEvaluators.redeliveries(thresholds.getExternalRedeliveries()));
- }
- if (thresholds.getLastProcessingTime() != null) {
- final String time =
thresholds.getLastProcessingTime().getThreshold();
- final Integer failures =
thresholds.getLastProcessingTime().getFailures();
-
- if (ObjectHelper.isNotEmpty(time) &&
ObjectHelper.isNotEmpty(failures)) {
-
repository.addEvaluator(RoutePerformanceCounterEvaluators.lastProcessingTime(TimePatternConverter.toMilliSeconds(time),
failures));
- }
- }
- if (thresholds.getMinProcessingTime() != null) {
- final String time =
thresholds.getMinProcessingTime().getThreshold();
- final Integer failures =
thresholds.getMinProcessingTime().getFailures();
-
- if (ObjectHelper.isNotEmpty(time) &&
ObjectHelper.isNotEmpty(failures)) {
-
repository.addEvaluator(RoutePerformanceCounterEvaluators.minProcessingTime(TimePatternConverter.toMilliSeconds(time),
failures));
- }
- }
- if (thresholds.getMeanProcessingTime() != null) {
- final String time =
thresholds.getMeanProcessingTime().getThreshold();
- final Integer failures =
thresholds.getMeanProcessingTime().getFailures();
-
- if (ObjectHelper.isNotEmpty(time) &&
ObjectHelper.isNotEmpty(failures)) {
-
repository.addEvaluator(RoutePerformanceCounterEvaluators.meanProcessingTime(TimePatternConverter.toMilliSeconds(time),
failures));
- }
- }
- if (thresholds.getMaxProcessingTime() != null) {
- final String time =
thresholds.getMaxProcessingTime().getThreshold();
- final Integer failures =
thresholds.getMaxProcessingTime().getFailures();
-
- if (ObjectHelper.isNotEmpty(time) &&
ObjectHelper.isNotEmpty(failures)) {
-
repository.addEvaluator(RoutePerformanceCounterEvaluators.maxProcessingTime(TimePatternConverter.toMilliSeconds(time),
failures));
- }
+ if (configuration.isEnabled()) {
+ return new RoutesHealthCheckRepository();
+ } else {
+ return null;
}
-
- if (configuration.getThreshold() != null) {
- for (String key: configuration.getThreshold().keySet()) {
-
- final HealthCheckRoutesConfiguration.ThresholdsConfiguration
threshold = configuration.getThreshold(key);
-
- if (threshold.getExchangesFailed() != null) {
- repository.addRouteEvaluator(key,
RoutePerformanceCounterEvaluators.exchangesFailed(threshold.getExchangesFailed()));
- }
- if (threshold.getExchangesInflight() != null) {
- repository.addRouteEvaluator(key,
RoutePerformanceCounterEvaluators.exchangesInflight(threshold.getExchangesInflight()));
- }
- if (threshold.getRedeliveries() != null) {
- repository.addRouteEvaluator(key,
RoutePerformanceCounterEvaluators.redeliveries(threshold.getRedeliveries()));
- }
- if (threshold.getExternalRedeliveries() != null) {
- repository.addRouteEvaluator(key,
RoutePerformanceCounterEvaluators.redeliveries(threshold.getExternalRedeliveries()));
- }
-
- if (threshold.getLastProcessingTime() != null) {
- final String time =
threshold.getLastProcessingTime().getThreshold();
- final Integer failures =
threshold.getLastProcessingTime().getFailures();
-
- if (ObjectHelper.isNotEmpty(time) &&
ObjectHelper.isNotEmpty(failures)) {
- repository.addRouteEvaluator(key,
RoutePerformanceCounterEvaluators.lastProcessingTime(TimePatternConverter.toMilliSeconds(time),
failures));
- }
- }
- if (threshold.getMinProcessingTime() != null) {
- final String time =
threshold.getMinProcessingTime().getThreshold();
- final Integer failures =
threshold.getMinProcessingTime().getFailures();
-
- if (ObjectHelper.isNotEmpty(time) &&
ObjectHelper.isNotEmpty(failures)) {
- repository.addRouteEvaluator(key,
RoutePerformanceCounterEvaluators.minProcessingTime(TimePatternConverter.toMilliSeconds(time),
failures));
- }
- }
- if (threshold.getMeanProcessingTime() != null) {
- final String time =
threshold.getMeanProcessingTime().getThreshold();
- final Integer failures =
threshold.getMeanProcessingTime().getFailures();
-
- if (ObjectHelper.isNotEmpty(time) &&
ObjectHelper.isNotEmpty(failures)) {
- repository.addRouteEvaluator(key,
RoutePerformanceCounterEvaluators.meanProcessingTime(TimePatternConverter.toMilliSeconds(time),
failures));
- }
- }
- if (threshold.getMaxProcessingTime() != null) {
- final String time =
threshold.getMaxProcessingTime().getThreshold();
- final Integer failures =
threshold.getMaxProcessingTime().getFailures();
-
- if (ObjectHelper.isNotEmpty(time) &&
ObjectHelper.isNotEmpty(failures)) {
- repository.addRouteEvaluator(key,
RoutePerformanceCounterEvaluators.maxProcessingTime(TimePatternConverter.toMilliSeconds(time),
failures));
- }
- }
- }
- }
-
- return repository;
}
// ***************************************
diff --git
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/health/HealthCheckRoutesConfiguration.java
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/health/HealthCheckRoutesConfiguration.java
index 2cbcf65..09e3248 100644
---
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/health/HealthCheckRoutesConfiguration.java
+++
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/health/HealthCheckRoutesConfiguration.java
@@ -16,9 +16,6 @@
*/
package org.apache.camel.spring.boot.health;
-import java.util.Map;
-
-import org.apache.camel.util.ObjectHelper;
import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties(prefix = HealthConstants.HEALTH_CHECK_ROUTES_PREFIX)
@@ -28,16 +25,6 @@ public class HealthCheckRoutesConfiguration {
*/
private boolean enabled;
- /**
- * Threshold healthc check configurations.
- */
- private ThresholdsConfiguration thresholds = new ThresholdsConfiguration();
-
- /**
- * General health check configurations.
- */
- private Map<String, RouteThresholdsConfiguration> threshold;
-
public boolean isEnabled() {
return enabled;
}
@@ -46,203 +33,4 @@ public class HealthCheckRoutesConfiguration {
this.enabled = enabled;
}
- public ThresholdsConfiguration getThresholds() {
- return thresholds;
- }
-
- public Map<String, RouteThresholdsConfiguration> getThreshold() {
- return threshold;
- }
-
- public void setThreshold(Map<String, RouteThresholdsConfiguration>
threshold) {
- this.threshold = threshold;
- }
-
- public ThresholdsConfiguration getThreshold(String id) {
- ThresholdsConfiguration cfg;
-
- if (this.threshold == null) {
- cfg = this.thresholds.copy();
- } else {
- RouteThresholdsConfiguration routeCfg = this.threshold.get(id);
- //cfg = this.threshold.get(id);
-
- if (routeCfg == null) {
- cfg = this.thresholds.copy();
- } else {
- cfg = routeCfg;
-
- if (routeCfg.isInherit()) {
- routeCfg.exchangesFailed =
ObjectHelper.supplyIfEmpty(cfg.exchangesFailed, thresholds::getExchangesFailed);
- routeCfg.exchangesInflight =
ObjectHelper.supplyIfEmpty(cfg.exchangesInflight,
thresholds::getExchangesInflight);
- routeCfg.redeliveries =
ObjectHelper.supplyIfEmpty(cfg.redeliveries, thresholds::getRedeliveries);
- routeCfg.externalRedeliveries =
ObjectHelper.supplyIfEmpty(cfg.externalRedeliveries,
thresholds::getExternalRedeliveries);
- routeCfg.externalRedeliveries =
ObjectHelper.supplyIfEmpty(cfg.externalRedeliveries,
thresholds::getExternalRedeliveries);
- routeCfg.lastProcessingTime =
ObjectHelper.supplyIfEmpty(cfg.lastProcessingTime,
thresholds::getLastProcessingTime);
- routeCfg.minProcessingTime =
ObjectHelper.supplyIfEmpty(cfg.minProcessingTime,
thresholds::getMinProcessingTime);
- routeCfg.meanProcessingTime =
ObjectHelper.supplyIfEmpty(cfg.meanProcessingTime,
thresholds::getMeanProcessingTime);
- routeCfg.maxProcessingTime =
ObjectHelper.supplyIfEmpty(cfg.maxProcessingTime,
thresholds::getMaxProcessingTime);
- }
- }
- }
-
- return cfg;
- }
-
- public static class ThresholdsConfiguration implements Cloneable {
- /**
- * Number of failed exchanges.
- */
- protected Long exchangesFailed;
-
- /**
- * Number of inflight exchanges.
- */
- protected Long exchangesInflight;
-
- /**
- * Number of redeliveries (internal only).
- */
- protected Long redeliveries;
-
- /**
- * Number of external initiated redeliveries (such as from JMS broker).
- */
- protected Long externalRedeliveries;
-
- /**
- * Last processing time
- */
- protected ThresholdsWithFailuresConfiguration lastProcessingTime;
-
- /**
- * Min processing time
- */
- protected ThresholdsWithFailuresConfiguration minProcessingTime;
-
- /**
- * Mean processing time
- */
- protected ThresholdsWithFailuresConfiguration meanProcessingTime;
-
- /**
- * Max processing time
- */
- protected ThresholdsWithFailuresConfiguration maxProcessingTime;
-
- public Long getExchangesFailed() {
- return exchangesFailed;
- }
-
- public void setExchangesFailed(Long exchangesFailed) {
- this.exchangesFailed = exchangesFailed;
- }
-
- public Long getExchangesInflight() {
- return exchangesInflight;
- }
-
- public void setExchangesInflight(Long exchangesInflight) {
- this.exchangesInflight = exchangesInflight;
- }
-
- public Long getRedeliveries() {
- return redeliveries;
- }
-
- public void setRedeliveries(Long redeliveries) {
- this.redeliveries = redeliveries;
- }
-
- public Long getExternalRedeliveries() {
- return externalRedeliveries;
- }
-
- public void setExternalRedeliveries(Long externalRedeliveries) {
- this.externalRedeliveries = externalRedeliveries;
- }
-
- public ThresholdsWithFailuresConfiguration getLastProcessingTime() {
- return lastProcessingTime;
- }
-
- public void setLastProcessingTime(ThresholdsWithFailuresConfiguration
lastProcessingTime) {
- this.lastProcessingTime = lastProcessingTime;
- }
-
- public ThresholdsWithFailuresConfiguration getMinProcessingTime() {
- return minProcessingTime;
- }
-
- public void setMinProcessingTime(ThresholdsWithFailuresConfiguration
minProcessingTime) {
- this.minProcessingTime = minProcessingTime;
- }
-
- public ThresholdsWithFailuresConfiguration getMeanProcessingTime() {
- return meanProcessingTime;
- }
-
- public void setMeanProcessingTime(ThresholdsWithFailuresConfiguration
meanProcessingTime) {
- this.meanProcessingTime = meanProcessingTime;
- }
-
- public ThresholdsWithFailuresConfiguration getMaxProcessingTime() {
- return maxProcessingTime;
- }
-
- public void setMaxProcessingTime(ThresholdsWithFailuresConfiguration
maxProcessingTime) {
- this.maxProcessingTime = maxProcessingTime;
- }
-
- public ThresholdsConfiguration copy() {
- try {
- return (ThresholdsConfiguration)super.clone();
- } catch (CloneNotSupportedException e) {
- throw new RuntimeException(e);
- }
- }
- }
-
- public static class RouteThresholdsConfiguration extends
ThresholdsConfiguration {
- /**
- * Inherit from global from global configuration.
- */
- private boolean inherit = true;
-
- public boolean isInherit() {
- return inherit;
- }
-
- public void setInherit(boolean inherit) {
- this.inherit = inherit;
- }
- }
-
- public static class ThresholdsWithFailuresConfiguration {
- /**
- * The threshold value.
- */
- private String threshold;
-
- /**
- * The threshold of number of failures.
- */
- private Integer failures;
-
- public String getThreshold() {
- return threshold;
- }
-
- public void setThreshold(String threshold) {
- this.threshold = threshold;
- }
-
- public Integer getFailures() {
- return failures;
- }
-
- public void setFailures(Integer failures) {
- this.failures = failures;
- }
- }
}
diff --git
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/health/HealthCheckVerboseConfiguration.java
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/health/HealthCheckVerboseConfiguration.java
index 7f62eb0..85c7985 100644
---
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/health/HealthCheckVerboseConfiguration.java
+++
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/health/HealthCheckVerboseConfiguration.java
@@ -18,6 +18,7 @@ package org.apache.camel.spring.boot.health;
import org.springframework.boot.context.properties.ConfigurationProperties;
+// TODO: Move to actuate/health
@ConfigurationProperties("management.info.camel")
public class HealthCheckVerboseConfiguration {
/**
diff --git
a/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/health/HealthCheckRegistryTest.java
b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/health/HealthCheckRegistryTest.java
deleted file mode 100644
index 87d8652..0000000
---
a/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/health/HealthCheckRegistryTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.spring.boot.health;
-
-import java.util.Collection;
-import java.util.Optional;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.health.HealthCheckRegistry;
-import org.apache.camel.health.HealthCheckRepository;
-import org.apache.camel.impl.health.RegistryRepository;
-import org.apache.camel.impl.health.RoutePerformanceCounterEvaluators;
-import org.apache.camel.impl.health.RoutesHealthCheckRepository;
-import org.apache.camel.spring.boot.CamelAutoConfiguration;
-import
org.apache.camel.spring.boot.actuate.health.CamelHealthAutoConfiguration;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-@RunWith(SpringRunner.class)
-@SpringBootTest(
- classes = {
- CamelAutoConfiguration.class,
- CamelHealthAutoConfiguration.class,
- HealthCheckRoutesAutoConfiguration.class
- },
- properties = {
- "camel.health.check.routes.enabled = true",
- "camel.health.check.routes.thresholds.exchanges-failed = 1",
- "camel.health.check.routes.thresholds.last-processing-time.threshold =
1",
- "camel.health.check.routes.thresholds.last-processing-time.failures =
2",
- "camel.health.check.routes.threshold[route-1].inherit = false",
- "camel.health.check.routes.threshold[route-1].exchanges-inflight = 1",
- "camel.health.check.routes.threshold[route-2].inherit = true",
- "camel.health.check.routes.threshold[route-2].exchanges-inflight = 1",
- }
-)
-public class HealthCheckRegistryTest extends Assert {
- @Autowired
- private CamelContext context;
-
- @Test
- public void testRepositories() {
- Collection<HealthCheckRepository> repos =
HealthCheckRegistry.get(context).getRepositories();
-
- Assert.assertNotNull(repos);
- Assert.assertEquals(2, repos.size());
-
Assert.assertTrue(repos.stream().anyMatch(RegistryRepository.class::isInstance));
-
Assert.assertTrue(repos.stream().anyMatch(RoutesHealthCheckRepository.class::isInstance));
-
- Optional<RoutesHealthCheckRepository> repo = repos.stream()
- .filter(RoutesHealthCheckRepository.class::isInstance)
- .map(RoutesHealthCheckRepository.class::cast)
- .findFirst();
-
- Assert.assertTrue(repo.isPresent());
-
- // default thresholds configuration
- Assert.assertEquals(2, repo.get().evaluators().count());
- Assert.assertEquals(1,
repo.get().evaluators().filter(RoutePerformanceCounterEvaluators.ExchangesFailed.class::isInstance).count());
- Assert.assertEquals(1,
repo.get().evaluators().filter(RoutePerformanceCounterEvaluators.LastProcessingTime.class::isInstance).count());
-
- // route-1 does not inherit from default thresholds configuration
- Assert.assertEquals(1, repo.get().evaluators("route-1").count());
- Assert.assertEquals(1,
repo.get().evaluators("route-1").filter(RoutePerformanceCounterEvaluators.ExchangesInflight.class::isInstance).count());
-
- // route-2 inherits from default thresholds configuration
- Assert.assertEquals(3, repo.get().evaluators("route-2").count());
- Assert.assertEquals(1,
repo.get().evaluators("route-2").filter(RoutePerformanceCounterEvaluators.ExchangesFailed.class::isInstance).count());
- Assert.assertEquals(1,
repo.get().evaluators("route-2").filter(RoutePerformanceCounterEvaluators.LastProcessingTime.class::isInstance).count());
- Assert.assertEquals(1,
repo.get().evaluators("route-2").filter(RoutePerformanceCounterEvaluators.ExchangesInflight.class::isInstance).count());
- }
-}