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 2023/07/25 11:38:04 UTC
[camel] branch main updated: CAMEL-19646: camel-health - Routes controlled by superviser controller that is exhausted should report DOWN. (#10819)
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
The following commit(s) were added to refs/heads/main by this push:
new 7b1a00aa819 CAMEL-19646: camel-health - Routes controlled by superviser controller that is exhausted should report DOWN. (#10819)
7b1a00aa819 is described below
commit 7b1a00aa819241da61c4dc704e6e7f1da95853d1
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Jul 25 13:37:58 2023 +0200
CAMEL-19646: camel-health - Routes controlled by superviser controller that is exhausted should report DOWN. (#10819)
---
core/camel-api/src/main/java/org/apache/camel/Route.java | 1 +
.../impl/engine/DefaultSupervisingRouteController.java | 1 +
.../org/apache/camel/impl/health/RouteHealthCheck.java | 14 +++++++++-----
.../org/apache/camel/support/HealthCheckComponent.java | 9 ++++++---
4 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/core/camel-api/src/main/java/org/apache/camel/Route.java b/core/camel-api/src/main/java/org/apache/camel/Route.java
index b2039689899..2491513ac7e 100644
--- a/core/camel-api/src/main/java/org/apache/camel/Route.java
+++ b/core/camel-api/src/main/java/org/apache/camel/Route.java
@@ -48,6 +48,7 @@ public interface Route extends RuntimeConfiguration {
String TEMPLATE_PROPERTY = "template";
String DESCRIPTION_PROPERTY = "description";
String CONFIGURATION_ID_PROPERTY = "configurationId";
+ String SUPERVISED = "supervised";
/**
* Gets the route id
diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultSupervisingRouteController.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultSupervisingRouteController.java
index 485c3570f24..a80559c84de 100644
--- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultSupervisingRouteController.java
+++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultSupervisingRouteController.java
@@ -825,6 +825,7 @@ public class DefaultSupervisingRouteController extends DefaultRouteController im
if (routes.add(holder)) {
holder.get().setRouteController(DefaultSupervisingRouteController.this);
holder.get().setAutoStartup(false);
+ holder.get().getProperties().put(Route.SUPERVISED, true); // mark route as being supervised
if (contextStarted.get()) {
LOG.debug("Context is already started: attempt to start route {}", route.getId());
diff --git a/core/camel-health/src/main/java/org/apache/camel/impl/health/RouteHealthCheck.java b/core/camel-health/src/main/java/org/apache/camel/impl/health/RouteHealthCheck.java
index 2e6496c8f6e..df01bf5ef7e 100644
--- a/core/camel-health/src/main/java/org/apache/camel/impl/health/RouteHealthCheck.java
+++ b/core/camel-health/src/main/java/org/apache/camel/impl/health/RouteHealthCheck.java
@@ -56,11 +56,8 @@ public class RouteHealthCheck extends AbstractHealthCheck {
builder.message(String.format("Route %s has status %s", route.getId(), status.name()));
}
} else {
- if (!route.isAutoStartup()) {
- // if a route is configured to not to automatically start, then the
- // route is always up as it is externally managed.
- builder.up();
- } else if (route.getRouteController() == null) {
+ if (route.getRouteController() == null
+ && Boolean.TRUE == route.getProperties().getOrDefault(Route.SUPERVISED, Boolean.FALSE)) {
// the route has no route controller which mean it may be supervised and then failed
// all attempts and be exhausted, and if so then we are in unknown status
@@ -70,6 +67,13 @@ public class RouteHealthCheck extends AbstractHealthCheck {
if (route.getLastError() != null && route.getLastError().isUnhealthy()) {
builder.down();
}
+ } else if (!route.isAutoStartup()) {
+ // if a route is configured to not to automatically start, then the
+ // route is always up as it is externally managed.
+ builder.up();
+ } else {
+ // route in unknown state
+ builder.unknown();
}
}
}
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/HealthCheckComponent.java b/core/camel-support/src/main/java/org/apache/camel/support/HealthCheckComponent.java
index 3263eeca25b..43f4215e157 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/HealthCheckComponent.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/HealthCheckComponent.java
@@ -24,13 +24,16 @@ import org.apache.camel.spi.Metadata;
*/
public abstract class HealthCheckComponent extends DefaultComponent {
- @Metadata(label = "health", defaultValue = "true", description = "Used for enabling or disabling all health checks from this component")
+ @Metadata(label = "health", defaultValue = "true",
+ description = "Used for enabling or disabling all health checks from this component")
private boolean healthCheckEnabled = true;
- @Metadata(label = "health", defaultValue = "true", description = "Used for enabling or disabling all consumer based health checks from this component")
+ @Metadata(label = "health", defaultValue = "true",
+ description = "Used for enabling or disabling all consumer based health checks from this component")
private boolean healthCheckConsumerEnabled = true;
- @Metadata(label = "health", defaultValue = "true", description = "Used for enabling or disabling all producer based health checks from this component")
+ @Metadata(label = "health", defaultValue = "true",
+ description = "Used for enabling or disabling all producer based health checks from this component")
private boolean healthCheckProducerEnabled = true;
public HealthCheckComponent() {