camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/3] camel git commit: CAMEL-9014: Lets keep track of usage of all incoming and outgoing endpoints by default.
Date Tue, 28 Jul 2015 13:26:06 GMT
Repository: camel
Updated Branches:
  refs/heads/master 0046232ae -> 61887fa20


CAMEL-9014: Lets keep track of usage of all incoming and outgoing endpoints by default.


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

Branch: refs/heads/master
Commit: 92b017cd04bad06fde6a4ed0755f0e26e3d877aa
Parents: 0046232
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Tue Jul 28 10:53:29 2015 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Tue Jul 28 10:53:29 2015 +0200

----------------------------------------------------------------------
 .../camel/impl/DefaultRuntimeEndpointRegistry.java | 10 ++++++++--
 .../camel/management/DefaultManagementAgent.java   | 13 +++++++++++++
 .../camel/management/JmxSystemPropertyKeys.java    |  3 +++
 .../java/org/apache/camel/spi/ManagementAgent.java | 16 ++++++++++++++++
 .../core/xml/AbstractCamelContextFactoryBean.java  |  5 ++++-
 .../camel/core/xml/CamelJMXAgentDefinition.java    | 17 +++++++++++++++++
 6 files changed, 61 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/92b017cd/camel-core/src/main/java/org/apache/camel/impl/DefaultRuntimeEndpointRegistry.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultRuntimeEndpointRegistry.java
b/camel-core/src/main/java/org/apache/camel/impl/DefaultRuntimeEndpointRegistry.java
index 17aef16..7b01c89 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultRuntimeEndpointRegistry.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultRuntimeEndpointRegistry.java
@@ -51,7 +51,7 @@ public class DefaultRuntimeEndpointRegistry extends EventNotifierSupport
impleme
     private Map<String, Map<String, String>> outputs;
     private int limit = 1000;
     private boolean enabled = true;
-    private boolean extended;
+    private volatile boolean extended;
     private EndpointUtilizationStatistics inputUtilization;
     private EndpointUtilizationStatistics outputUtilization;
 
@@ -190,12 +190,18 @@ public class DefaultRuntimeEndpointRegistry extends EventNotifierSupport
impleme
             outputs = new HashMap<String, Map<String, String>>();
         }
         if (getCamelContext().getManagementStrategy().getManagementAgent() != null) {
-            extended = getCamelContext().getManagementStrategy().getManagementAgent().getStatisticsLevel().isExtended();
+            Boolean isEnabled = getCamelContext().getManagementStrategy().getManagementAgent().getEndpointRuntimeStatisticsEnabled();
+            boolean isExtended = getCamelContext().getManagementStrategy().getManagementAgent().getStatisticsLevel().isExtended();
+            // extended mode is either if we use Extended statistics level or the option
is explicit enabled
+            extended = isExtended || isEnabled != null && isEnabled;
         }
         if (extended) {
             inputUtilization = new DefaultEndpointUtilizationStatistics(limit);
             outputUtilization = new DefaultEndpointUtilizationStatistics(limit);
         }
+        if (extended) {
+            log.info("Runtime endpoint registry is in extended mode gathering usage statistics
of all incoming and outgoing endpoints (cache limit: {})", limit);
+        }
         ServiceHelper.startServices(inputUtilization, outputUtilization);
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/92b017cd/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java
b/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java
index f6c76a6..a65fffc 100644
--- a/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java
+++ b/camel-core/src/main/java/org/apache/camel/management/DefaultManagementAgent.java
@@ -79,6 +79,7 @@ public class DefaultManagementAgent extends ServiceSupport implements Management
     private Boolean createConnector = false;
     private Boolean onlyRegisterProcessorWithCustomId = false;
     private Boolean loadStatisticsEnabled = false;
+    private Boolean endpointRuntimeStatisticsEnabled = true;
     private Boolean registerAlways = false;
     private Boolean registerNewRoutes = true;
     private Boolean mask = true;
@@ -153,6 +154,10 @@ public class DefaultManagementAgent extends ServiceSupport implements
Management
             loadStatisticsEnabled = Boolean.getBoolean(JmxSystemPropertyKeys.LOAD_STATISTICS_ENABLED);
             values.put(JmxSystemPropertyKeys.LOAD_STATISTICS_ENABLED, loadStatisticsEnabled);
         }
