camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r812099 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/ camel-core/src/main/java/org/apache/camel/management/ camel-core/src/main/java/org/apache/camel/management/mbean/ camel-core/src/main/java/org/apache/camel/spi/ camel-cor...
Date Mon, 07 Sep 2009 12:04:42 GMT
Author: davsclaus
Date: Mon Sep  7 12:04:41 2009
New Revision: 812099

URL: http://svn.apache.org/viewvc?rev=812099&view=rev
Log:
CAMEL-1992: Added mangement statistics level option to preset stats enabled when starting.
All, RoutesOnly and Off.

Added:
    camel/trunk/camel-core/src/main/java/org/apache/camel/ManagementStatisticsLevel.java 
 (with props)
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedStatisticsLevelOffTest.java
  (contents, props changed)
      - copied, changed from r812052, camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedStatisticsDisabledTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedStatisticsLevelRoutesOnlyTest.java
  (with props)
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/
      - copied from r812050, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/managment/
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedStatisticsLevelOffTest.java
  (with props)
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedStatisticsLevelRoutesOnlyTest.java
  (with props)
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/ManagedStatisticsLevelRoutesOnlyTest.xml
  (with props)
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/SpringManagedStatisticsLevelOffTest.xml
      - copied, changed from r812050, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/disableJmxConfig.xml
Removed:
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/managment/
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementLifecycleStrategy.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementStrategy.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedProcessor.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ManagementStrategy.java
    camel/trunk/camel-core/src/main/resources/org/apache/camel/jaxb.index
    camel/trunk/components/camel-spring/pom.xml
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelJMXAgentDefinition.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/JmxInstrumentationWithConnectorTest.java

