Repository: camel
Updated Branches:
  refs/heads/master 84eaba980 -> 54e7d3471


Add Ganglia component


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

Branch: refs/heads/master
Commit: 6605b826b2c25306b1ad96033dec32b63ee4d692
Parents: 84eaba9
Author: Daniel Pocock <[email protected]>
Authored: Tue Feb 10 21:45:11 2015 +0100
Committer: Claus Ibsen <[email protected]>
Committed: Fri Feb 20 09:07:11 2015 +0100

----------------------------------------------------------------------
 .../src/main/descriptors/common-bin.xml         |  1 +
 components/camel-ganglia/pom.xml                |  2 +-
 .../component/ganglia/GangliaConfiguration.java | 30 ++++++++-------
 .../component/ganglia/GangliaConstants.java     |  4 +-
 .../component/ganglia/GangliaEndpoint.java      |  1 -
 .../component/ganglia/GangliaProducer.java      | 12 +++++-
 parent/pom.xml                                  |  7 ++++
 .../features/src/main/resources/features.xml    |  8 +++-
 .../camel/itest/karaf/CamelGangliaTest.java     | 40 ++++++++++++++++++++
 9 files changed, 84 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/6605b826/apache-camel/src/main/descriptors/common-bin.xml
----------------------------------------------------------------------
diff --git a/apache-camel/src/main/descriptors/common-bin.xml 
b/apache-camel/src/main/descriptors/common-bin.xml
index c2dda52..85bd33c 100644
--- a/apache-camel/src/main/descriptors/common-bin.xml
+++ b/apache-camel/src/main/descriptors/common-bin.xml
@@ -73,6 +73,7 @@
         <include>org.apache.camel:camel-freemarker</include>
         <include>org.apache.camel:camel-ftp</include>
         <include>org.apache.camel:camel-gae</include>
+        <include>org.apache.camel:camel-ganglia</include>
         <include>org.apache.camel:camel-geocoder</include>
         <include>org.apache.camel:camel-github</include>
         <include>org.apache.camel:camel-google-calendar</include>

http://git-wip-us.apache.org/repos/asf/camel/blob/6605b826/components/camel-ganglia/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-ganglia/pom.xml b/components/camel-ganglia/pom.xml
index 92f7557..02a2ecc 100644
--- a/components/camel-ganglia/pom.xml
+++ b/components/camel-ganglia/pom.xml
@@ -46,7 +46,7 @@
     <dependency>
       <groupId>info.ganglia.gmetric4j</groupId>
       <artifactId>gmetric4j</artifactId>
-      <version>1.0.7</version>
+      <version>${gmetric4j-version}</version>
     </dependency>
 
     <!-- test dependencies -->

http://git-wip-us.apache.org/repos/asf/camel/blob/6605b826/components/camel-ganglia/src/main/java/org/apache/camel/component/ganglia/GangliaConfiguration.java
----------------------------------------------------------------------
diff --git 
a/components/camel-ganglia/src/main/java/org/apache/camel/component/ganglia/GangliaConfiguration.java
 
b/components/camel-ganglia/src/main/java/org/apache/camel/component/ganglia/GangliaConfiguration.java
index d82f920..abf531c 100644
--- 
a/components/camel-ganglia/src/main/java/org/apache/camel/component/ganglia/GangliaConfiguration.java
+++ 
b/components/camel-ganglia/src/main/java/org/apache/camel/component/ganglia/GangliaConfiguration.java
@@ -22,14 +22,13 @@ import java.net.URI;
 import info.ganglia.gmetric4j.gmetric.GMetric;
 import info.ganglia.gmetric4j.gmetric.GMetricSlope;
 import info.ganglia.gmetric4j.gmetric.GMetricType;
