camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/3] camel git commit: CAMEL-9395: Reduce the number of default services registered in JMX
Date Sun, 06 Dec 2015 08:59:33 GMT
CAMEL-9395: Reduce the number of default services registered in JMX


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

Branch: refs/heads/master
Commit: 43a747deb5c4bcd25a3682d912d727a337f9b554
Parents: 7c02503
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Sat Dec 5 18:13:29 2015 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sat Dec 5 18:13:29 2015 +0100

----------------------------------------------------------------------
 .../org/apache/camel/NonManagedService.java     |   6 +-
 .../ManagedNonManagedServiceTest.java           | 112 +++++++++++++++++++
 .../quartz/ScheduledRoutePolicy.java            |   3 +-
 .../QuartzScheduledPollConsumerScheduler.java   |   3 +-
 .../quartz2/ScheduledRoutePolicy.java           |   3 +-
 .../SpringScheduledPollConsumerScheduler.java   |   3 +-
 .../zookeeper/policy/ZooKeeperRoutePolicy.java  |   3 +-
 7 files changed, 125 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/43a747de/camel-core/src/main/java/org/apache/camel/NonManagedService.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/NonManagedService.java b/camel-core/src/main/java/org/apache/camel/NonManagedService.java
index 37a7ed7..ae2ace3 100644
--- a/camel-core/src/main/java/org/apache/camel/NonManagedService.java
+++ b/camel-core/src/main/java/org/apache/camel/NonManagedService.java
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

