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

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

commit c7214a7d1880b28598f0d31942636f658e25456d
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Sat Feb 24 14:00:54 2024 +0100

    CAMEL-18858: camel-core - Mark route as created by Kamelet so we know this, 
so we can filter out in tooling and whereelse (kamelet is a blackbox)
---
 .../camel/impl/engine/AbstractCamelContext.java    | 73 +++++++++++++++++++---
 1 file changed, 64 insertions(+), 9 deletions(-)

diff --git 
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
 
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
index 24cb8e2af08..d99e3368c28 100644
--- 
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
+++ 
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
@@ -2567,7 +2567,12 @@ public abstract class AbstractCamelContext extends 
BaseService
                 && LOG.isInfoEnabled()) {
             int started = 0;
             int total = 0;
+            int kamelets = 0;
+            int templates = 0;
+            int rests = 0;
             int disabled = 0;
+            boolean registerKamelets = 
getManagementStrategy().getManagementAgent().getRegisterRoutesCreateByKamelet();
+            boolean registerTemplates = 
getManagementStrategy().getManagementAgent().getRegisterRoutesCreateByTemplate();
             List<String> lines = new ArrayList<>();
             List<String> configs = new ArrayList<>();
             
routeStartupOrder.sort(Comparator.comparingInt(RouteStartupOrder::getStartupOrder));
@@ -2575,9 +2580,18 @@ public abstract class AbstractCamelContext extends 
BaseService
                 total++;
                 String id = order.getRoute().getRouteId();
                 String status = getRouteStatus(id).name();
-                if (ServiceStatus.Started.name().equals(status)) {
+                if (order.getRoute().isCreatedByKamelet()) {
+                    kamelets++;
+                } else if (order.getRoute().isCreatedByRouteTemplate()) {
+                    templates++;
+                } else if (order.getRoute().isCreatedByRestDsl()) {
+                    rests++;
+                }
+                boolean skip = (!registerKamelets && 
order.getRoute().isCreatedByKamelet()) || (!registerTemplates && 
order.getRoute().isCreatedByRouteTemplate());
+                if (!skip && ServiceStatus.Started.name().equals(status)) {
                     started++;
                 }
+
                 // use basic endpoint uri to not log verbose details or 
potential sensitive data
                 String uri = 
order.getRoute().getEndpoint().getEndpointBaseUri();
                 uri = URISupport.sanitizeUri(uri);
@@ -2585,7 +2599,9 @@ public abstract class AbstractCamelContext extends 
BaseService
                 if (startupSummaryLevel == StartupSummaryLevel.Verbose && loc 
!= null) {
                     lines.add(String.format("    %s %s (%s) (source: %s)", 
status, id, uri, loc));
                 } else {
-                    lines.add(String.format("    %s %s (%s)", status, id, 
uri));
+                    if (!skip) {
+                        lines.add(String.format("    %s %s (%s)", status, id, 
uri));
+                    }
                 }
                 String cid = order.getRoute().getConfigurationId();
                 if (cid != null) {
@@ -2601,6 +2617,14 @@ public abstract class AbstractCamelContext extends 
BaseService
                     if (ServiceStatus.Stopped.name().equals(status)) {
                         status = "Disabled";
                     }
+                    if (route.isCreatedByKamelet()) {
+                        kamelets++;
+                    } else if (route.isCreatedByRouteTemplate()) {
+                        templates++;
+                    } else if (route.isCreatedByRestDsl()) {
+                        rests++;
+                    }
+                    boolean skip = (!registerKamelets && 
route.isCreatedByKamelet()) || (!registerTemplates && 
route.isCreatedByRouteTemplate());
                     // use basic endpoint uri to not log verbose details or 
potential sensitive data
                     String uri = route.getEndpoint().getEndpointBaseUri();
                     uri = URISupport.sanitizeUri(uri);
@@ -2608,7 +2632,9 @@ public abstract class AbstractCamelContext extends 
BaseService
                     if (startupSummaryLevel == StartupSummaryLevel.Verbose && 
loc != null) {
                         lines.add(String.format("    %s %s (%s) (source: %s)", 
status, id, uri, loc));
                     } else {
-                        lines.add(String.format("    %s %s (%s)", status, id, 
uri));
+                        if (!skip) {
+                            lines.add(String.format("    %s %s (%s)", status, 
id, uri));
+                        }
                     }
 
                     String cid = route.getConfigurationId();
@@ -2617,10 +2643,17 @@ public abstract class AbstractCamelContext extends 
BaseService
                     }
                 }
             }