+        if (System.getProperty(JmxSystemPropertyKeys.ENDPOINT_RUNTIME_STATISTICS_ENABLED)
!= null) {
+            endpointRuntimeStatisticsEnabled = Boolean.getBoolean(JmxSystemPropertyKeys.ENDPOINT_RUNTIME_STATISTICS_ENABLED);
+            values.put(JmxSystemPropertyKeys.ENDPOINT_RUNTIME_STATISTICS_ENABLED, endpointRuntimeStatisticsEnabled);
+        }
         if (System.getProperty(JmxSystemPropertyKeys.STATISTICS_LEVEL) != null) {
             statisticsLevel = camelContext.getTypeConverter().mandatoryConvertTo(ManagementStatisticsLevel.class,
System.getProperty(JmxSystemPropertyKeys.STATISTICS_LEVEL));
             values.put(JmxSystemPropertyKeys.STATISTICS_LEVEL, statisticsLevel);
@@ -287,6 +292,14 @@ public class DefaultManagementAgent extends ServiceSupport implements
Management
         this.loadStatisticsEnabled = loadStatisticsEnabled;
     }
 
+    public Boolean getEndpointRuntimeStatisticsEnabled() {
+        return endpointRuntimeStatisticsEnabled;
+    }
+
+    public void setEndpointRuntimeStatisticsEnabled(Boolean endpointRuntimeStatisticsEnabled)
{
+        this.endpointRuntimeStatisticsEnabled = endpointRuntimeStatisticsEnabled;
+    }
+
     public ManagementStatisticsLevel getStatisticsLevel() {
         return statisticsLevel;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/92b017cd/camel-core/src/main/java/org/apache/camel/management/JmxSystemPropertyKeys.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/management/JmxSystemPropertyKeys.java
b/camel-core/src/main/java/org/apache/camel/management/JmxSystemPropertyKeys.java
index fdde84c..5684e5d 100644
--- a/camel-core/src/main/java/org/apache/camel/management/JmxSystemPropertyKeys.java
+++ b/camel-core/src/main/java/org/apache/camel/management/JmxSystemPropertyKeys.java
@@ -53,6 +53,9 @@ public final class JmxSystemPropertyKeys {
     // whether to enable gathering load statistics in the background
     public static final String LOAD_STATISTICS_ENABLED = "org.apache.camel.jmx.loadStatisticsEnabled";
 
+    // whether to enable gathering endpoint runtime statistics
+    public static final String ENDPOINT_RUNTIME_STATISTICS_ENABLED = "org.apache.camel.jmx.endpointRuntimeStatisticsEnabled";
+
     // the level of statistics enabled
     public static final String STATISTICS_LEVEL = "org.apache.camel.jmx.statisticsLevel";
 

http://git-wip-us.apache.org/repos/asf/camel/blob/92b017cd/camel-core/src/main/java/org/apache/camel/spi/ManagementAgent.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/spi/ManagementAgent.java b/camel-core/src/main/java/org/apache/camel/spi/ManagementAgent.java
index ae552da..ac25bd2 100644
--- a/camel-core/src/main/java/org/apache/camel/spi/ManagementAgent.java
+++ b/camel-core/src/main/java/org/apache/camel/spi/ManagementAgent.java
@@ -319,6 +319,22 @@ public interface ManagementAgent extends Service {
     Boolean getLoadStatisticsEnabled();
 
     /**
+     * Sets whether endpoint runtime statistics is enabled (gathers runtime usage of each
incoming and outgoing endpoints).
+     * <p/>
+     * The default value is <tt>true</tt>
+     *
+     * @param flag <tt>false</tt> to disable endpoint runtime statistics
+     */
+    void setEndpointRuntimeStatisticsEnabled(Boolean flag);
+
+    /**
+     * Gets whether load statistics is enabled
+     *
+     * @return <tt>true</tt> if enabled
+     */
+    Boolean getEndpointRuntimeStatisticsEnabled();
+
+    /**
      * Sets the statistics level
      * <p/>
      * Default is {@link org.apache.camel.ManagementStatisticsLevel#Default}

http://git-wip-us.apache.org/repos/asf/camel/blob/92b017cd/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
----------------------------------------------------------------------
diff --git a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
index e48b74c..20e93a3 100644
--- a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
+++ b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
@@ -460,7 +460,10 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
                 agent.setMask(CamelContextHelper.parseBoolean(getContext(), camelJMXAgent.getMask()));
             }
             if (camelJMXAgent.getLoadStatisticsEnabled() != null) {
-                agent.setMask(CamelContextHelper.parseBoolean(getContext(), camelJMXAgent.getLoadStatisticsEnabled()));
+                agent.setLoadStatisticsEnabled(CamelContextHelper.parseBoolean(getContext(),
camelJMXAgent.getLoadStatisticsEnabled()));
+            }
+            if (camelJMXAgent.getEndpointRuntimeStatisticsEnabled() != null) {
+                agent.setEndpointRuntimeStatisticsEnabled(CamelContextHelper.parseBoolean(getContext(),
camelJMXAgent.getEndpointRuntimeStatisticsEnabled()));
             }
             if (camelJMXAgent.getStatisticsLevel() != null) {
                 String level = CamelContextHelper.parseText(getContext(), camelJMXAgent.getStatisticsLevel());

http://git-wip-us.apache.org/repos/asf/camel/blob/92b017cd/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelJMXAgentDefinition.java
----------------------------------------------------------------------
diff --git a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelJMXAgentDefinition.java
b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelJMXAgentDefinition.java
index 1a70fc9..b4ce31b 100644
--- a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelJMXAgentDefinition.java
+++ b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelJMXAgentDefinition.java
@@ -112,6 +112,12 @@ public class CamelJMXAgentDefinition extends IdentifiedType {
     private String loadStatisticsEnabled;
 
     /**
+     * A flag that indicates whether endpoint runtime statistics is enabled
+     */
+    @XmlAttribute
+    private String endpointRuntimeStatisticsEnabled;
+
+    /**
      * A flag that indicates whether to include hostname in JMX MBean names.
      */
     @XmlAttribute
@@ -227,6 +233,14 @@ public class CamelJMXAgentDefinition extends IdentifiedType {
         this.loadStatisticsEnabled = loadStatisticsEnabled;
     }
 
+    public String getEndpointRuntimeStatisticsEnabled() {
+        return endpointRuntimeStatisticsEnabled;
+    }
+
+    public void setEndpointRuntimeStatisticsEnabled(String endpointRuntimeStatisticsEnabled)
{
+        this.endpointRuntimeStatisticsEnabled = endpointRuntimeStatisticsEnabled;
+    }
+
     public String getIncludeHostName() {
         return includeHostName;
     }
@@ -279,6 +293,9 @@ public class CamelJMXAgentDefinition extends IdentifiedType {
         if (loadStatisticsEnabled != null) {
             csb.append("loadStatisticsEnabled=" + loadStatisticsEnabled);
         }
+        if (endpointRuntimeStatisticsEnabled != null) {
+            csb.append("endpointRuntimeStatisticsEnabled=" + endpointRuntimeStatisticsEnabled);
+        }
         if (onlyRegisterProcessorWithCustomId != null) {
             csb.append("onlyRegisterProcessorWithCustomId=" + onlyRegisterProcessorWithCustomId);
         }


Mime
View raw message