camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/2] git commit: CAMEL-7062: Ensure tracer/debugger lifecycle is stopped when Camel stops. And fixed backloger tracer leak with keep references to processor defs which wasnt needed afterall.
Date Thu, 12 Dec 2013 13:22:18 GMT
CAMEL-7062: Ensure tracer/debugger lifecycle is stopped when Camel stops. And fixed backloger
tracer leak with keep references to processor defs which wasnt needed afterall.


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

Branch: refs/heads/master
Commit: 4f663169ad7d02af02a6efeb57ce8a1fa8cce1ac
Parents: 2170352
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Thu Dec 12 13:19:21 2013 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Thu Dec 12 14:25:03 2013 +0100

----------------------------------------------------------------------
 .../processor/interceptor/BacklogTracer.java    | 34 --------------------
 .../processor/interceptor/DefaultChannel.java   | 27 ++--------------
 2 files changed, 3 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/4f663169/camel-core/src/main/java/org/apache/camel/processor/interceptor/BacklogTracer.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/processor/interceptor/BacklogTracer.java
b/camel-core/src/main/java/org/apache/camel/processor/interceptor/BacklogTracer.java
index cd825e5..6dde932 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/interceptor/BacklogTracer.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/interceptor/BacklogTracer.java
@@ -17,10 +17,8 @@
 package org.apache.camel.processor.interceptor;
 
 import java.util.ArrayList;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Queue;
-import java.util.Set;
 import java.util.concurrent.ArrayBlockingQueue;
 import java.util.concurrent.atomic.AtomicLong;
 
@@ -32,9 +30,7 @@ import org.apache.camel.api.management.mbean.BacklogTracerEventMessage;
 import org.apache.camel.model.ProcessorDefinition;
 import org.apache.camel.model.ProcessorDefinitionHelper;
 import org.apache.camel.model.RouteDefinition;
-import org.apache.camel.model.RouteDefinitionHelper;
 import org.apache.camel.spi.InterceptStrategy;
-import org.apache.camel.spi.NodeIdFactory;
 import org.apache.camel.support.ServiceSupport;
 import org.apache.camel.util.EndpointHelper;
 import org.apache.camel.util.ObjectHelper;
