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 2015/08/11 10:36:31 UTC

[2/5] camel git commit: CAMEL-9068: Log inflights per route during graceful shutdown

CAMEL-9068: Log inflights per route during graceful shutdown


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/249b2e8b
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/249b2e8b
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/249b2e8b

Branch: refs/heads/master
Commit: 249b2e8bd07b2e0d7f385cfe4cbed5cdac03e8c2
Parents: ea77507
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Aug 11 10:42:24 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Aug 11 10:42:50 2015 +0200

----------------------------------------------------------------------
 .../camel/impl/DefaultShutdownStrategy.java     | 24 +++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/249b2e8b/camel-core/src/main/java/org/apache/camel/impl/DefaultShutdownStrategy.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultShutdownStrategy.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultShutdownStrategy.java
index 6a96dae..eed2235 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultShutdownStrategy.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultShutdownStrategy.java
@@ -21,9 +21,11 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashSet;
+import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Locale;
+import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
@@ -45,6 +47,7 @@ import org.apache.camel.spi.ShutdownAware;
 import org.apache.camel.spi.ShutdownPrepared;
 import org.apache.camel.spi.ShutdownStrategy;
 import org.apache.camel.support.ServiceSupport;
+import org.apache.camel.util.CollectionStringBuffer;
 import org.apache.camel.util.EventHelper;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.ServiceHelper;
@@ -587,6 +590,9 @@ public class DefaultShutdownStrategy extends ServiceSupport implements ShutdownS
             long loopCount = 0;
             while (!done && !timeoutOccurred.get()) {
                 int size = 0;
+                // number of inflights per route
+                final Map<String, Integer> routeInflight = new LinkedHashMap<String, Integer>();
+
                 for (RouteStartupOrder order : routes) {
                     int inflight = context.getInflightRepository().size(order.getRoute().getId());
                     for (Consumer consumer : order.getInputs()) {
@@ -597,14 +603,26 @@ public class DefaultShutdownStrategy extends ServiceSupport implements ShutdownS
                         }
                     }
                     if (inflight > 0) {
+                        String routeId = order.getRoute().getId();
+                        routeInflight.put(routeId, inflight);
                         size += inflight;
-                        LOG.trace("{} inflight and pending exchanges for route: {}", inflight, order.getRoute().getId());
+                        LOG.trace("{} inflight and pending exchanges for route: {}", inflight, routeId);
                     }
                 }
                 if (size > 0) {
                     try {
-                        LOG.info("Waiting as there are still " + size + " inflight and pending exchanges to complete, timeout in "
-                             + (TimeUnit.SECONDS.convert(timeout, timeUnit) - (loopCount++ * loopDelaySeconds)) + " seconds.");
+                        // build a message with inflight per route
+                        CollectionStringBuffer csb = new CollectionStringBuffer();
+                        for (Map.Entry<String, Integer> entry : routeInflight.entrySet()) {
+                            String row = String.format("%s = %s", entry.getKey(), entry.getValue());
+                            csb.append(row);
+                        }
+
+                        String msg = "Waiting as there are still " + size + " inflight and pending exchanges to complete, timeout in "
+                                + (TimeUnit.SECONDS.convert(timeout, timeUnit) - (loopCount++ * loopDelaySeconds)) + " seconds.";
+                        msg += " Inflights per route: [" + csb.toString() + "]";
+
+                        LOG.info(msg);
 
                         // log verbose if DEBUG logging is enabled
                         logInflightExchanges(context, routes, false);