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 2021/01/29 11:12:23 UTC

[camel] branch master updated (a4f6087 -> 4b0efca)

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

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


    from a4f6087  camel-infinispan: implement route policy using clustering facilities
     new 9085572  CAMEL-16072: camel-main - Be less verbose when stopping. And return exit code from run method.
     new 7c996b4  CAMEL-16072: camel-main - be less verbose in summary off mode
     new f41c701  CAMEL-16072: Tabs as spaces
     new f2c51c4  CAMEL-16072: camel-main - be less verbose in summary off mode
     new 4b0efca  CAMEL-16072: camel-main - be less verbose in summary off mode

The 5 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/spring/camelContext.json      |  2 +-
 .../java/org/apache/camel/StartupSummaryLevel.java |  1 +
 .../camel/impl/engine/AbstractCamelContext.java    | 41 +++++++++++++---------
 .../org/apache/camel/main/BaseMainSupport.java     | 19 ++++++----
 .../camel/main/DefaultMainShutdownStrategy.java    |  2 +-
 .../src/main/java/org/apache/camel/main/Main.java  |  8 +++--
 .../apache/camel/main/MainCommandLineSupport.java  | 10 ++++--
 .../apache/camel/main/MainLifecycleStrategy.java   |  2 +-
 8 files changed, 52 insertions(+), 33 deletions(-)


[camel] 01/05: CAMEL-16072: camel-main - Be less verbose when stopping. And return exit code from run method.

Posted by da...@apache.org.
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.git

commit 9085572a87ad1f747c861fd64096593cf73aaf3e
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jan 29 11:30:09 2021 +0100

    CAMEL-16072: camel-main - Be less verbose when stopping. And return exit code from run method.
---
 .../org/apache/camel/main/DefaultMainShutdownStrategy.java     |  2 +-
 core/camel-main/src/main/java/org/apache/camel/main/Main.java  |  8 +++++---
 .../java/org/apache/camel/main/MainCommandLineSupport.java     | 10 +++++++---
 .../main/java/org/apache/camel/main/MainLifecycleStrategy.java |  2 +-
 4 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/core/camel-main/src/main/java/org/apache/camel/main/DefaultMainShutdownStrategy.java b/core/camel-main/src/main/java/org/apache/camel/main/DefaultMainShutdownStrategy.java
