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 2020/03/22 17:04:13 UTC

[camel] branch master updated: Lets log how long time it takes to load additional routes/rests from XML

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


The following commit(s) were added to refs/heads/master by this push:
     new 359a19c  Lets log how long time it takes to load additional routes/rests from XML
359a19c is described below

commit 359a19cd6bca6110039d19e443b767ebbde88bf2
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sun Mar 22 18:03:48 2020 +0100

    Lets log how long time it takes to load additional routes/rests from XML
---
 .../apache/camel/main/DefaultRoutesCollector.java  | 25 ++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/core/camel-main/src/main/java/org/apache/camel/main/DefaultRoutesCollector.java b/core/camel-main/src/main/java/org/apache/camel/main/DefaultRoutesCollector.java
index aad37b0..9fd329c 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/DefaultRoutesCollector.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/DefaultRoutesCollector.java
@@ -33,6 +33,7 @@ import org.apache.camel.spi.PackageScanResourceResolver;
 import org.apache.camel.util.AntPathMatcher;
 import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.StopWatch;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -99,23 +100,31 @@ public class DefaultRoutesCollector implements RoutesCollector {
 
         PackageScanResourceResolver resolver = camelContext.adapt(ExtendedCamelContext.class).getPackageScanResourceResolver();
 
+        StopWatch watch = new StopWatch();
+        int count = 0;
         String[] parts = directory.split(",");
         for (String part : parts) {
-            log.info("Loading additional Camel XML routes from: {}", part);
+            log.debug("Loading additional Camel XML routes from: {}", part);
             try {
                 Set<InputStream> set = resolver.findResources(part);
                 for (InputStream is : set) {
-                    log.debug("Found XML route: {}", is);
+                    log.debug("Found XML routes from location: {}", part);
                     ExtendedCamelContext ecc = camelContext.adapt(ExtendedCamelContext.class);
                     RoutesDefinition routes = (RoutesDefinition) ecc.getXMLRoutesDefinitionLoader().loadRoutesDefinition(ecc, is);
                     answer.add(routes);
                     IOHelper.close(is);
+                    count += routes.getRoutes().size();
                 }
             } catch (FileNotFoundException e) {
                 log.debug("No XML routes found in {}. Skipping XML routes detection.", part);
             } catch (Exception e) {
                 throw RuntimeCamelException.wrapRuntimeException(e);
             }
+            if (count > 0) {
+                log.info("Loaded {} ({} millis) additional Camel XML routes from: {}", count, watch.taken(), directory);
+            } else {
+                log.info("No additional Camel XML routes discovered from: {}", directory);
+            }
         }
 
         return answer;
@@ -127,23 +136,31 @@ public class DefaultRoutesCollector implements RoutesCollector {
 
         PackageScanResourceResolver resolver = camelContext.adapt(ExtendedCamelContext.class).getPackageScanResourceResolver();
 
+        StopWatch watch = new StopWatch();
+        int count = 0;
         String[] parts = directory.split(",");
         for (String part : parts) {
-            log.info("Loading additional Camel XML rests from: {}", part);
+            log.debug("Loading additional Camel XML rests from: {}", part);
             try {
                 Set<InputStream> set = resolver.findResources(part);
                 for (InputStream is : set) {
-                    log.debug("Found XML rest: {}", is);
+                    log.debug("Found XML rest from location: {}", part);
                     ExtendedCamelContext ecc = camelContext.adapt(ExtendedCamelContext.class);
                     RestsDefinition rests = (RestsDefinition) ecc.getXMLRoutesDefinitionLoader().loadRoutesDefinition(ecc, is);
                     answer.add(rests);
                     IOHelper.close(is);
+                    count += rests.getRests().size();
                 }
             } catch (FileNotFoundException e) {
                 log.debug("No XML rests found in {}. Skipping XML rests detection.", part);
             } catch (Exception e) {
                 throw RuntimeCamelException.wrapRuntimeException(e);
             }
+            if (count > 0) {
+                log.info("Loaded {} ({} millis) additional Camel XML rests from: {}", count, watch.taken(), directory);
+            } else {
+                log.info("No additional Camel XML rests discovered from: {}", directory);
+            }
         }
 
         return answer;