+            int newTotal = total;
+            if (!registerKamelets) {
+                newTotal -= kamelets;
+            }
+            if (!registerTemplates) {
+                newTotal -= templates;
+            }
             if (disabled > 0) {
-                LOG.info("Routes startup (total:{} started:{} disabled:{})", 
total, started, disabled);
+                LOG.info("Routes startup (total:{} started:{} disabled:{})", 
newTotal, started, disabled);
             } else if (total != started) {
-                LOG.info("Routes startup (total:{} started:{})", total, 
started);
+                LOG.info("Routes startup (total:{} started:{})", newTotal, 
started);
             } else {
                 LOG.info("Routes startup (started:{})", started);
             }
@@ -3024,6 +3057,11 @@ public abstract class AbstractCamelContext extends 
BaseService
             int total = 0;
             int stopped = 0;
             int forced = 0;
+            int kamelets = 0;
+            int templates = 0;
+            int rests = 0;
+            boolean registerKamelets = 
getManagementStrategy().getManagementAgent().getRegisterRoutesCreateByKamelet();
+            boolean registerTemplates = 
getManagementStrategy().getManagementAgent().getRegisterRoutesCreateByTemplate();
             List<String> lines = new ArrayList<>();
 
             final ShutdownStrategy shutdownStrategy = 
camelContextExtension.getShutdownStrategy();
@@ -3036,7 +3074,15 @@ public abstract class AbstractCamelContext extends 
BaseService
                 total++;
                 String id = order.getRoute().getRouteId();
                 String status = getRouteStatus(id).name();
-                if (ServiceStatus.Stopped.name().equals(status)) {
+                if (order.getRoute().isCreatedByKamelet()) {
+                    kamelets++;
+                } else if (order.getRoute().isCreatedByRouteTemplate()) {
+                    templates++;
+                } else if (order.getRoute().isCreatedByRestDsl()) {
+                    rests++;
+                }
+                boolean skip = (!registerKamelets && 
order.getRoute().isCreatedByKamelet()) || (!registerTemplates && 
order.getRoute().isCreatedByRouteTemplate());
+                if (!skip && ServiceStatus.Stopped.name().equals(status)) {
                     stopped++;
                 }
                 if 
(order.getRoute().getProperties().containsKey("forcedShutdown")) {
@@ -3046,12 +3092,21 @@ public abstract class AbstractCamelContext extends 
BaseService
                 // use basic endpoint uri to not log verbose details or 
potential sensitive data
                 String uri = 
order.getRoute().getEndpoint().getEndpointBaseUri();
                 uri = URISupport.sanitizeUri(uri);
-                lines.add(String.format("    %s %s (%s)", status, id, uri));
+                if (startupSummaryLevel == StartupSummaryLevel.Verbose || 
!skip) {
+                    lines.add(String.format("    %s %s (%s)", status, id, 
uri));
+                }
+            }
+            int newTotal = total;
+            if (!registerKamelets) {
+                newTotal -= kamelets;
+            }
+            if (!registerTemplates) {
+                newTotal -= templates;
             }
             if (forced > 0) {
-                logger.log(String.format("Routes stopped (total:%s stopped:%s 
forced:%s)", total, stopped, forced));
+                logger.log(String.format("Routes stopped (total:%s stopped:%s 
forced:%s)", newTotal, stopped, forced));
             } else if (total != stopped) {
-                logger.log(String.format("Routes stopped (total:%s 
stopped:%s)", total, stopped));
+                logger.log(String.format("Routes stopped (total:%s 
stopped:%s)", newTotal, stopped));
             } else {
                 logger.log(String.format("Routes stopped (stopped:%s)", 
stopped));
             }

Reply via email to