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 10:40:14 UTC

[camel] branch up created (now 0a37fc59dd0)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a change to branch up
in repository https://gitbox.apache.org/repos/asf/camel.git


      at 0a37fc59dd0 CAMEL-19646: camel-health - Routes controlled by superviser controller that is exhausted should report DOWN.

This branch includes the following new commits:

     new 0a37fc59dd0 CAMEL-19646: camel-health - Routes controlled by superviser controller that is exhausted should report DOWN.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[camel] 01/01: CAMEL-19646: camel-health - Routes controlled by superviser controller that is exhausted should report DOWN.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch up
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 0a37fc59dd060b27f4585921671f8fdce8d172c4
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Jul 25 12:39:58 2023 +0200

    CAMEL-19646: camel-health - Routes controlled by superviser controller that is exhausted should report DOWN.
---
 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() {