http://git-wip-us.apache.org/repos/asf/camel/blob/43a747de/camel-core/src/test/java/org/apache/camel/management/ManagedNonManagedServiceTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/management/ManagedNonManagedServiceTest.java
b/camel-core/src/test/java/org/apache/camel/management/ManagedNonManagedServiceTest.java
new file mode 100644
index 0000000..a2ed6ed
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/management/ManagedNonManagedServiceTest.java
@@ -0,0 +1,112 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.management;
+
+import java.util.Set;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.camel.NonManagedService;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.spi.LifecycleStrategy;
+import org.apache.camel.support.ServiceSupport;
+
+/**
+ * @version 
+ */
+public class ManagedNonManagedServiceTest extends ManagementTestSupport {
+
+    public void testService() throws Exception {
+        // JMX tests dont work well on AIX CI servers (hangs them)
+        if (isPlatform("aix")) {
+            return;
+        }
+
+        // must enable always as CamelContext has been started
+        // and we add the service manually below
+        context.getManagementStrategy().getManagementAgent().setRegisterAlways(true);
+
+        MyService service = new MyService();
+        for (LifecycleStrategy strategy : context.getLifecycleStrategies()) {
+            strategy.onServiceAdd(context, service, null);
+        }
+
+        MBeanServer mbeanServer = getMBeanServer();
+
+        Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=services,*"),
null);
+        assertEquals(9, set.size());
+    }
+
+    public void testNonManagedService() throws Exception {
+        // JMX tests dont work well on AIX CI servers (hangs them)
+        if (isPlatform("aix")) {
+            return;
+        }
+
+        // must enable always as CamelContext has been started
+        // and we add the service manually below
+        context.getManagementStrategy().getManagementAgent().setRegisterAlways(true);
+
+        MyNonService service = new MyNonService();
+        for (LifecycleStrategy strategy : context.getLifecycleStrategies()) {
+            strategy.onServiceAdd(context, service, null);
+        }
+
+        MBeanServer mbeanServer = getMBeanServer();
+
+        Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=services,*"),
null);
+        assertEquals(8, set.size());
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    .to("mock:result");
+            }
+        };
+    }
+
+    private final class MyService extends ServiceSupport {
+
+        @Override
+        protected void doStart() throws Exception {
+            // noop
+        }
+
+        @Override
+        protected void doStop() throws Exception {
+            // noop
+        }
+    }
+
+    private final class MyNonService extends ServiceSupport implements NonManagedService
{
+
+        @Override
+        protected void doStart() throws Exception {
+            // noop
+        }
+
+        @Override
+        protected void doStop() throws Exception {
+            // noop
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/43a747de/components/camel-quartz/src/main/java/org/apache/camel/routepolicy/quartz/ScheduledRoutePolicy.java
----------------------------------------------------------------------
diff --git a/components/camel-quartz/src/main/java/org/apache/camel/routepolicy/quartz/ScheduledRoutePolicy.java
b/components/camel-quartz/src/main/java/org/apache/camel/routepolicy/quartz/ScheduledRoutePolicy.java
index 9963d93..64aeaf2 100644
--- a/components/camel-quartz/src/main/java/org/apache/camel/routepolicy/quartz/ScheduledRoutePolicy.java
+++ b/components/camel-quartz/src/main/java/org/apache/camel/routepolicy/quartz/ScheduledRoutePolicy.java
@@ -20,6 +20,7 @@ import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.camel.NonManagedService;
 import org.apache.camel.Route;
 import org.apache.camel.ServiceStatus;
 import org.apache.camel.component.quartz.QuartzComponent;
@@ -33,7 +34,7 @@ import org.quartz.Trigger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public abstract class ScheduledRoutePolicy extends RoutePolicySupport implements ScheduledRoutePolicyConstants
{
+public abstract class ScheduledRoutePolicy extends RoutePolicySupport implements ScheduledRoutePolicyConstants,
NonManagedService {
     private static final Logger LOG = LoggerFactory.getLogger(ScheduledRoutePolicy.class);
     protected Map<String, ScheduledRouteDetails> scheduledRouteDetailsMap = new LinkedHashMap<String,
ScheduledRouteDetails>();
     private Scheduler scheduler;

http://git-wip-us.apache.org/repos/asf/camel/blob/43a747de/components/camel-quartz2/src/main/java/org/apache/camel/pollconsumer/quartz2/QuartzScheduledPollConsumerScheduler.java
----------------------------------------------------------------------
diff --git a/components/camel-quartz2/src/main/java/org/apache/camel/pollconsumer/quartz2/QuartzScheduledPollConsumerScheduler.java
b/components/camel-quartz2/src/main/java/org/apache/camel/pollconsumer/quartz2/QuartzScheduledPollConsumerScheduler.java
index 6ddf670..51c17dc 100644
--- a/components/camel-quartz2/src/main/java/org/apache/camel/pollconsumer/quartz2/QuartzScheduledPollConsumerScheduler.java
+++ b/components/camel-quartz2/src/main/java/org/apache/camel/pollconsumer/quartz2/QuartzScheduledPollConsumerScheduler.java
@@ -20,6 +20,7 @@ import java.util.TimeZone;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Consumer;
+import org.apache.camel.NonManagedService;
 import org.apache.camel.Route;
 import org.apache.camel.component.quartz2.QuartzComponent;
 import org.apache.camel.component.quartz2.QuartzConstants;
@@ -42,7 +43,7 @@ import org.slf4j.LoggerFactory;
  * A quartz based {@link ScheduledPollConsumerScheduler} which uses a {@link CronTrigger}
to define when the
  * poll should be triggered.
  */
-public class QuartzScheduledPollConsumerScheduler extends ServiceSupport implements ScheduledPollConsumerScheduler
{
+public class QuartzScheduledPollConsumerScheduler extends ServiceSupport implements ScheduledPollConsumerScheduler,
NonManagedService {
 
     private static final Logger LOG = LoggerFactory.getLogger(QuartzScheduledPollConsumerScheduler.class);
     private Scheduler quartzScheduler;

http://git-wip-us.apache.org/repos/asf/camel/blob/43a747de/components/camel-quartz2/src/main/java/org/apache/camel/routepolicy/quartz2/ScheduledRoutePolicy.java
----------------------------------------------------------------------
diff --git a/components/camel-quartz2/src/main/java/org/apache/camel/routepolicy/quartz2/ScheduledRoutePolicy.java
b/components/camel-quartz2/src/main/java/org/apache/camel/routepolicy/quartz2/ScheduledRoutePolicy.java
index 84a9d6f..3f6639c 100644
--- a/components/camel-quartz2/src/main/java/org/apache/camel/routepolicy/quartz2/ScheduledRoutePolicy.java
+++ b/components/camel-quartz2/src/main/java/org/apache/camel/routepolicy/quartz2/ScheduledRoutePolicy.java
@@ -20,6 +20,7 @@ import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.camel.NonManagedService;
 import org.apache.camel.Route;
 import org.apache.camel.ServiceStatus;
 import org.apache.camel.component.quartz2.QuartzComponent;
@@ -47,7 +48,7 @@ import org.slf4j.LoggerFactory;
  * See org.apache.camel.component.quartz2.QuartzComponent
  *
  */
-public abstract class ScheduledRoutePolicy extends RoutePolicySupport implements ScheduledRoutePolicyConstants
{
+public abstract class ScheduledRoutePolicy extends RoutePolicySupport implements ScheduledRoutePolicyConstants,
NonManagedService {
     private static final Logger LOG = LoggerFactory.getLogger(ScheduledRoutePolicy.class);
     protected Map<String, ScheduledRouteDetails> scheduledRouteDetailsMap = new LinkedHashMap<String,
ScheduledRouteDetails>();
     private Scheduler scheduler;

http://git-wip-us.apache.org/repos/asf/camel/blob/43a747de/components/camel-spring/src/main/java/org/apache/camel/spring/pollingconsumer/SpringScheduledPollConsumerScheduler.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/main/java/org/apache/camel/spring/pollingconsumer/SpringScheduledPollConsumerScheduler.java
b/components/camel-spring/src/main/java/org/apache/camel/spring/pollingconsumer/SpringScheduledPollConsumerScheduler.java
index 7175930..992180f 100644
--- a/components/camel-spring/src/main/java/org/apache/camel/spring/pollingconsumer/SpringScheduledPollConsumerScheduler.java
+++ b/components/camel-spring/src/main/java/org/apache/camel/spring/pollingconsumer/SpringScheduledPollConsumerScheduler.java
@@ -21,6 +21,7 @@ import java.util.concurrent.ScheduledFuture;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Consumer;
+import org.apache.camel.NonManagedService;
 import org.apache.camel.spi.ScheduledPollConsumerScheduler;
 import org.apache.camel.spring.util.CamelThreadPoolTaskScheduler;
 import org.apache.camel.support.ServiceSupport;
@@ -34,7 +35,7 @@ import org.springframework.scheduling.support.CronTrigger;
  * A Spring based {@link ScheduledPollConsumerScheduler} which uses a {@link CronTrigger}
to define when the
  * poll should be triggered.
  */
-public class SpringScheduledPollConsumerScheduler extends ServiceSupport implements ScheduledPollConsumerScheduler
{
+public class SpringScheduledPollConsumerScheduler extends ServiceSupport implements ScheduledPollConsumerScheduler,
NonManagedService {
 
     private static final Logger LOG = LoggerFactory.getLogger(SpringScheduledPollConsumerScheduler.class);
     private CamelContext camelContext;

http://git-wip-us.apache.org/repos/asf/camel/blob/43a747de/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/policy/ZooKeeperRoutePolicy.java
----------------------------------------------------------------------
diff --git a/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/policy/ZooKeeperRoutePolicy.java
b/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/policy/ZooKeeperRoutePolicy.java
index d059101..11faea4 100644
--- a/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/policy/ZooKeeperRoutePolicy.java
+++ b/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/policy/ZooKeeperRoutePolicy.java
@@ -23,6 +23,7 @@ import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 
 import org.apache.camel.Exchange;
+import org.apache.camel.NonManagedService;
 import org.apache.camel.Route;
 import org.apache.camel.support.RoutePolicySupport;
 
@@ -48,7 +49,7 @@ import org.apache.camel.support.RoutePolicySupport;
  * See <a href="http://hadoop.apache.org/zookeeper/docs/current/recipes.html#sc_leaderElection">
  *     for more on how Leader election</a> is archived with ZooKeeper.
  */
-public class ZooKeeperRoutePolicy extends RoutePolicySupport implements ElectionWatcher {
+public class ZooKeeperRoutePolicy extends RoutePolicySupport implements ElectionWatcher,
NonManagedService {
 
     private final String uri;
     private final int enabledCount;


Mime
View raw message