Added: camel/trunk/camel-core/src/main/java/org/apache/camel/ManagementStatisticsLevel.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/ManagementStatisticsLevel.java?rev=812099&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/ManagementStatisticsLevel.java (added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/ManagementStatisticsLevel.java Mon
Sep  7 12:04:41 2009
@@ -0,0 +1,31 @@
+/**
+ * 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;
+
+import javax.xml.bind.annotation.XmlEnum;
+
+/**
+ * Level of granularity for performance statistics enabled
+ *
+ * @version $Revision$
+ */
+@XmlEnum
+public enum ManagementStatisticsLevel {
+
+    All, RoutesOnly, Off
+
+}

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/ManagementStatisticsLevel.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/ManagementStatisticsLevel.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

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=812099&r1=812098&r2=812099&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 Sep  7 12:04:41 2009
@@ -60,6 +60,7 @@
 import org.apache.camel.spi.BrowsableEndpoint;
 import org.apache.camel.spi.LifecycleStrategy;
 import org.apache.camel.spi.ManagementAware;
+import org.apache.camel.ManagementStatisticsLevel;
 import org.apache.camel.spi.ManagementStrategy;
 import org.apache.camel.spi.RouteContext;
 import org.apache.camel.util.KeyValueHolder;
@@ -413,6 +414,9 @@
         // okay this is a processor we would like to manage so create the
         // performance counter that is the base for processors
         ManagedPerformanceCounter pc = new ManagedPerformanceCounter(getStrategy());
+        // set statistics enabled depending on the option
+        boolean enabled = context.getManagementStrategy().getStatisticsLevel() == ManagementStatisticsLevel.All;
+        pc.setStatisticsEnabled(enabled);
 
         // and add it as a a registered counter that will be used lazy when Camel
         // does the instrumentation of the route and adds the InstrumentationProcessor

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementStrategy.java?rev=812099&r1=812098&r2=812099&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementStrategy.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementStrategy.java
Mon Sep  7 12:04:41 2009
@@ -23,6 +23,7 @@
 import org.apache.camel.spi.EventNotifier;
 import org.apache.camel.spi.ManagementAgent;
 import org.apache.camel.spi.ManagementNamingStrategy;
+import org.apache.camel.ManagementStatisticsLevel;
 import org.apache.camel.spi.ManagementStrategy;
 import org.fusesource.commons.management.Statistic;
 
@@ -46,6 +47,7 @@
     private ManagementNamingStrategy managementNamingStrategy;
     private boolean onlyManageProcessorWithCustomId;
     private ManagementAgent managementAgent;
+    private ManagementStatisticsLevel statisticsLevel = ManagementStatisticsLevel.All;
 
     public EventNotifier getEventNotifier() {
         return eventNotifier;
@@ -131,6 +133,14 @@
         return null;
     }
 
+    public void setSatisticsLevel(ManagementStatisticsLevel level) {
+        this.statisticsLevel = level;
+    }
+
+    public ManagementStatisticsLevel getStatisticsLevel() {
+        return statisticsLevel;
+    }
+
     public void start() throws Exception {
         if (managementAgent != null) {
             managementAgent.start();

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedProcessor.java?rev=812099&r1=812098&r2=812099&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedProcessor.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedProcessor.java
Mon Sep  7 12:04:41 2009
@@ -22,6 +22,7 @@
 import org.apache.camel.ServiceStatus;
 import org.apache.camel.impl.ServiceSupport;
 import org.apache.camel.model.ProcessorDefinition;
+import org.apache.camel.ManagementStatisticsLevel;
 import org.springframework.jmx.export.annotation.ManagedAttribute;
 import org.springframework.jmx.export.annotation.ManagedResource;
 
@@ -43,6 +44,9 @@
         this.processor = processor;
         this.definition = definition;
         this.id = definition.idOrCreate(context.getNodeIdFactory());
+
+        boolean enabled = context.getManagementStrategy().getStatisticsLevel() == ManagementStatisticsLevel.All;
+        setStatisticsEnabled(enabled);
     }
 
     public CamelContext getContext() {

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java?rev=812099&r1=812098&r2=812099&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java
Mon Sep  7 12:04:41 2009
@@ -20,6 +20,7 @@
 import org.apache.camel.Endpoint;
 import org.apache.camel.Route;
 import org.apache.camel.ServiceStatus;
+import org.apache.camel.ManagementStatisticsLevel;
 import org.apache.camel.spi.ManagementStrategy;
 import org.springframework.jmx.export.annotation.ManagedAttribute;
 import org.springframework.jmx.export.annotation.ManagedOperation;
@@ -38,6 +39,8 @@
         this.route = route;
         this.context = context;
         this.description = route.toString();
+        boolean enabled = context.getManagementStrategy().getStatisticsLevel() != ManagementStatisticsLevel.Off;
+        setStatisticsEnabled(enabled);
     }
 
     public Route getRoute() {

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ManagementStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ManagementStrategy.java?rev=812099&r1=812098&r2=812099&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ManagementStrategy.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ManagementStrategy.java Mon
Sep  7 12:04:41 2009
@@ -17,6 +17,7 @@
 package org.apache.camel.spi;
 
 import org.apache.camel.Service;
+import org.apache.camel.ManagementStatisticsLevel;
 import org.apache.camel.model.ProcessorDefinition;
 
 /**
@@ -114,4 +115,20 @@
      */
     boolean isOnlyManageProcessorWithCustomId();
 
+    /**
+     * Sets the statistics level
+     * <p/>
+     * Default is {@link org.apache.camel.ManagementStatisticsLevel#All}
+     *
+     * @param level the new level
+     */
+    void setSatisticsLevel(ManagementStatisticsLevel level);
+
+    /**
+     * Gets the statistics level
+     *
+     * @return the level
+     */
+    ManagementStatisticsLevel getStatisticsLevel();
+
 }

Modified: camel/trunk/camel-core/src/main/resources/org/apache/camel/jaxb.index
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/resources/org/apache/camel/jaxb.index?rev=812099&r1=812098&r2=812099&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/resources/org/apache/camel/jaxb.index (original)
+++ camel/trunk/camel-core/src/main/resources/org/apache/camel/jaxb.index Mon Sep  7 12:04:41
2009
@@ -15,4 +15,5 @@
 ## limitations under the License.
 ## ------------------------------------------------------------------------
 ExchangePattern
-LoggingLevel
\ No newline at end of file
+LoggingLevel
+ManagementStatisticsLevel
\ No newline at end of file

Copied: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedStatisticsLevelOffTest.java
(from r812052, camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedStatisticsDisabledTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedStatisticsLevelOffTest.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedStatisticsLevelOffTest.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedStatisticsDisabledTest.java&r1=812052&r2=812099&rev=812099&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedStatisticsDisabledTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedStatisticsLevelOffTest.java
Mon Sep  7 12:04:41 2009
@@ -24,11 +24,12 @@
 import org.apache.camel.CamelContext;
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.ManagementStatisticsLevel;
 
 /**
  * @version $Revision$
  */
-public class ManagedStatisticsDisabledTest extends ContextTestSupport {
+public class ManagedStatisticsLevelOffTest extends ContextTestSupport {
 
     @Override
     protected CamelContext createCamelContext() throws Exception {
@@ -36,11 +37,14 @@
         DefaultManagementNamingStrategy naming = (DefaultManagementNamingStrategy) context.getManagementStrategy().getManagementNamingStrategy();
         naming.setHostName("localhost");
         naming.setDomainName("org.apache.camel");
+
+        // disable it by default
+        context.getManagementStrategy().setSatisticsLevel(ManagementStatisticsLevel.Off);
         return context;
     }
 
     @SuppressWarnings("unchecked")
-    public void testManageStatisticsDisabled() throws Exception {
+    public void testManageStatisticsLevelDisabled() throws Exception {
         template.sendBody("direct:start", "Hello World");
         template.sendBody("direct:start", "Bye World");
 
@@ -54,35 +58,15 @@
 
         // use route to get the total time
         Long completed = (Long) mbeanServer.getAttribute(on, "ExchangesCompleted");
-        assertEquals(2, completed.longValue());
-        
-        // disable statistics
-        mbeanServer.setAttribute(on, new Attribute("StatisticsEnabled", false));
-
-        // send in another message
-        template.sendBody("direct:start", "Goodday World");
-
-        // should stay at 2
-        completed = (Long) mbeanServer.getAttribute(on, "ExchangesCompleted");
-        assertEquals(2, completed.longValue());
+        assertEquals(0, completed.longValue());
 
-        // enable statistics
+        // disable statistics
         mbeanServer.setAttribute(on, new Attribute("StatisticsEnabled", true));
 
         // send in another message
-        template.sendBody("direct:start", "Hi World");
-
-        // should now be 3
-        completed = (Long) mbeanServer.getAttribute(on, "ExchangesCompleted");
-        assertEquals(3, completed.longValue());
-
-        // now reset it
-        mbeanServer.invoke(on, "reset", null, null);
-
-        // send in another message
-        template.sendBody("direct:start", "Hallo World");
+        template.sendBody("direct:start", "Goodday World");
 
-        // should now be 1
+        // should be 1
         completed = (Long) mbeanServer.getAttribute(on, "ExchangesCompleted");
         assertEquals(1, completed.longValue());
     }

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedStatisticsLevelOffTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedStatisticsLevelOffTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedStatisticsLevelRoutesOnlyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedStatisticsLevelRoutesOnlyTest.java?rev=812099&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedStatisticsLevelRoutesOnlyTest.java
(added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedStatisticsLevelRoutesOnlyTest.java
Mon Sep  7 12:04:41 2009
@@ -0,0 +1,92 @@
+/**
+ * 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.CamelContext;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.ManagementStatisticsLevel;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class ManagedStatisticsLevelRoutesOnlyTest extends ContextTestSupport {
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = super.createCamelContext();
+        DefaultManagementNamingStrategy naming = (DefaultManagementNamingStrategy) context.getManagementStrategy().getManagementNamingStrategy();
+        naming.setHostName("localhost");
+        naming.setDomainName("org.apache.camel");
+
+        // only routes
+        context.getManagementStrategy().setSatisticsLevel(ManagementStatisticsLevel.RoutesOnly);
+        return context;
+    }
+
+    @SuppressWarnings("unchecked")
+    public void testManageStatisticsRoutesOnly() throws Exception {
+        template.sendBody("direct:start", "Hello World");
+        template.sendBody("direct:start", "Bye World");
+
+        // get the stats for the route
+        MBeanServer mbeanServer = context.getManagementStrategy().getManagementAgent().getMBeanServer();
+
+        Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=routes,*"),
null);
+        assertEquals(1, set.size());
+
+        ObjectName on = set.iterator().next();
+
+        set = mbeanServer.queryNames(new ObjectName("*:type=processors,*"), null);
+        assertEquals(1, set.size());
+
+        ObjectName on2 = set.iterator().next();
+
+        // route should have stats enabled
+        Long completed = (Long) mbeanServer.getAttribute(on, "ExchangesCompleted");
+        assertEquals(2, completed.longValue());
+
+        // but not processor
+        Long completed2 = (Long) mbeanServer.getAttribute(on2, "ExchangesCompleted");
+        assertEquals(0, completed2.longValue());
+
+        // send in another message
+        template.sendBody("direct:start", "Goodday World");
+
+        // should be 3
+        completed = (Long) mbeanServer.getAttribute(on, "ExchangesCompleted");
+        assertEquals(3, completed.longValue());
+
+        completed2 = (Long) mbeanServer.getAttribute(on2, "ExchangesCompleted");
+        assertEquals(0, completed2.longValue());
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to("mock:result");
+            }
+        };
+    }
+
+}
\ No newline at end of file

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedStatisticsLevelRoutesOnlyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedStatisticsLevelRoutesOnlyTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/components/camel-spring/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/pom.xml?rev=812099&r1=812098&r2=812099&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/pom.xml (original)
+++ camel/trunk/components/camel-spring/pom.xml Mon Sep  7 12:04:41 2009
@@ -192,6 +192,8 @@
                   <fileset dir="${basedir}/../../camel-core/src/main/java">
                     <include name="org/apache/camel/model/**/*.java" />
                     <include name="org/apache/camel/ExchangePattern.java" />
+                    <include name="org/apache/camel/LoggingLevel.java" />
+                    <include name="org/apache/camel/ManagementStatisticsLevel.java" />
                     <include name="org/apache/camel/package-info.java" />
                   </fileset>
                 </copy>

Modified: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java?rev=812099&r1=812098&r2=812099&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
(original)
+++ camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
Mon Sep  7 12:04:41 2009
@@ -456,10 +456,13 @@
 
             ManagementStrategy managementStrategy = new ManagedManagementStrategy(agent);
             getContext().setManagementStrategy(managementStrategy);
+
             // clear the existing lifecycle strategies define by the DefaultCamelContext
constructor
             getContext().getLifecycleStrategies().clear();
             getContext().addLifecycleStrategy(new DefaultManagementLifecycleStrategy(getContext()));
+            // set additional configuration from camelJMXAgent
             getContext().getManagementStrategy().onlyManageProcessorWithCustomId(camelJMXAgent.getOnlyRegisterProcessorWithCustomId());
+            getContext().getManagementStrategy().setSatisticsLevel(camelJMXAgent.getStatisticsLevel());
         }
     }
 

Modified: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelJMXAgentDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelJMXAgentDefinition.java?rev=812099&r1=812098&r2=812099&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelJMXAgentDefinition.java
(original)
+++ camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelJMXAgentDefinition.java
Mon Sep  7 12:04:41 2009
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.spring;
 
 import javax.xml.bind.annotation.XmlAccessType;
@@ -22,6 +21,7 @@
 import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlRootElement;
 
+import org.apache.camel.ManagementStatisticsLevel;
 import org.apache.camel.model.IdentifiedType;
 
 /**
@@ -87,6 +87,12 @@
     @XmlAttribute(required = false)
     private Boolean usePlatformMBeanServer = Boolean.TRUE;
 
+    /**
+     * Level of granularity for performance statistics enabled
+     */
+    @XmlAttribute(required = false)
+    private ManagementStatisticsLevel statisticsLevel = ManagementStatisticsLevel.All;
+
     public Integer getConnectorPort() {
         return connectorPort;
     }
@@ -159,6 +165,14 @@
         disabled = value != null ? value : Boolean.FALSE;
     }
 
+    public ManagementStatisticsLevel getStatisticsLevel() {
+        return statisticsLevel;
+    }
+
+    public void setStatisticsLevel(ManagementStatisticsLevel statisticsLevel) {
+        this.statisticsLevel = statisticsLevel;
+    }
+
     @Override
     public String toString() {
         StringBuilder sb = new StringBuilder();
@@ -182,6 +196,9 @@
         if (mbeanObjectDomainName != null) {
             sb.append(", mbeanObjectDomainName=").append(mbeanObjectDomainName);
         }
+        if (statisticsLevel != null) {
+            sb.append(", statisticsLevel=").append(statisticsLevel);
+        }
         sb.append("]");
         return sb.toString();
     }

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/JmxInstrumentationWithConnectorTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/JmxInstrumentationWithConnectorTest.java?rev=812099&r1=812050&r2=812099&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/JmxInstrumentationWithConnectorTest.java
(original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/JmxInstrumentationWithConnectorTest.java
Mon Sep  7 12:04:41 2009
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.spring.managment;
+package org.apache.camel.spring.management;
 
 import org.apache.camel.management.DefaultManagementAgent;
 import org.apache.camel.spi.ManagementAgent;

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedStatisticsLevelOffTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedStatisticsLevelOffTest.java?rev=812099&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedStatisticsLevelOffTest.java
(added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedStatisticsLevelOffTest.java
Mon Sep  7 12:04:41 2009
@@ -0,0 +1,32 @@
+/**
+ * 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.spring.management;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.management.ManagedStatisticsLevelOffTest;
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+/**
+ * @version $Revision$
+ */
+public class SpringManagedStatisticsLevelOffTest extends ManagedStatisticsLevelOffTest {
+
+    protected CamelContext createCamelContext() throws Exception {
+        return createSpringCamelContext(this, "org/apache/camel/spring/management/SpringManagedStatisticsLevelOffTest.xml");
+    }
+
+}

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedStatisticsLevelOffTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedStatisticsLevelOffTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedStatisticsLevelRoutesOnlyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedStatisticsLevelRoutesOnlyTest.java?rev=812099&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedStatisticsLevelRoutesOnlyTest.java
(added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedStatisticsLevelRoutesOnlyTest.java
Mon Sep  7 12:04:41 2009
@@ -0,0 +1,32 @@
+/**
+ * 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.spring.management;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.management.ManagedStatisticsLevelRoutesOnlyTest;
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+/**
+ * @version $Revision$
+ */
+public class SpringManagedStatisticsLevelRoutesOnlyTest extends ManagedStatisticsLevelRoutesOnlyTest
{
+
+    protected CamelContext createCamelContext() throws Exception {
+        return createSpringCamelContext(this, "org/apache/camel/spring/management/ManagedStatisticsLevelRoutesOnlyTest.xml");
+    }
+
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedStatisticsLevelRoutesOnlyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedStatisticsLevelRoutesOnlyTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/ManagedStatisticsLevelRoutesOnlyTest.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/ManagedStatisticsLevelRoutesOnlyTest.xml?rev=812099&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/ManagedStatisticsLevelRoutesOnlyTest.xml
(added)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/ManagedStatisticsLevelRoutesOnlyTest.xml
Mon Sep  7 12:04:41 2009
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+    <!-- START SNIPPET: example -->
+    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+        <jmxAgent id="agent" statisticsLevel="RoutesOnly"/>
+
+        <route>
+            <from uri="direct:start"/>
+            <to uri="mock:result"/>
+        </route>
+    </camelContext>
+    <!-- END SNIPPET: example -->
+
+</beans>

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/ManagedStatisticsLevelRoutesOnlyTest.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/ManagedStatisticsLevelRoutesOnlyTest.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/ManagedStatisticsLevelRoutesOnlyTest.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Copied: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/SpringManagedStatisticsLevelOffTest.xml
(from r812050, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/disableJmxConfig.xml)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/SpringManagedStatisticsLevelOffTest.xml?p2=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/SpringManagedStatisticsLevelOffTest.xml&p1=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/disableJmxConfig.xml&r1=812050&r2=812099&rev=812099&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/disableJmxConfig.xml
(original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/management/SpringManagedStatisticsLevelOffTest.xml
Mon Sep  7 12:04:41 2009
@@ -22,15 +22,15 @@
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
     ">
 
-  <!-- START SNIPPET: example -->
-  <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
-    <jmxAgent id="agent" disabled="true"/> 
-      
-    <route>
-      <from uri="seda:start"/>
-      <to uri="mock:result"/>
-    </route>
-  </camelContext>
-  <!-- END SNIPPET: example -->
+    <!-- START SNIPPET: example -->
+    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+        <jmxAgent id="agent" statisticsLevel="Off"/>
+
+        <route>
+            <from uri="direct:start"/>
+            <to uri="mock:result"/>
+        </route>
+    </camelContext>
+    <!-- END SNIPPET: example -->
 
 </beans>



Mime
View raw message