camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1361973 - /camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementLifecycleStrategy.java
Date Mon, 16 Jul 2012 11:25:37 GMT
Author: davsclaus
Date: Mon Jul 16 11:25:37 2012
New Revision: 1361973

URL: http://svn.apache.org/viewvc?rev=1361973&view=rev
Log:
CAMEL-5445: TimerManagerLoadTask thread name is now using the same name pattern as all the
other threads. Have to defer starting it until CamelContext fully started.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementLifecycleStrategy.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementLifecycleStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementLifecycleStrategy.java?rev=1361973&r1=1361972&r2=1361973&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementLifecycleStrategy.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementLifecycleStrategy.java
Mon Jul 16 11:25:37 2012
@@ -42,6 +42,7 @@ import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.Route;
 import org.apache.camel.Service;
+import org.apache.camel.StartupListener;
 import org.apache.camel.TimerListener;
 import org.apache.camel.VetoCamelContextStartException;
 import org.apache.camel.api.management.PerformanceCounter;
@@ -105,6 +106,7 @@ public class DefaultManagementLifecycleS
             new HashMap<Processor, KeyValueHolder<ProcessorDefinition<?>, InstrumentationProcessor>>();
     private final List<PreRegisterService> preServices = new ArrayList<PreRegisterService>();
     private final TimerListenerManager timerListenerManager = new TimerListenerManager();
+    private final TimerListenerManagerStartupListener timerManagerStartupListener = new TimerListenerManagerStartupListener();
     private volatile CamelContext camelContext;
     private volatile ManagedCamelContext camelContextMBean;
     private volatile boolean initialized;
@@ -844,14 +846,24 @@ public class DefaultManagementLifecycleS
     protected void doStart() throws Exception {
         ObjectHelper.notNull(camelContext, "CamelContext");
 
-        boolean enabled = camelContext.getManagementStrategy().getStatisticsLevel() != ManagementStatisticsLevel.Off;
-        if (enabled) {
-            LOG.info("StatisticsLevel at {} so enabling load performance statistics", camelContext.getManagementStrategy().getStatisticsLevel());
-            ScheduledExecutorService executorService = camelContext.getExecutorServiceManager().newSingleThreadScheduledExecutor(this,
"ManagementLoadTask");
-            timerListenerManager.setExecutorService(executorService);
-            // must use 1 sec interval as the load statistics is based on 1 sec calculations
-            timerListenerManager.setInterval(1000);
-            ServiceHelper.startService(timerListenerManager);
+        // defer starting the timer manager until CamelContext has been fully started
+        camelContext.addStartupListener(timerManagerStartupListener);
+    }
+
+    private final class TimerListenerManagerStartupListener implements StartupListener {
+
+        @Override
+        public void onCamelContextStarted(CamelContext context, boolean alreadyStarted) throws
Exception {
+            boolean enabled = camelContext.getManagementStrategy().getStatisticsLevel() !=
ManagementStatisticsLevel.Off;
+            if (enabled) {
+                LOG.info("StatisticsLevel at {} so enabling load performance statistics",
camelContext.getManagementStrategy().getStatisticsLevel());
+                // we have to defer creating this until CamelContext has been started
+                ScheduledExecutorService executorService = camelContext.getExecutorServiceManager().newSingleThreadScheduledExecutor(this,
"ManagementLoadTask");
+                timerListenerManager.setExecutorService(executorService);
+                // must use 1 sec interval as the load statistics is based on 1 sec calculations
+                timerListenerManager.setInterval(1000);
+                ServiceHelper.startService(timerListenerManager);
+            }
         }
     }
 



Mime
View raw message