[rhq] 3 commits - modules/enterprise modules/plugins pom.xml
by Heiko W. Rupp
modules/enterprise/server/plugins/alert-microblog/pom.xml | 18
modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java | 15
modules/plugins/hadoop/pom.xml | 185 ++++++++++
modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopComponent.java | 47 ++
modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopDiscovery.java | 64 +++
modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopServiceComponent.java | 135 +++++++
modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopServiceDiscovery.java | 135 +++++++
modules/plugins/hadoop/src/main/resources/META-INF/rhq-plugin.xml | 70 +++
modules/plugins/twitter/pom.xml | 12
modules/plugins/twitter/src/main/java/org/rhq/plugins/twitter/TwitterComponent.java | 23 -
pom.xml | 9
11 files changed, 687 insertions(+), 26 deletions(-)
New commits:
commit 7449c09e21af72826ac3d765612bb28bee9be16b
Author: Heiko W. Rupp <hwr(a)pilhuhn.de>
Date: Tue Jun 15 19:19:25 2010 +0200
Update to new twitter4j methods.
diff --git a/modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java b/modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java
index b13763e..b148a9b 100644
--- a/modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java
+++ b/modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java
@@ -18,9 +18,13 @@
*/
package org.rhq.enterprise.server.plugins.alertMicroblog;
+import java.util.Properties;
+
import twitter4j.Status;
import twitter4j.Twitter;
import twitter4j.TwitterException;
+import twitter4j.TwitterFactory;
+import twitter4j.conf.PropertyConfiguration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -48,9 +52,16 @@ public class MicroblogSender extends AlertSender {
String baseUrl = preferences.getSimpleValue("microblogServerUrl","http://twitter.com/");
if (!baseUrl.endsWith("/"))
baseUrl = baseUrl +"/";
- Twitter twitter = new Twitter(user,password,baseUrl);
+ Properties props = new Properties();
+ props.put(PropertyConfiguration.SOURCE,"Jopr");
+ props.put(PropertyConfiguration.HTTP_USER_AGENT,"Jopr");
+ props.put(PropertyConfiguration.REST_BASE_URL,baseUrl);
+ twitter4j.conf.Configuration tconf = new PropertyConfiguration(props);
+
+ TwitterFactory tFactory = new TwitterFactory(tconf);
+
+ Twitter twitter = tFactory.getInstance(user,password);
AlertManagerLocal alertManager = LookupUtil.getAlertManager();
- twitter.setSource("Jopr");
StringBuilder b = new StringBuilder("Alert ");
b.append(alert.getId()).append(":'"); // Alert id
b.append(alert.getAlertDefinition().getResource().getName());
diff --git a/modules/plugins/twitter/src/main/java/org/rhq/plugins/twitter/TwitterComponent.java b/modules/plugins/twitter/src/main/java/org/rhq/plugins/twitter/TwitterComponent.java
index d3c4d9e..eab4634 100644
--- a/modules/plugins/twitter/src/main/java/org/rhq/plugins/twitter/TwitterComponent.java
+++ b/modules/plugins/twitter/src/main/java/org/rhq/plugins/twitter/TwitterComponent.java
@@ -21,11 +21,14 @@ package org.rhq.plugins.twitter;
import java.net.URL;
import java.net.MalformedURLException;
import java.util.List;
+import java.util.Properties;
import java.util.Set;
import twitter4j.Paging;
import twitter4j.Status;
import twitter4j.Twitter;
+import twitter4j.TwitterFactory;
+import twitter4j.conf.PropertyConfiguration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -63,6 +66,7 @@ public class TwitterComponent implements ResourceComponent, OperationFacet, Meas
private String password;
private String serverUrl;
private String searchBaseUrl;
+ private TwitterFactory tFactory;
private TwitterEventPoller eventPoller;
private long lastId = NOT_YET_SET;
private static final String HTTP_TWITTER_COM = "http://twitter.com/";
@@ -111,6 +115,15 @@ public class TwitterComponent implements ResourceComponent, OperationFacet, Meas
eventContext = context.getEventContext();
eventPoller = new TwitterEventPoller(TWIT_EVENT);
eventContext.registerEventPoller(eventPoller, 53);
+ Properties props = new Properties();
+ props.put(PropertyConfiguration.SOURCE,"Jopr");
+ props.put(PropertyConfiguration.HTTP_USER_AGENT,"Jopr");
+ props.put(PropertyConfiguration.SEARCH_BASE_URL,searchBaseUrl);
+ props.put(PropertyConfiguration.REST_BASE_URL,serverUrl);
+ twitter4j.conf.Configuration tconf = new PropertyConfiguration(props);
+
+ tFactory = new TwitterFactory(tconf);
+
}
@@ -132,7 +145,9 @@ public class TwitterComponent implements ResourceComponent, OperationFacet, Meas
for (MeasurementScheduleRequest req : metrics) {
if (req.getName().equals("tweetCount")) {
- Twitter twitter = new Twitter(username,password,serverUrl);
+
+ Twitter twitter = tFactory.getInstance(username,password); // TODO server url?
+// Twitter twitter = new Twitter(username,password,serverUrl);
Paging paging = new Paging();
if (lastId == NOT_YET_SET) {
paging.setSinceId(1);
@@ -155,7 +170,7 @@ public class TwitterComponent implements ResourceComponent, OperationFacet, Meas
lastId = statuses.get(0).getId(); // This is always newest first
}
else if (req.getName().equals("followerCount")) {
- Twitter twitter = new Twitter(username,password,serverUrl);
+ Twitter twitter = tFactory.getInstance(username,password); // TODO server url?
int count = twitter.getFollowersIDs().getIDs().length;
MeasurementDataNumeric res;
res = new MeasurementDataNumeric(req,(double)count);
@@ -181,9 +196,7 @@ public class TwitterComponent implements ResourceComponent, OperationFacet, Meas
String message = configuration.getSimpleValue("message",null);
- Twitter twitter = new Twitter(username,password,serverUrl);
- twitter.setSource("Jopr");
- twitter.setUserAgent("Jopr");
+ Twitter twitter = tFactory.getInstance(username,password);
Status status = twitter.updateStatus(message);
OperationResult result = new OperationResult("Posted " + status.getText());
commit 9367e471e8faeea2cb0c49521939c48d03c10d2d
Author: Heiko W. Rupp <hwr(a)pilhuhn.de>
Date: Tue Jun 15 07:57:47 2010 +0200
Update twitter4j version to prepare for OAuth changes.
diff --git a/modules/enterprise/server/plugins/alert-microblog/pom.xml b/modules/enterprise/server/plugins/alert-microblog/pom.xml
index c3f248c..48bcca6 100644
--- a/modules/enterprise/server/plugins/alert-microblog/pom.xml
+++ b/modules/enterprise/server/plugins/alert-microblog/pom.xml
@@ -26,9 +26,9 @@
<dependencies>
<dependency>
- <groupId>net.homeip.yusuke</groupId>
- <artifactId>twitter4j</artifactId>
- <version>2.0.9</version>
+ <groupId>org.twitter4j</groupId>
+ <artifactId>twitter4j-core</artifactId>
+ <version>${twitter4j.version}</version>
</dependency>
</dependencies>
@@ -135,9 +135,9 @@
<configuration>
<artifactItems>
<artifactItem>
- <groupId>net.homeip.yusuke</groupId>
- <artifactId>twitter4j</artifactId>
- <version>2.0.9</version>
+ <groupId>org.twitter4j</groupId>
+ <artifactId>twitter4j-core</artifactId>
+ <version>${twitter4j.version}</version>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.outputDirectory}/lib</outputDirectory>
@@ -170,9 +170,9 @@
<configuration>
<artifactItems>
<artifactItem>
- <groupId>net.homeip.yusuke</groupId>
- <artifactId>twitter4j</artifactId>
- <version>2.0.9</version>
+ <groupId>org.twitter4j</groupId>
+ <artifactId>twitter4j-core</artifactId>
+ <version>${twitter4j.version}</version>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.outputDirectory}/lib</outputDirectory>
diff --git a/modules/plugins/twitter/pom.xml b/modules/plugins/twitter/pom.xml
index 9adaca6..c27ee72 100644
--- a/modules/plugins/twitter/pom.xml
+++ b/modules/plugins/twitter/pom.xml
@@ -116,9 +116,9 @@
<configuration>
<artifactItems>
<artifactItem>
- <groupId>net.homeip.yusuke</groupId>
- <artifactId>twitter4j</artifactId>
- <version>2.0.8</version>
+ <groupId>org.twitter4j</groupId>
+ <artifactId>twitter4j-core</artifactId>
+ <version>${twitter4j.version}</version>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.outputDirectory}/lib</outputDirectory>
@@ -160,9 +160,9 @@
</dependency>
<dependency>
- <groupId>net.homeip.yusuke</groupId>
- <artifactId>twitter4j</artifactId>
- <version>2.0.9</version>
+ <groupId>org.twitter4j</groupId>
+ <artifactId>twitter4j-core</artifactId>
+ <version>${twitter4j.version}</version>
</dependency>
</dependencies>
diff --git a/pom.xml b/pom.xml
index e000770..dff1c40 100644
--- a/pom.xml
+++ b/pom.xml
@@ -83,10 +83,11 @@
<sigar.version>1.6.5.132</sigar.version>
<quartz.version>1.6.5</quartz.version>
<jna.version>3.2.2</jna.version>
+ <twitter4j.version>2.1.2</twitter4j.version>
<!--
defaults for datasource used by integration tests -
- these may be overridden in ~/.m2/settings.xml
+ these may be overridden in ~/.m2/settings.xml
-->
<rhq.test.ds.db-name>rhq</rhq.test.ds.db-name>
<rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/${rhq.test.ds.db-name}</rhq.test.ds.connection-url>
@@ -106,7 +107,7 @@
<!--
defaults for datasource used by the dev container build (see dev docs on the 'dev' profile) -
- these may be overridden in ~/.m2/settings.xml
+ these may be overridden in ~/.m2/settings.xml
-->
<rhq.dev.ds.db-name>rhqdev</rhq.dev.ds.db-name>
<rhq.dev.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/${rhq.dev.ds.db-name}</rhq.dev.ds.connection-url>
@@ -654,7 +655,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
- <executions>
+ <executions>
<execution>
<id>read-build-properties</id>
<phase>process-resources</phase>
@@ -674,7 +675,7 @@
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
- <!-- As of v2.4 of this plugin, the default delimiters are @*@ -
+ <!-- As of v2.4 of this plugin, the default delimiters are @*@ -
we want the old default of ${*} instead. -->
<useDefaultDelimiters>false</useDefaultDelimiters>
<delimiters>
commit fcdfd9b5921cdfd04901827b2735b25181d13027
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Jun 14 14:26:16 2010 +0200
First cut of a Hadoop plugin.
diff --git a/modules/plugins/hadoop/pom.xml b/modules/plugins/hadoop/pom.xml
new file mode 100644
index 0000000..f5bfd9a
--- /dev/null
+++ b/modules/plugins/hadoop/pom.xml
@@ -0,0 +1,185 @@
+<project
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+ >
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-plugins-parent</artifactId>
+ <version>3.0.0-SNAPSHOT</version><!-- TODO adjust RHQ version -->
+ </parent>
+
+ <groupId>org.rhq</groupId>
+ <artifactId>Hadoop-plugin</artifactId>
+ <packaging>jar</packaging>
+
+ <name>RHQ Hadoop Plugin</name>
+ <description>Monitor Hadoop clusters</description>
+
+ <properties>
+ <scm.module.path>TODO</scm.module.path>
+ <rhq.version>3.0.0-SNAPSHOT</rhq.version> <!-- TODO adjust, see above too -->
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+
+
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>dev</id>
+
+ <properties>
+ <rhq.rootDir>../../..</rhq.rootDir>
+ <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
+ <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/rhq-downloads/rhq-plugins</rhq.deploymentDir>
+ </properties>
+
+ <build>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+
+ <execution>
+ <id>deploy</id>
+ <phase>compile</phase>
+ <configuration>
+ <tasks>
+ <mkdir dir="${rhq.deploymentDir}"/>
+ <property name="deployment.file"
+ location="${rhq.deploymentDir}/${project.build.finalName}.jar"/>
+ <echo>*** Updating ${deployment.file}...</echo>
+ <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}"/>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>deploy-jar-meta-inf</id>
+ <phase>package</phase>
+ <configuration>
+ <tasks>
+ <property name="deployment.file"
+ location="${rhq.deploymentDir}/${project.build.finalName}.jar"/>
+ <echo>*** Updating META-INF dir in ${deployment.file}...</echo>
+ <unjar src="${project.build.directory}/${project.build.finalName}.jar"
+ dest="${project.build.outputDirectory}">
+ <patternset>
+ <include name="META-INF/**"/>
+ </patternset>
+ </unjar>
+ <jar destfile="${deployment.file}"
+ manifest="${project.build.outputDirectory}/META-INF/MANIFEST.MF"
+ update="true">
+ </jar>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>undeploy</id>
+ <phase>clean</phase>
+ <configuration>
+ <tasks>
+ <property name="deployment.file"
+ location="${rhq.deploymentDir}/${project.build.finalName}.jar"/>
+ <echo>*** Deleting ${deployment.file}...</echo>
+ <delete file="${deployment.file}"/>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+
+ </profile>
+ </profiles>
+
+
+ <repositories>
+ <repository>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ <id>jboss</id>
+ <name>JBoss Repository</name>
+ <url>http://repository.jboss.org/maven2/</url>
+ </repository>
+ <!-- TODO add your own maven repositories here (if needed) -->
+ </repositories>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ <id>jboss</id>
+ <name>JBoss Plugin Repository</name>
+ <url>http://repository.jboss.org/maven2/</url>
+ </pluginRepository>
+ </pluginRepositories>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-domain</artifactId>
+ <version>${rhq.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-plugin-api</artifactId>
+ <version>${rhq.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-native-system</artifactId>
+ <version>${rhq.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-jmx-plugin</artifactId>
+ <version>${rhq.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- TODO add your dependencies here -->
+
+ </dependencies>
+</project>
\ No newline at end of file
diff --git a/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopComponent.java b/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopComponent.java
new file mode 100644
index 0000000..a568de9
--- /dev/null
+++ b/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopComponent.java
@@ -0,0 +1,47 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.hadoop;
+
+import com.google.gwt.user.client.ui.ResizeComposite;
+
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+
+/**
+ * // TODO: Document this
+ * @author Heiko W. Rupp
+ */
+public class HadoopComponent implements ResourceComponent{
+
+// private final Log log = LogFactory.getLog(HadoopComponent.class);
+
+ public void start(ResourceContext resourceContext) throws InvalidPluginConfigurationException, Exception {
+ // TODO: Customise this generated block
+ }
+
+ public void stop() {
+ // TODO: Customise this generated block
+ }
+
+ public AvailabilityType getAvailability() {
+ return AvailabilityType.UP; // TODO: Customise this generated block
+ }
+}
diff --git a/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopDiscovery.java b/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopDiscovery.java
new file mode 100644
index 0000000..de8613a
--- /dev/null
+++ b/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopDiscovery.java
@@ -0,0 +1,64 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.hadoop;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+
+/**
+ * Discover a hadoop subsystem. When one of the hadoop server processes
+ * is present, this class discovers a Hadoop 'subsystem' that holds all the
+ * children in the resource tree.
+ *
+ * @author Heiko W. Rupp
+ */
+public class HadoopDiscovery implements ResourceDiscoveryComponent {
+
+ private final Log log = LogFactory.getLog(HadoopDiscovery.class);
+
+ public Set<DiscoveredResourceDetails> discoverResources(
+ ResourceDiscoveryContext resourceDiscoveryContext) throws InvalidPluginConfigurationException, Exception {
+
+ Set<DiscoveredResourceDetails> result = new HashSet<DiscoveredResourceDetails>(1);
+
+ if (resourceDiscoveryContext.getAutoDiscoveredProcesses().size()>0) {
+ // Found some Hadoop processes
+
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
+ resourceDiscoveryContext.getResourceType(),
+ "Hadoop|", // TODO add path
+ "Hadoop",
+ null, // get from core jar
+ "Hadoop Framework",
+ resourceDiscoveryContext.getDefaultPluginConfiguration(),
+ null // ProcessInfo
+ );
+ result.add(detail);
+ }
+ return result;
+ }
+}
diff --git a/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopServiceComponent.java b/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopServiceComponent.java
new file mode 100644
index 0000000..53f437b
--- /dev/null
+++ b/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopServiceComponent.java
@@ -0,0 +1,135 @@
+
+package org.rhq.plugins.hadoop;
+
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.mc4j.ems.connection.EmsConnection;
+import org.mc4j.ems.connection.bean.EmsBean;
+import org.mc4j.ems.connection.bean.attribute.EmsAttribute;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.MeasurementDataNumeric;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.rhq.core.pluginapi.operation.OperationContext;
+import org.rhq.core.pluginapi.operation.OperationFacet;
+import org.rhq.core.pluginapi.operation.OperationResult;
+import org.rhq.plugins.jmx.JMXComponent;
+import org.rhq.plugins.jmx.JMXServerComponent;
+
+public class HadoopServiceComponent extends JMXServerComponent implements JMXComponent, ResourceComponent
+, MeasurementFacet
+, OperationFacet
+{
+ private final Log log = LogFactory.getLog(this.getClass());
+
+ private ResourceContext context;
+
+
+
+
+ /**
+ * Return availability of this resource
+ * @see org.rhq.core.pluginapi.inventory.ResourceComponent#getAvailability()
+ */
+ public AvailabilityType getAvailability() {
+ return context.getNativeProcess().isRunning() ? AvailabilityType.UP: AvailabilityType.DOWN;
+ }
+
+
+ /**
+ * Start the resource connection
+ * @see org.rhq.core.pluginapi.inventory.ResourceComponent#start(org.rhq.core.pluginapi.inventory.ResourceContext)
+ */
+ public void start(ResourceContext context) throws InvalidPluginConfigurationException, Exception {
+
+ Configuration conf = context.getPluginConfiguration();
+ this.context = context;
+ super.start(context);
+ log.info("Started " + context.getResourceKey());
+
+ }
+
+
+ /**
+ * Tear down the resource connection
+ * @see org.rhq.core.pluginapi.inventory.ResourceComponent#stop()
+ */
+ public void stop() {
+ super.stop();
+
+ }
+
+ @Override
+ public EmsConnection getEmsConnection() {
+ EmsConnection conn = super.getEmsConnection(); // TODO: Customise this generated block
+ log.info("EmsConnection is " + conn.toString());
+ return conn;
+
+ }
+
+ /**
+ * Gather measurement data
+ * @see org.rhq.core.pluginapi.measurement.MeasurementFacet#getValues(org.rhq.core.domain.measurement.MeasurementReport, java.util.Set)
+ */
+ public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception {
+
+ for (MeasurementScheduleRequest req : metrics) {
+ String property=req.getName();
+ String props[] = property.split("\\|");
+
+ EmsConnection conn = getEmsConnection();
+ EmsBean bean = conn.getBean(props[0]);
+ if (bean != null) {
+ bean.refreshAttributes();
+ EmsAttribute att = bean.getAttribute(props[1]);
+ if (att!=null) {
+ Long val = (Long) att.getValue(); // TODO check for real type
+
+ MeasurementDataNumeric res = new MeasurementDataNumeric(req, Double.valueOf(val));
+ report.addData(res);
+ }
+ else
+ log.warn("Attribute " + props[1] + " not found");
+ }
+ else
+ log.warn("MBean " + props[0] +" not found");
+ }
+ }
+
+
+
+ public void startOperationFacet(OperationContext context) {
+
+ }
+
+
+ /**
+ * Invokes the passed operation on the managed resource
+ * @param name Name of the operation
+ * @param params The method parameters
+ * @return An operation result
+ * @see org.rhq.core.pluginapi.operation.OperationFacet
+ */
+ public OperationResult invokeOperation(String name, Configuration params) throws Exception {
+
+ OperationResult res = new OperationResult();
+ if ("dummyOperation".equals(name)) {
+ // TODO implement me
+
+ }
+ return res;
+ }
+
+
+
+
+
+}
diff --git a/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopServiceDiscovery.java b/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopServiceDiscovery.java
new file mode 100644
index 0000000..bcc9af8
--- /dev/null
+++ b/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopServiceDiscovery.java
@@ -0,0 +1,135 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.plugins.hadoop;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.mc4j.ems.connection.support.metadata.InternalVMTypeDescriptor;
+import org.mc4j.ems.connection.support.metadata.J2SE5ConnectionTypeDescriptor;
+import org.mc4j.ems.connection.support.metadata.LocalVMTypeDescriptor;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ProcessScanResult;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.jmx.JMXDiscoveryComponent;
+
+/**
+ * Discover individual hadoop processes
+ * @author Heiko W. Rupp
+ */
+public class HadoopServiceDiscovery implements ResourceDiscoveryComponent {
+
+ private final Log log = LogFactory.getLog(HadoopServiceDiscovery.class);
+ private static final String HADOOP_VERSION_MATCH = ".*hadoop-([0-9\\.]+)-core.jar.*";
+ private Pattern hadoopPattern = Pattern.compile(HADOOP_VERSION_MATCH);
+
+ public Set<DiscoveredResourceDetails> discoverResources(
+ ResourceDiscoveryContext resourceDiscoveryContext) throws InvalidPluginConfigurationException, Exception {
+
+ Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>();
+
+ @SuppressWarnings("unchecked")
+ List<ProcessScanResult> parentProcessScans = resourceDiscoveryContext.getParentResourceContext().getNativeProcessesForType();
+ ResourceType resourceType = resourceDiscoveryContext.getResourceType();
+ String rtName = resourceType.getName();
+
+ for (ProcessScanResult psr : parentProcessScans) {
+
+
+ if (psr.getProcessScan().getName().equals(rtName)) {
+
+ String[] commandLineArgs = psr.getProcessInfo().getCommandLine();
+ String version = getVersion(commandLineArgs);
+ String javaClazz = getClazzFromCommandLine(commandLineArgs);
+
+ Configuration pluginConfiguration = resourceDiscoveryContext.getDefaultPluginConfiguration();
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
+ resourceType, // ResourceType
+ rtName+":"+psr.getProcessInfo().getCurrentWorkingDirectory(), // ResourceKey
+ rtName, // resource name
+ version, // Version
+ "Hadoop " + rtName + " ( "+ psr.getProcessInfo().getCurrentWorkingDirectory() +" )", // description
+ pluginConfiguration,
+ psr.getProcessInfo() // process info
+ );
+
+
+ /*
+ * We'll connect to the discovered VM on the local host, so set the jmx connection
+ * properties accordingly. This may only work on JDK6+, but then JDK5 is deprecated
+ * anyway.
+ */
+ pluginConfiguration.put(new PropertySimple(JMXDiscoveryComponent.COMMAND_LINE_CONFIG_PROPERTY,
+ javaClazz));
+ pluginConfiguration.put(new PropertySimple(JMXDiscoveryComponent.CONNECTION_TYPE,
+ LocalVMTypeDescriptor.class.getName()));
+
+ log.info("Discovered " + detail);
+ details.add(detail);
+ }
+ }
+
+ return details;
+ }
+
+ /**
+ * Get the full class name of the java class that 'jps -l' would list
+ * @param commandLineArgs Command line args for the java executable
+ * @return full class name for the server class
+ */
+ private String getClazzFromCommandLine(String[] commandLineArgs) {
+ for (String line : commandLineArgs) {
+ if (line.startsWith("org.apache.hadoop."))
+ return line;
+ }
+ return "-not found-";
+ }
+
+ /**
+ * Get hadoop version
+ * from command line by looking at haoop-core-xx-core.jar
+ * @param commandLine Command line args for the java executable
+ * @return hdoop version string or null if it can not be determined
+ */
+ private String getVersion(String[] commandLine) {
+
+ for (String line : commandLine) {
+ Matcher m = hadoopPattern.matcher(line);
+ if (m.matches()) {
+ String result = m.group(1);
+ return result;
+ }
+ }
+
+ return null;
+ }
+
+
+}
diff --git a/modules/plugins/hadoop/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/hadoop/src/main/resources/META-INF/rhq-plugin.xml
new file mode 100644
index 0000000..8f1f506
--- /dev/null
+++ b/modules/plugins/hadoop/src/main/resources/META-INF/rhq-plugin.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0"?>
+<plugin name="hadoop"
+ displayName="hadoopPlugin"
+ description="Monitor Hadoop Clusters"
+ package="org.rhq.plugins.hadoop"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:xmlns:rhq-plugin"
+ xmlns:c="urn:xmlns:rhq-configuration">
+
+ <depends plugin="JMX" useClasses="true"/>
+
+ <server name="Hadoop" discovery="HadoopDiscovery" class="HadoopComponent">
+
+
+ <process-scan name="TaskTracker" query="process|basename|match=^java.*,arg|org.apache.hadoop.mapred.TaskTracker|match=.*"/>
+ <process-scan name="JobTracker" query="process|basename|match=^java.*,arg|org.apache.hadoop.mapred.JobTracker|match=.*"/>
+ <process-scan name="NameNode" query="process|basename|match=^java.*,arg|org.apache.hadoop.hdfs.server.namenode.NameNode|match=.*"/>
+ <process-scan name="SecondaryNameNode" query="process|basename|match=^java.*,arg|org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode|match=.*"/>
+ <process-scan name="DataNode" query="process|basename|match=^java.*,arg|org.apache.hadoop.hdfs.server.datanode.DataNode|match=.*"/>
+
+
+
+ <service name="TaskTracker" discovery="HadoopServiceDiscovery" class="HadoopServiceComponent"
+ >
+
+ </service>
+
+ <service name="JobTracker" discovery="HadoopServiceDiscovery" class="HadoopServiceComponent"
+ >
+ <plugin-configuration>
+ <c:simple-property name="baseObjectName" defaultValue="hadoop:service=JobTracker"/>
+ </plugin-configuration>
+ </service>
+
+ <service name="NameNode" discovery="HadoopServiceDiscovery" class="HadoopServiceComponent">
+ <metric property="hadoop:service=NameNode,name=FSNamesystemState|CapacityTotal" displayName="CapacityTotal"
+ units="bytes" description="DFS Configured capacitiy"/>
+ <metric property="hadoop:service=NameNode,name=FSNamesystemState|CapacityUsed" displayName="CapacityUsed"
+ units="bytes" description="DFS used" displayType="summary"/>
+ <metric property="hadoop:service=NameNode,name=FSNamesystemState|CapacityRemaining" displayName="CapacityRemaining"
+ units="bytes" description="DFS remaining"/>
+ <metric property="hadoop:service=NameNode,name=FSNamesystemState|BlocksTotal" displayName="BlocksTotal"
+ units="none"/>
+ <metric property="hadoop:service=NameNode,name=FSNamesystemState|FilesTotal" displayName="FilesTotal"
+ units="none"/>
+ <metric property="hadoop:service=NameNode,name=FSNamesystemState|PendingReplicationBlocks" displayName="PendingReplicationBlocks"
+ units="none"/>
+
+ <metric property="hadoop:service=NameNode,name=NameNodeActivity|FilesCreated" displayName="FilesCreated"
+ units="none"/>
+ </service>
+
+ <service name="SecondaryNameNode" discovery="HadoopServiceDiscovery" class="HadoopServiceComponent"
+ >
+ </service>
+
+
+ <service name="DataNode" discovery="HadoopServiceDiscovery" class="HadoopServiceComponent">
+
+ <metric property="DataNodeActivity*|bytes_written"/>
+ <metric property="FSDatasetState*|Remaining"/>
+ <metric property="FSDatasetState*|Capacity"/>
+ <metric property="FSDatasetState*|StorageInfo" dataType="trait" displayType="summary"/>
+ <metric property="RpcActivitForPort*|NumOpenConnections"/>
+
+ </service>
+ </server>
+
+
+</plugin>
\ No newline at end of file
13 years, 11 months
[rhq] modules/core
by mazz
modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java | 1 +
1 file changed, 1 insertion(+)
New commits:
commit 8e37d409d6fdd411c188e5be519b72a26085c21e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jun 24 13:18:04 2010 -0400
clean commons logging factory cache to help free memory on shutdown
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java
index 8970404..d6546a2 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java
@@ -336,6 +336,7 @@ public class PluginContainer implements ContainerService {
*/
private void cleanMemory() {
Introspector.flushCaches();
+ LogFactory.releaseAll();
System.gc();
}
13 years, 11 months