-
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriParams;
 import org.apache.camel.spi.UriPath;
 
 /**
- * @version 
+ * @version
  */
 @UriParams
 public class GangliaConfiguration implements Cloneable {
@@ -53,7 +52,7 @@ public class GangliaConfiguration implements Cloneable {
     @UriPath
     private int port = DEFAULT_PORT;
 
-    @UriParam
+    @UriParam(defaultValue = "MULTICAST")
     private GMetric.UDPAddressingMode mode = DEFAULT_MODE;
 
     @UriParam(defaultValue = "5")
@@ -65,22 +64,22 @@ public class GangliaConfiguration implements Cloneable {
     @UriParam
     private String spoofHostname;
 
-    @UriParam(defaultValue = "Java")
+    @UriParam(defaultValue = "java")
     private String groupName = DEFAULT_GROUP_NAME;
 
     @UriParam
-    private String prefix;
+    private String prefix = null;
 
     @UriParam(defaultValue = "metric")
     private String metricName = DEFAULT_METRIC_NAME;
 
-    @UriParam
+    @UriParam(defaultValue = "STRING")
     private GMetricType type = DEFAULT_TYPE;
 
-    @UriParam
+    @UriParam(defaultValue = "BOTH")
     private GMetricSlope slope = DEFAULT_SLOPE;
 
-    @UriParam(defaultValue = "")
+    @UriParam
     private String units = DEFAULT_UNITS;
 
     @UriParam(defaultValue = "60")
@@ -114,8 +113,7 @@ public class GangliaConfiguration implements Cloneable {
 
     public GMetric createGMetric() {
         try {
-            return new GMetric(host, port, mode, ttl, wireFormat31x,
-                null, spoofHostname);
+            return new GMetric(host, port, mode, ttl, wireFormat31x, null, 
spoofHostname);
         } catch (IOException ex) {
             throw new RuntimeCamelException("Failed to initialize Ganglia", 
ex);
         }
@@ -217,19 +215,23 @@ public class GangliaConfiguration implements Cloneable {
         this.units = units;
     }
 
-    public int getTMax() {
+    public boolean isWireFormat31x() {
+        return wireFormat31x;
+    }
+
+    public int getTmax() {
         return tmax;
     }
 
-    public void setTMax(int tmax) {
+    public void setTmax(int tmax) {
         this.tmax = tmax;
     }
 
-    public int getDMax() {
+    public int getDmax() {
         return dmax;
     }
 
-    public void setDMax(int dmax) {
+    public void setDmax(int dmax) {
         this.dmax = dmax;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/6605b826/components/camel-ganglia/src/main/java/org/apache/camel/component/ganglia/GangliaConstants.java
----------------------------------------------------------------------
diff --git 
a/components/camel-ganglia/src/main/java/org/apache/camel/component/ganglia/GangliaConstants.java
 
b/components/camel-ganglia/src/main/java/org/apache/camel/component/ganglia/GangliaConstants.java
index e5d71a2..12ca5d0 100644
--- 
a/components/camel-ganglia/src/main/java/org/apache/camel/component/ganglia/GangliaConstants.java
+++ 
b/components/camel-ganglia/src/main/java/org/apache/camel/component/ganglia/GangliaConstants.java
@@ -26,8 +26,8 @@ public final class GangliaConstants {
     public static final String METRIC_TYPE = "CamelGangliaMetricType";
     public static final String METRIC_SLOPE = "CamelGangliaMetricSlope";
     public static final String METRIC_UNITS = "CamelGangliaMetricUnits";
-    public static final String METRIC_TMAX = "CamelGangliaMetricTMax";
-    public static final String METRIC_DMAX = "CamelGangliaMetricDMax";
+    public static final String METRIC_TMAX = "CamelGangliaMetricTmax";
+    public static final String METRIC_DMAX = "CamelGangliaMetricDmax";
 
     private GangliaConstants() {
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/6605b826/components/camel-ganglia/src/main/java/org/apache/camel/component/ganglia/GangliaEndpoint.java
----------------------------------------------------------------------
diff --git 
a/components/camel-ganglia/src/main/java/org/apache/camel/component/ganglia/GangliaEndpoint.java
 
b/components/camel-ganglia/src/main/java/org/apache/camel/component/ganglia/GangliaEndpoint.java
index 199e115..3e15cd6 100644
--- 
a/components/camel-ganglia/src/main/java/org/apache/camel/component/ganglia/GangliaEndpoint.java
+++ 
b/components/camel-ganglia/src/main/java/org/apache/camel/component/ganglia/GangliaEndpoint.java
@@ -19,7 +19,6 @@ package org.apache.camel.component.ganglia;
 import info.ganglia.gmetric4j.Publisher;
 import info.ganglia.gmetric4j.gmetric.GMetric;
 import info.ganglia.gmetric4j.gmetric.GMetricPublisher;
-
 import org.apache.camel.Component;
 import org.apache.camel.Consumer;
 import org.apache.camel.Processor;

http://git-wip-us.apache.org/repos/asf/camel/blob/6605b826/components/camel-ganglia/src/main/java/org/apache/camel/component/ganglia/GangliaProducer.java
----------------------------------------------------------------------
diff --git 
a/components/camel-ganglia/src/main/java/org/apache/camel/component/ganglia/GangliaProducer.java
 
b/components/camel-ganglia/src/main/java/org/apache/camel/component/ganglia/GangliaProducer.java
index 21d3fc8..c373e58 100644
--- 
a/components/camel-ganglia/src/main/java/org/apache/camel/component/ganglia/GangliaProducer.java
+++ 
b/components/camel-ganglia/src/main/java/org/apache/camel/component/ganglia/GangliaProducer.java
@@ -23,6 +23,9 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.impl.DefaultProducer;
 
+/**
+ * @version 
+ */
 public class GangliaProducer extends DefaultProducer {
 
     private final Publisher publisher;
@@ -68,17 +71,22 @@ public class GangliaProducer extends DefaultProducer {
             units = message.getHeader(GangliaConstants.METRIC_UNITS, 
String.class);
         }
 
-        int tmax = conf.getTMax();
+        int tmax = conf.getTmax();
         if (message.getHeaders().containsKey(GangliaConstants.METRIC_TMAX)) {
             tmax = message.getHeader(GangliaConstants.METRIC_TMAX, 
Integer.class);
         }
 
-        int dmax = conf.getDMax();
+        int dmax = conf.getDmax();
         if (message.getHeaders().containsKey(GangliaConstants.METRIC_DMAX)) {
             dmax = message.getHeader(GangliaConstants.METRIC_DMAX, 
Integer.class);
         }
 
         String value = message.getBody(String.class);
+        if ((value == null || value.length() == 0) &&
+                (type == GMetricType.FLOAT || type == GMetricType.DOUBLE)) {
+            log.debug("Metric {} string value was null, using NaN", 
metricName);
+            value = "NaN";
+        }
 
         if (log.isDebugEnabled()) {
             log.debug("Sending metric {} to Ganglia: {}", metricName, value);

http://git-wip-us.apache.org/repos/asf/camel/blob/6605b826/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index a7e6347..e574a2e 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -177,6 +177,7 @@
     <geronimo-servlet-spec-version>1.0</geronimo-servlet-spec-version>
     
<geronimo-ws-metadata-spec-version>1.1.3</geronimo-ws-metadata-spec-version>
     <gmaven-plugin-version>1.4</gmaven-plugin-version>
+    <gmetric4j-version>1.0.9</gmetric4j-version>
     <google-app-engine-version>1.8.3</google-app-engine-version>
     
<google-app-engine-bundle-version>1.8.3_1</google-app-engine-bundle-version>
     <google-gdata-version>1.41.5.w1</google-gdata-version>
@@ -354,6 +355,7 @@
     <olingo2-version>2.0.0</olingo2-version>
     
<olingo-odata2-core-bundle-version>2.0.0_1</olingo-odata2-core-bundle-version>
     <ognl-version>3.0.8_1</ognl-version>
+    <oncrpc-version>1.1.2</oncrpc-version>
     <openejb-version>4.6.0.2</openejb-version>
     <openjpa-version>2.3.0</openjpa-version>
     <opensaml-version>2.5.1_2</opensaml-version>
@@ -818,6 +820,11 @@
       </dependency>
       <dependency>
         <groupId>org.apache.camel</groupId>
+        <artifactId>camel-ganglia</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.camel</groupId>
         <artifactId>camel-github</artifactId>
         <version>${project.version}</version>
       </dependency>

http://git-wip-us.apache.org/repos/asf/camel/blob/6605b826/platforms/karaf/features/src/main/resources/features.xml
----------------------------------------------------------------------
diff --git a/platforms/karaf/features/src/main/resources/features.xml 
b/platforms/karaf/features/src/main/resources/features.xml
index 3b2ae3a..66ff965 100644
--- a/platforms/karaf/features/src/main/resources/features.xml
+++ b/platforms/karaf/features/src/main/resources/features.xml
@@ -52,7 +52,7 @@
      <bundle>mvn:org.apache.camel/camel-blueprint/${project.version}</bundle>
   </feature>
 
-  <!-- the following features is sorted A..Z -->
+  <!-- the following features are sorted A..Z -->
 
   <feature name='camel-ahc' version='${project.version}' resolver='(obr)' 
start-level='50'>
     <feature version='${project.version}'>camel-core</feature>
@@ -408,6 +408,12 @@
     <bundle 
dependency='true'>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.gae/${google-app-engine-bundle-version}</bundle>
     <bundle>mvn:org.apache.camel/camel-gae/${project.version}</bundle>
   </feature>
+  <feature name='camel-ganglia' version='${project.version}' resolver='(obr)' 
start-level='50'>
+    <feature version='${project.version}'>camel-core</feature>
+    <bundle 
dependency='true'>mvn:org.acplt.remotetea/remotetea-oncrpc/${oncrpc-version}</bundle>
+    <bundle 
dependency='true'>mvn:info.ganglia.gmetric4j/gmetric4j/${gmetric4j-version}</bundle>
+    <bundle>mvn:org.apache.camel/camel-ganglia/${project.version}</bundle>
+  </feature>
   <feature name='camel-geocoder' version='${project.version}' resolver='(obr)' 
start-level='50'>
     <feature version='${project.version}'>camel-core</feature>
     <bundle 
dependency='true'>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient/${commons-httpclient-bundle-version}</bundle>

http://git-wip-us.apache.org/repos/asf/camel/blob/6605b826/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelGangliaTest.java
----------------------------------------------------------------------
diff --git 
a/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelGangliaTest.java
 
b/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelGangliaTest.java
new file mode 100644
index 0000000..5c3df1e
--- /dev/null
+++ 
b/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelGangliaTest.java
@@ -0,0 +1,40 @@
+/**
+ * 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.itest.karaf;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+
+@RunWith(PaxExam.class)
+public class CamelGangliaTest extends AbstractFeatureTest {
+
+    public static final String COMPONENT = extractName(CamelGangliaTest.class);
+
+    @Test
+    public void test() throws Exception {
+        testComponent(COMPONENT);
+    }
+
+    @Configuration
+    public static Option[] configure() {
+        return configure(COMPONENT);
+    }
+
+}

Reply via email to