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/09/01 08:34:04 UTC
[camel] branch main updated (2189395a3db -> 632e1da6550)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
from 2189395a3db Sync deps
new 29d5f1c19e1 Polished
new 113a507cd9d CAMEL-18440: camel-health - Allow to call checks with custom exposure level.
new 632e1da6550 camel-jbang - Show ready column as kubernetes with 1/1 or 0/1
The 3 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.
Summary of changes:
.../org/apache/camel/health/HealthCheckHelper.java | 22 ++++++++++++++--------
.../engine/DefaultSupervisingRouteController.java | 14 +++++++-------
.../apache/camel/impl/health/RouteHealthCheck.java | 2 +-
.../camel/cli/connector/LocalCliConnector.java | 15 +++++----------
4 files changed, 27 insertions(+), 26 deletions(-)
[camel] 02/03: CAMEL-18440: camel-health - Allow to call checks with custom exposure level.
Posted by da...@apache.org.
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 113a507cd9d583d2062a8bf27487382543e1c55a
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Sep 1 10:24:52 2022 +0200
CAMEL-18440: camel-health - Allow to call checks with custom exposure level.
---
.../org/apache/camel/health/HealthCheckHelper.java | 22 ++++++++++++++--------
.../apache/camel/impl/health/RouteHealthCheck.java | 2 +-
2 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckHelper.java b/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckHelper.java
index 431f09db1f0..43bea0beab6 100644
--- a/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckHelper.java
+++ b/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckHelper.java
@@ -48,7 +48,7 @@ public final class HealthCheckHelper {
* Invokes the checks and returns a collection of results.
*/
public static Collection<HealthCheck.Result> invoke(CamelContext camelContext) {
- return invoke(camelContext, check -> Map.of(HealthCheck.CHECK_KIND, HealthCheck.Kind.ALL), check -> false);
+ return invoke(camelContext, check -> Map.of(HealthCheck.CHECK_KIND, HealthCheck.Kind.ALL), check -> false, null);
}
/**
@@ -56,7 +56,7 @@ public final class HealthCheckHelper {
*/
public static Collection<HealthCheck.Result> invokeReadiness(CamelContext camelContext) {
return invoke(camelContext, check -> Map.of(HealthCheck.CHECK_KIND, HealthCheck.Kind.READINESS),
- check -> !check.isReadiness());
+ check -> !check.isReadiness(), null);
}
/**
@@ -64,7 +64,7 @@ public final class HealthCheckHelper {
*/
public static Collection<HealthCheck.Result> invokeLiveness(CamelContext camelContext) {
return invoke(camelContext, check -> Map.of(HealthCheck.CHECK_KIND, HealthCheck.Kind.LIVENESS),
- check -> !check.isLiveness());
+ check -> !check.isLiveness(), null);
}
/**
@@ -74,7 +74,7 @@ public final class HealthCheckHelper {
CamelContext camelContext,
Function<HealthCheck, Map<String, Object>> optionsSupplier) {
- return invoke(camelContext, optionsSupplier, check -> false);
+ return invoke(camelContext, optionsSupplier, check -> false, null);
}
/**
@@ -84,7 +84,7 @@ public final class HealthCheckHelper {
CamelContext camelContext,
Predicate<HealthCheck> filter) {
- return invoke(camelContext, check -> Collections.emptyMap(), filter);
+ return invoke(camelContext, check -> Collections.emptyMap(), filter, null);
}
/**
@@ -93,11 +93,13 @@ public final class HealthCheckHelper {
* @param camelContext the camel context.
* @param optionsSupplier a supplier for options.
* @param filter filter to exclude some checks.
+ * @param exposureLevel full or oneline (null to use default)
*/
public static Collection<HealthCheck.Result> invoke(
CamelContext camelContext,
Function<HealthCheck, Map<String, Object>> optionsSupplier,
- Predicate<HealthCheck> filter) {
+ Predicate<HealthCheck> filter,
+ String exposureLevel) {
final HealthCheckRegistry registry = HealthCheckRegistry.get(camelContext);
@@ -116,8 +118,12 @@ public final class HealthCheckHelper {
return Collections.emptyList();
}
+ if (exposureLevel == null) {
+ exposureLevel = registry.getExposureLevel();
+ }
+
// the result includes all the details
- if ("full".equals(registry.getExposureLevel())) {
+ if ("full".equals(exposureLevel)) {
return result;
} else {
// are there any downs?
@@ -127,7 +133,7 @@ public final class HealthCheckHelper {
// default mode is to either be just UP or include all DOWNs
// oneline mode is either UP or DOWN
if (!downs.isEmpty()) {
- if ("oneline".equals(registry.getExposureLevel())) {
+ if ("oneline".equals(exposureLevel)) {
// grab first down
return Collections.singleton(downs.iterator().next());
} else {
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 1c54aab8099..e6584736e00 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
@@ -72,7 +72,7 @@ public class RouteHealthCheck extends AbstractHealthCheck {
// all attempts and be exhausted, and if so then we are in unknown status
// the supervised route controller would store the last error if the route is regarded
- // as unhealthy which we use to signal its down, otherwise we are in unknown state
+ // as unhealthy which we will use to signal it is down, otherwise we are in unknown state
builder.unknown();
if (route.getLastError() != null && route.getLastError().isUnhealthy()) {
builder.down();
[camel] 03/03: camel-jbang - Show ready column as kubernetes with 1/1 or 0/1
Posted by da...@apache.org.
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 632e1da65509f82dbb2433eec401979bbb5759e1
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Sep 1 10:33:26 2022 +0200
camel-jbang - Show ready column as kubernetes with 1/1 or 0/1
---
.../org/apache/camel/cli/connector/LocalCliConnector.java | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/dsl/camel-cli-connector/src/main/java/org/apache/camel/cli/connector/LocalCliConnector.java b/dsl/camel-cli-connector/src/main/java/org/apache/camel/cli/connector/LocalCliConnector.java
index ea28a956bed..da5fdf7b7f2 100644
--- a/dsl/camel-cli-connector/src/main/java/org/apache/camel/cli/connector/LocalCliConnector.java
+++ b/dsl/camel-cli-connector/src/main/java/org/apache/camel/cli/connector/LocalCliConnector.java
@@ -27,6 +27,7 @@ import java.lang.management.ThreadMXBean;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
+import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
@@ -41,6 +42,7 @@ import org.apache.camel.Route;
import org.apache.camel.console.DevConsole;
import org.apache.camel.health.HealthCheck;
import org.apache.camel.health.HealthCheckHelper;
+import org.apache.camel.health.HealthCheckRegistry;
import org.apache.camel.spi.CliConnector;
import org.apache.camel.spi.CliConnectorFactory;
import org.apache.camel.support.PatternHelper;
@@ -288,8 +290,6 @@ public class LocalCliConnector extends ServiceSupport implements CliConnector, C
.getDevConsoleResolver().resolveDevConsole("context");
DevConsole dc2 = camelContext.adapt(ExtendedCamelContext.class)
.getDevConsoleResolver().resolveDevConsole("route");
- int ready = 0;
- int total = 0;
if (dc != null && dc2 != null) {
JsonObject json = (JsonObject) dc.call(DevConsole.MediaType.JSON);
JsonObject json2 = (JsonObject) dc2.call(DevConsole.MediaType.JSON);
@@ -315,17 +315,12 @@ public class LocalCliConnector extends ServiceSupport implements CliConnector, C
if (gc != null) {
root.put("gc", gc);
}
- // and health-check readiness
+ // and health-check readiness (use 1/1 or 0/1 for UP or DOWN like kubernetes)
Collection<HealthCheck.Result> res = HealthCheckHelper.invokeReadiness(camelContext);
- for (var r : res) {
- if (r.getState().equals(HealthCheck.State.UP)) {
- ready++;
- }
- total++;
- }
+ int ready = HealthCheckHelper.isResultsUp(res, true) ? 1 : 0;
JsonObject hc = new JsonObject();
hc.put("ready", ready);
- hc.put("total", total);
+ hc.put("total", 1);
root.put("healthChecks", hc);
LOG.trace("Updating status file: {}", statusFile);
[camel] 01/03: Polished
Posted by da...@apache.org.
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 29d5f1c19e19dbd85ae2d57f9dff9136ac0c82ba
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Sep 1 10:03:07 2022 +0200
Polished
---
.../impl/engine/DefaultSupervisingRouteController.java | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
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 545a39c6bc4..19bb2e8cb00 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
@@ -242,7 +242,7 @@ public class DefaultSupervisingRouteController extends DefaultRouteController im
public void startRoute(String routeId) throws Exception {
final Optional<RouteHolder> route = routes.stream().filter(r -> r.getId().equals(routeId)).findFirst();
- if (!route.isPresent()) {
+ if (route.isEmpty()) {
// This route is unknown to this controller, apply default behaviour
// from super class.
super.startRoute(routeId);
@@ -255,7 +255,7 @@ public class DefaultSupervisingRouteController extends DefaultRouteController im
public void stopRoute(String routeId) throws Exception {
final Optional<RouteHolder> route = routes.stream().filter(r -> r.getId().equals(routeId)).findFirst();
- if (!route.isPresent()) {
+ if (route.isEmpty()) {
// This route is unknown to this controller, apply default behaviour
// from super class.
super.stopRoute(routeId);
@@ -268,7 +268,7 @@ public class DefaultSupervisingRouteController extends DefaultRouteController im
public void stopRoute(String routeId, Throwable cause) throws Exception {
final Optional<RouteHolder> route = routes.stream().filter(r -> r.getId().equals(routeId)).findFirst();
- if (!route.isPresent()) {
+ if (route.isEmpty()) {
// This route is unknown to this controller, apply default behaviour
// from super class.
super.stopRoute(routeId, cause);
@@ -281,7 +281,7 @@ public class DefaultSupervisingRouteController extends DefaultRouteController im
public void stopRoute(String routeId, long timeout, TimeUnit timeUnit) throws Exception {
final Optional<RouteHolder> route = routes.stream().filter(r -> r.getId().equals(routeId)).findFirst();
- if (!route.isPresent()) {
+ if (route.isEmpty()) {
// This route is unknown to this controller, apply default behaviour
// from super class.
super.stopRoute(routeId, timeout, timeUnit);
@@ -310,7 +310,7 @@ public class DefaultSupervisingRouteController extends DefaultRouteController im
public void suspendRoute(String routeId) throws Exception {
final Optional<RouteHolder> route = routes.stream().filter(r -> r.getId().equals(routeId)).findFirst();
- if (!route.isPresent()) {
+ if (route.isEmpty()) {
// This route is unknown to this controller, apply default behaviour
// from super class.
super.suspendRoute(routeId);
@@ -323,7 +323,7 @@ public class DefaultSupervisingRouteController extends DefaultRouteController im
public void suspendRoute(String routeId, long timeout, TimeUnit timeUnit) throws Exception {
final Optional<RouteHolder> route = routes.stream().filter(r -> r.getId().equals(routeId)).findFirst();
- if (!route.isPresent()) {
+ if (route.isEmpty()) {
// This route is unknown to this controller, apply default behaviour
// from super class.
super.suspendRoute(routeId, timeout, timeUnit);
@@ -336,7 +336,7 @@ public class DefaultSupervisingRouteController extends DefaultRouteController im
public void resumeRoute(String routeId) throws Exception {
final Optional<RouteHolder> route = routes.stream().filter(r -> r.getId().equals(routeId)).findFirst();
- if (!route.isPresent()) {
+ if (route.isEmpty()) {
// This route is unknown to this controller, apply default behaviour
// from super class.
super.resumeRoute(routeId);