index a715066..9958622 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/DefaultMainShutdownStrategy.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/DefaultMainShutdownStrategy.java
@@ -72,7 +72,7 @@ public class DefaultMainShutdownStrategy extends SimpleMainShutdownStrategy {
     }
 
     private void handleHangup() {
-        LOG.info("Received hangup signal, stopping the main instance.");
+        LOG.debug("Received hangup signal, stopping the main instance.");
         // and shutdown listener to allow camel context to graceful shutdown if JVM shutdown hook is triggered
         // as otherwise the JVM terminates before Camel is graceful shutdown
         addShutdownListener(() -> {
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/Main.java b/core/camel-main/src/main/java/org/apache/camel/main/Main.java
index fcc4633..e666bc0 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/Main.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/Main.java
@@ -41,9 +41,11 @@ public class Main extends MainCommandLineSupport {
     public static void main(String... args) throws Exception {
         Main main = new Main();
         instance = main;
-        main.run(args);
-
-        System.exit(main.getExitCode());
+        int code = main.run(args);
+        if (code != 0) {
+            System.exit(code);
+        }
+        // normal exit
     }
 
     /**
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/MainCommandLineSupport.java b/core/camel-main/src/main/java/org/apache/camel/main/MainCommandLineSupport.java
index e82a7f0..9ad7322 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/MainCommandLineSupport.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/MainCommandLineSupport.java
@@ -159,12 +159,16 @@ public abstract class MainCommandLineSupport extends MainSupport {
     }
 
     /**
-     * Parses the command line arguments then runs the program.
+     * Parses the command line arguments then runs the program. The run method will keep blocking until the program is
+     * stopped.
+     *
+     * @return the exit code, usually 0 for normal termination.
      */
-    public void run(String[] args) throws Exception {
+    public int run(String[] args) throws Exception {
         parseArguments(args);
         run();
-        LOG.info("MainSupport exiting code: {}", getExitCode());
+
+        return getExitCode();
     }
 
     /**
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/MainLifecycleStrategy.java b/core/camel-main/src/main/java/org/apache/camel/main/MainLifecycleStrategy.java
index 080aaea..ddeb075 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/MainLifecycleStrategy.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/MainLifecycleStrategy.java
@@ -35,7 +35,7 @@ public class MainLifecycleStrategy extends LifecycleStrategySupport {
 
     @Override
     public void onContextStopping(CamelContext context) {
-        LOG.info("CamelContext: {} has been shutdown, triggering shutdown of the JVM.", context.getName());
+        LOG.debug("CamelContext: {} is stopping, triggering shutdown of the JVM.", context.getName());
 
         // trigger stopping the Main
         shutdownStrategy.shutdown();


[camel] 03/05: CAMEL-16072: Tabs as spaces

Posted by da...@apache.org.
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.git

commit f41c701a14a8fbe5aa23db1e2e16c851136cb8d9
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jan 29 11:47:02 2021 +0100

    CAMEL-16072: Tabs as spaces
---
 .../src/main/java/org/apache/camel/main/BaseMainSupport.java      | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
index a8a79e7..3101034 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
@@ -442,9 +442,9 @@ public abstract class BaseMainSupport extends BaseService {
             LOG.info("Auto-configuration summary");
             autoConfiguredProperties.forEach((k, v) -> {
                 if (SensitiveUtils.containsSensitive(k)) {
-                    LOG.info("\t{}=xxxxxx", k);
+                    LOG.info("    {}=xxxxxx", k);
                 } else {
-                    LOG.info("\t{}={}", k, v);
+                    LOG.info("    {}={}", k, v);
                 }
             });
         }
@@ -1279,9 +1279,9 @@ public abstract class BaseMainSupport extends BaseService {
                 LOG.info("Auto-configuration component {} summary", name);
                 autoConfiguredProperties.forEach((k, v) -> {
                     if (SensitiveUtils.containsSensitive(k)) {
-                        LOG.info("\t{}=xxxxxx", k);
+                        LOG.info("    {}=xxxxxx", k);
                     } else {
-                        LOG.info("\t{}={}", k, v);
+                        LOG.info("    {}={}", k, v);
                     }
                 });
             }


[camel] 04/05: CAMEL-16072: camel-main - be less verbose in summary off mode

Posted by da...@apache.org.
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.git

commit f2c51c4f6ce1bf0e76422597fe0387fdcf6803ea
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jan 29 12:01:09 2021 +0100

    CAMEL-16072: camel-main - be less verbose in summary off mode
---
 .../java/org/apache/camel/StartupSummaryLevel.java |  1 +
 .../camel/impl/engine/AbstractCamelContext.java    | 29 +++++++++++++---------
 2 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/core/camel-api/src/main/java/org/apache/camel/StartupSummaryLevel.java b/core/camel-api/src/main/java/org/apache/camel/StartupSummaryLevel.java
index 449d803..d025d67 100644
--- a/core/camel-api/src/main/java/org/apache/camel/StartupSummaryLevel.java
+++ b/core/camel-api/src/main/java/org/apache/camel/StartupSummaryLevel.java
@@ -28,6 +28,7 @@ public enum StartupSummaryLevel {
     Verbose,
     Default,
     Brief,
+    Oneline,
     Off
 
 }
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 04e225e..6cb184d 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
@@ -2924,7 +2924,8 @@ public abstract class AbstractCamelContext extends BaseService
     protected void logStartSummary() {
         // supervising route controller should do their own startup log summary
         boolean supervised = getRouteController().isSupervising();
-        if (!supervised && startupSummaryLevel != StartupSummaryLevel.Off && LOG.isInfoEnabled()) {
+        if (!supervised && startupSummaryLevel != StartupSummaryLevel.Oneline && startupSummaryLevel != StartupSummaryLevel.Off
+                && LOG.isInfoEnabled()) {
             int started = 0;
             int total = 0;
             int disabled = 0;
@@ -2970,14 +2971,17 @@ public abstract class AbstractCamelContext extends BaseService
             }
         }
 
-        long taken = stopWatch.taken();
-        long max = buildTaken + initTaken + taken;
-        String total = TimeUtils.printDuration(max);
-        String start = TimeUtils.printDuration(taken);
-        String init = TimeUtils.printDuration(initTaken);
-        String built = TimeUtils.printDuration(buildTaken);
-        LOG.info("Apache Camel {} ({}) started in {} (build:{} init:{} start:{})", getVersion(), getName(), total, built, init,
-                start);
+        if (startupSummaryLevel != StartupSummaryLevel.Off && LOG.isInfoEnabled()) {
+            long taken = stopWatch.taken();
+            long max = buildTaken + initTaken + taken;
+            String total = TimeUtils.printDuration(max);
+            String start = TimeUtils.printDuration(taken);
+            String init = TimeUtils.printDuration(initTaken);
+            String built = TimeUtils.printDuration(buildTaken);
+            LOG.info("Apache Camel {} ({}) started in {} (build:{} init:{} start:{})", getVersion(), getName(), total, built,
+                    init,
+                    start);
+        }
     }
 
     protected void doStartCamel() throws Exception {
@@ -3147,7 +3151,7 @@ public abstract class AbstractCamelContext extends BaseService
     protected void doStop() throws Exception {
         stopWatch.restart();
 
-        if (startupSummaryLevel != StartupSummaryLevel.Off) {
+        if (startupSummaryLevel != StartupSummaryLevel.Oneline && startupSummaryLevel != StartupSummaryLevel.Off) {
             if (shutdownStrategy != null && shutdownStrategy.getTimeUnit() != null) {
                 long timeout = shutdownStrategy.getTimeUnit().toMillis(shutdownStrategy.getTimeout());
                 String to = TimeUtils.printDuration(timeout);
@@ -3196,7 +3200,8 @@ public abstract class AbstractCamelContext extends BaseService
         }
         shutdownServices(list, false);
 
-        if (startupSummaryLevel != StartupSummaryLevel.Classic && startupSummaryLevel != StartupSummaryLevel.Off) {
+        if (startupSummaryLevel != StartupSummaryLevel.Classic && startupSummaryLevel != StartupSummaryLevel.Oneline
+                && startupSummaryLevel != StartupSummaryLevel.Off) {
             logRouteStopSummary();
         }
 
@@ -3286,7 +3291,7 @@ public abstract class AbstractCamelContext extends BaseService
                 LOG.info("Apache Camel {} ({}) is shutdown in {}", getVersion(), getName(),
                         TimeUtils.printDuration(stopWatch.taken()));
             }
-        } else {
+        } else if (startupSummaryLevel != StartupSummaryLevel.Off) {
             if (LOG.isInfoEnabled()) {
                 String taken = TimeUtils.printDuration(stopWatch.taken());
                 LOG.info("Apache Camel {} ({}) shutdown in {} (uptime:{})", getVersion(), getName(), taken, getUptime());


[camel] 05/05: CAMEL-16072: camel-main - be less verbose in summary off mode

Posted by da...@apache.org.
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.git

commit 4b0efca4973830814333597960f2aad26f5b5194
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jan 29 12:10:33 2021 +0100

    CAMEL-16072: camel-main - be less verbose in summary off mode
---
 .../src/generated/resources/org/apache/camel/spring/camelContext.json   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/components/camel-spring/src/generated/resources/org/apache/camel/spring/camelContext.json b/components/camel-spring/src/generated/resources/org/apache/camel/spring/camelContext.json
index b57b615..0e0c891 100644
--- a/components/camel-spring/src/generated/resources/org/apache/camel/spring/camelContext.json
+++ b/components/camel-spring/src/generated/resources/org/apache/camel/spring/camelContext.json
@@ -12,7 +12,7 @@
   },
   "properties": {
     "depends-on": { "kind": "attribute", "displayName": "Depends On", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "List of other bean id's this CamelContext depends up. Multiple bean id's can be separated by comma." },
-    "startupSummaryLevel": { "kind": "attribute", "displayName": "Startup Summary Level", "required": false, "type": "enum", "javaType": "org.apache.camel.StartupSummaryLevel", "enum": [ "brief", "classic", "default", "off", "verbose" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "Default", "description": "Controls the level of information logged during startup (and shutdown) of CamelContext." },
+    "startupSummaryLevel": { "kind": "attribute", "displayName": "Startup Summary Level", "required": false, "type": "enum", "javaType": "org.apache.camel.StartupSummaryLevel", "enum": [ "brief", "classic", "default", "off", "oneline", "verbose" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "Default", "description": "Controls the level of information logged during startup (and shutdown) of CamelContext." },
     "trace": { "kind": "attribute", "displayName": "Trace", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets whether tracing is enabled or not. To use tracing then this must be enabled on startup to be installed in the CamelContext." },
     "backlogTrace": { "kind": "attribute", "displayName": "Backlog Trace", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets whether backlog tracing is enabled or not. To use backlog tracing then this must be enabled on startup to be installed in the CamelContext." },
     "tracePattern": { "kind": "attribute", "displayName": "Trace Pattern", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Tracing pattern to match which node EIPs to trace. For example to match all To EIP nodes, use to. The pattern matches by node and route id's Multiple patterns can be separated by comma." },


[camel] 02/05: CAMEL-16072: camel-main - be less verbose in summary off mode

Posted by da...@apache.org.
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.git

commit 7c996b4fb60e8a3f56f5f35cd13fd89e3c20def7
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jan 29 11:42:56 2021 +0100

    CAMEL-16072: camel-main - be less verbose in summary off mode
---
 .../org/apache/camel/impl/engine/AbstractCamelContext.java | 14 ++++++++------
 .../main/java/org/apache/camel/main/BaseMainSupport.java   | 11 ++++++++---
 2 files changed, 16 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 a7c0cbc..04e225e 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
@@ -3147,12 +3147,14 @@ public abstract class AbstractCamelContext extends BaseService
     protected void doStop() throws Exception {
         stopWatch.restart();
 
-        if (shutdownStrategy != null && shutdownStrategy.getTimeUnit() != null) {
-            long timeout = shutdownStrategy.getTimeUnit().toMillis(shutdownStrategy.getTimeout());
-            String to = TimeUtils.printDuration(timeout);
-            LOG.info("Apache Camel {} ({}) shutting down (timeout:{})", getVersion(), getName(), to);
-        } else {
-            LOG.info("Apache Camel {} ({}) shutting down", getVersion(), getName());
+        if (startupSummaryLevel != StartupSummaryLevel.Off) {
+            if (shutdownStrategy != null && shutdownStrategy.getTimeUnit() != null) {
+                long timeout = shutdownStrategy.getTimeUnit().toMillis(shutdownStrategy.getTimeout());
+                String to = TimeUtils.printDuration(timeout);
+                LOG.info("Apache Camel {} ({}) shutting down (timeout:{})", getVersion(), getName(), to);
+            } else {
+                LOG.info("Apache Camel {} ({}) shutting down", getVersion(), getName());
+            }
         }
 
         EventHelper.notifyCamelContextStopping(this);
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
index 0bbc281..a8a79e7 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
@@ -738,7 +738,8 @@ public abstract class BaseMainSupport extends BaseService {
         if (!beansProperties.isEmpty()) {
             LOG.debug("Creating and binding beans to registry from loaded properties: {}", beansProperties.size());
             bindBeansToRegistry(camelContext, beansProperties, "camel.beans.",
-                    mainConfigurationProperties.isAutoConfigurationFailFast(), true, autoConfiguredProperties);
+                    mainConfigurationProperties.isAutoConfigurationFailFast(),
+                    mainConfigurationProperties.isAutoConfigurationLogSummary(), true, autoConfiguredProperties);
         }
         if (!contextProperties.isEmpty()) {
             LOG.debug("Auto-configuring CamelContext from loaded properties: {}", contextProperties.size());
@@ -986,7 +987,7 @@ public abstract class BaseMainSupport extends BaseService {
 
     private void bindBeansToRegistry(
             CamelContext camelContext, Map<String, Object> properties,
-            String optionPrefix, boolean failIfNotSet, boolean ignoreCase,
+            String optionPrefix, boolean failIfNotSet, boolean logSummary, boolean ignoreCase,
             Map<String, String> autoConfiguredProperties)
             throws Exception {
 
@@ -1006,7 +1007,11 @@ public abstract class BaseMainSupport extends BaseService {
                             "Cannot create/resolve bean with name " + name + " from value: " + value);
                 }
                 // register bean
-                LOG.info("Binding bean: {} (type: {}) to the registry", key, ObjectHelper.classCanonicalName(bean));
+                if (logSummary) {
+                    LOG.info("Binding bean: {} (type: {}) to the registry", key, ObjectHelper.classCanonicalName(bean));
+                } else {
+                    LOG.debug("Binding bean: {} (type: {}) to the registry", key, ObjectHelper.classCanonicalName(bean));
+                }
                 camelContext.getRegistry().bind(name, bean);
             }
         }