@@ -68,17 +64,11 @@ public class BacklogTracer extends ServiceSupport implements InterceptStrategy
{
     private String[] patterns;
     private String traceFilter;
     private Predicate predicate;
-    // remember the processors we are tracing, which we need later
-    private final Set<ProcessorDefinition<?>> processors = new HashSet<ProcessorDefinition<?>>();
 
     public BacklogTracer(CamelContext camelContext) {
         this.camelContext = camelContext;
     }
 
-    public void addDefinition(ProcessorDefinition<?> definition) {
-        processors.add(definition);
-    }
-
     public Queue<DefaultBacklogTracerEventMessage> getQueue() {
         return queue;
     }
@@ -172,10 +162,6 @@ public class BacklogTracer extends ServiceSupport implements InterceptStrategy
{
     }
 
     public void setEnabled(boolean enabled) {
-        // okay tracer is enabled then force auto assigning ids
-        if (enabled) {
-            forceAutoAssigningIds();
-        }
         this.enabled = enabled;
     }
 
@@ -322,10 +308,6 @@ public class BacklogTracer extends ServiceSupport implements InterceptStrategy
{
         return traceCounter.incrementAndGet();
     }
 
-    void stopProcessor(ProcessorDefinition<?> processorDefinition) {
-        this.processors.remove(processorDefinition);
-    }
-
     @Override
     protected void doStart() throws Exception {
     }
@@ -335,20 +317,4 @@ public class BacklogTracer extends ServiceSupport implements InterceptStrategy
{
         queue.clear();
     }
 
-    @Override
-    protected void doShutdown() throws Exception {
-        queue.clear();
-        processors.clear();
-    }
-
-    private void forceAutoAssigningIds() {
-        NodeIdFactory factory = camelContext.getNodeIdFactory();
-        if (factory != null) {
-            for (ProcessorDefinition<?> child : processors) {
-                // ensure also the children get ids assigned
-                RouteDefinitionHelper.forceAssignIds(camelContext, child);
-            }
-        }
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/4f663169/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultChannel.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultChannel.java
b/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultChannel.java
index 815b943..f29bb23 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultChannel.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultChannel.java
@@ -27,7 +27,6 @@ import org.apache.camel.CamelContextAware;
 import org.apache.camel.Channel;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
-import org.apache.camel.Service;
 import org.apache.camel.model.ModelChannel;
 import org.apache.camel.model.ProcessorDefinition;
 import org.apache.camel.model.ProcessorDefinitionHelper;
@@ -37,7 +36,6 @@ import org.apache.camel.processor.CamelInternalProcessor;
 import org.apache.camel.processor.InterceptorToAsyncProcessorBridge;
 import org.apache.camel.processor.WrapProcessor;
 import org.apache.camel.spi.InterceptStrategy;
-import org.apache.camel.spi.LifecycleStrategy;
 import org.apache.camel.spi.RouteContext;
 import org.apache.camel.util.OrderedComparator;
 import org.apache.camel.util.ServiceHelper;
@@ -200,9 +198,9 @@ public class DefaultChannel extends CamelInternalProcessor implements
ModelChann
 
         // then wrap the output with the backlog and tracer (backlog first, as we do not
want regular tracer to tracer the backlog)
         InterceptStrategy tracer = getOrCreateBacklogTracer();
+        camelContext.addService(tracer);
         if (tracer instanceof BacklogTracer) {
             BacklogTracer backlogTracer = (BacklogTracer) tracer;
-            backlogTracer.addDefinition(targetOutputDef);
 
             RouteDefinition route = ProcessorDefinitionHelper.getRoute(definition);
             boolean first = false;
@@ -214,6 +212,7 @@ public class DefaultChannel extends CamelInternalProcessor implements
ModelChann
 
             // add debugger as well so we have both tracing and debugging out of the box
             InterceptStrategy debugger = getOrCreateBacklogDebugger();
+            camelContext.addService(debugger);
             if (debugger instanceof BacklogDebugger) {
                 BacklogDebugger backlogDebugger = (BacklogDebugger) debugger;
                 addAdvice(new BacklogDebuggerAdvice(backlogDebugger, target, targetOutputDef));
@@ -229,6 +228,7 @@ public class DefaultChannel extends CamelInternalProcessor implements
ModelChann
         // end users have to explicit enable the tracer to use it, and then its okay if we
wrap
         // the processors (but by default tracer is disabled, and therefore we do not wrap
processors)
         tracer = getOrCreateTracer();
+        camelContext.addService(tracer);
         if (tracer != null) {
             TraceInterceptor trace = (TraceInterceptor) tracer.wrapProcessorInInterceptors(routeContext.getCamelContext(),
targetOutputDef, target, null);
             // trace interceptor need to have a reference to route context so we at runtime
can enable/disable tracing on-the-fly
@@ -321,13 +321,6 @@ public class DefaultChannel extends CamelInternalProcessor implements
ModelChann
             }
         }
 
-        // which we must manage as well
-        for (LifecycleStrategy strategy : camelContext.getLifecycleStrategies()) {
-            if (tracer instanceof Service) {
-                strategy.onServiceAdd(camelContext, (Service) tracer, null);
-            }
-        }
-
         return tracer;
     }
 
@@ -347,13 +340,6 @@ public class DefaultChannel extends CamelInternalProcessor implements
ModelChann
             }
         }
 
-        // which we must manage as well
-        for (LifecycleStrategy strategy : camelContext.getLifecycleStrategies()) {
-            if (tracer instanceof Service) {
-                strategy.onServiceAdd(camelContext, (Service) tracer, null);
-            }
-        }
-
         return tracer;
     }
 
@@ -373,13 +359,6 @@ public class DefaultChannel extends CamelInternalProcessor implements
ModelChann
             }
         }
 
-        // which we must manage as well
-        for (LifecycleStrategy strategy : camelContext.getLifecycleStrategies()) {
-            if (debugger instanceof Service) {
-                strategy.onServiceAdd(camelContext, (Service) debugger, null);
-            }
-        }
-
         return debugger;
     }
 


Mime
View raw message