Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CAMEL-8342: Add Ganglia component #393

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions apache-camel/src/main/descriptors/common-bin.xml
Expand Up @@ -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>
Expand Down
16 changes: 15 additions & 1 deletion components/camel-ganglia/pom.xml
Expand Up @@ -36,6 +36,20 @@
<camel.osgi.export.service>org.apache.camel.spi.ComponentResolver;component=ganglia</camel.osgi.export.service>
</properties>

<repositories>
<repository>
<id>jboss.fs</id>
<name>JBoss FuseSource Public Release Repository</name>
<url>https://repository.jboss.org/nexus/content/groups/fs-public</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>

<dependencies>

<dependency>
Expand All @@ -46,7 +60,7 @@
<dependency>
<groupId>info.ganglia.gmetric4j</groupId>
<artifactId>gmetric4j</artifactId>
<version>1.0.7</version>
<version>${gmetric4j-version}</version>
</dependency>

<!-- test dependencies -->
Expand Down
Expand Up @@ -34,7 +34,7 @@
@UriParams
public class GangliaConfiguration implements Cloneable {

public static final String DEFAULT_DESTINATION = "127.0.0.1";
public static final String DEFAULT_DESTINATION = "239.2.11.71";
public static final int DEFAULT_PORT = 8649;
public static final GMetric.UDPAddressingMode DEFAULT_MODE = GMetric.UDPAddressingMode.MULTICAST;
public static final int DEFAULT_TTL = 5;
Expand All @@ -56,22 +56,22 @@ public class GangliaConfiguration implements Cloneable {
@UriParam
private GMetric.UDPAddressingMode mode = DEFAULT_MODE;

@UriParam(defaultValue = "5")
@UriParam
private int ttl = DEFAULT_TTL;

@UriParam(defaultValue = "true")
@UriParam
private boolean wireFormat31x = DEFAULT_WIRE_FORMAT_31X;

@UriParam
private String spoofHostname;

@UriParam(defaultValue = "Java")
@UriParam
private String groupName = DEFAULT_GROUP_NAME;

@UriParam
private String prefix;
private String prefix = null;

@UriParam(defaultValue = "metric")
@UriParam
private String metricName = DEFAULT_METRIC_NAME;

@UriParam
Expand All @@ -80,13 +80,13 @@ public class GangliaConfiguration implements Cloneable {
@UriParam
private GMetricSlope slope = DEFAULT_SLOPE;

@UriParam(defaultValue = "")
@UriParam
private String units = DEFAULT_UNITS;

@UriParam(defaultValue = "60")
@UriParam
private int tmax = DEFAULT_TMAX;

@UriParam(defaultValue = "0")
@UriParam
private int dmax = DEFAULT_DMAX;

/**
Expand Down Expand Up @@ -217,19 +217,19 @@ public void setUnits(String units) {
this.units = units;
}

public int getTMax() {
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;
}

Expand Down
Expand Up @@ -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() {
}
Expand Down
Expand Up @@ -29,10 +29,11 @@
import org.apache.camel.spi.UriParam;
import org.apache.camel.util.ObjectHelper;


/**
* @version
*/
@UriEndpoint(scheme = "ganglia", producerOnly = true, label = "monitoring")
@UriEndpoint(scheme = "ganglia", label = "monitoring")
public class GangliaEndpoint extends DefaultEndpoint {

private Publisher publisher;
Expand Down
Expand Up @@ -16,9 +16,12 @@
*/
package org.apache.camel.component.ganglia;

import java.util.concurrent.ExecutorService;

import info.ganglia.gmetric4j.Publisher;
import info.ganglia.gmetric4j.gmetric.GMetricSlope;
import info.ganglia.gmetric4j.gmetric.GMetricType;
import org.apache.camel.CamelException;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.impl.DefaultProducer;
Expand Down Expand Up @@ -68,17 +71,22 @@ public void process(Exchange exchange) throws Exception {
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);
Expand Down
7 changes: 7 additions & 0 deletions parent/pom.xml
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -816,6 +818,11 @@
<artifactId>camel-ftp</artifactId>
<version>${project.version}</version>
</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>
Expand Down
8 changes: 7 additions & 1 deletion platforms/karaf/features/src/main/resources/features.xml
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
@@ -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);
}

}