[rhq] Branch 'feature/hadoop-plugin' - modules/plugins
Jiri Kremser
jkremser at fedoraproject.org
Thu Aug 2 12:31:14 UTC 2012
modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopOperationsDelegate.java | 6 ++
modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopServerComponent.java | 28 +++++++++-
modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopSupportedOperations.java | 4 +
modules/plugins/hadoop/src/main/resources/META-INF/rhq-plugin.xml | 19 +++++-
4 files changed, 49 insertions(+), 8 deletions(-)
New commits:
commit fb042424cd329947d6a27b4d89382b0ea9932b57
Author: Jirka Kremser <jkremser at redhat.com>
Date: Thu Aug 2 14:31:03 2012 +0200
Support for percentage metrics from interval (0,100); new operations: rebalance
diff --git a/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopOperationsDelegate.java b/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopOperationsDelegate.java
index 6ebead7..ba39eae 100644
--- a/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopOperationsDelegate.java
+++ b/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopOperationsDelegate.java
@@ -72,6 +72,12 @@ public class HadoopOperationsDelegate {
case QUEUE_LIST:
results = queueList(operation);
break;
+ case JOB_LIST:
+ results = invokeGeneralOperation(operation);
+ break;
+ case REBALANCE_DFS:
+ results = invokeGeneralOperation(operation);
+ break;
default:
throw new UnsupportedOperationException(operation.toString());
}
diff --git a/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopServerComponent.java b/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopServerComponent.java
index cb36798..28fd6a1 100644
--- a/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopServerComponent.java
+++ b/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopServerComponent.java
@@ -20,6 +20,8 @@
package org.rhq.plugins.hadoop;
import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Set;
import org.apache.commons.logging.Log;
@@ -33,8 +35,10 @@ import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.MeasurementDataNumeric;
import org.rhq.core.domain.measurement.MeasurementDataTrait;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.measurement.MeasurementReport;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.domain.measurement.MeasurementUnits;
import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
import org.rhq.core.pluginapi.event.EventContext;
@@ -53,10 +57,11 @@ public class HadoopServerComponent extends JMXServerComponent<ResourceComponent<
JMXComponent<ResourceComponent<?>>, MeasurementFacet, OperationFacet, ConfigurationFacet {
private static final Log LOG = LogFactory.getLog(HadoopServerComponent.class);
-
private static final String LOG_EVENT_TYPE = "logEntry";
private static final String LOG_POLLING_INTERVAL_PROPERTY = "logPollingInterval";
+ private Map<String, Boolean> percentageMeasurements;
+
private HadoopServerConfigurationDelegate configurationDelegate;
private HadoopOperationsDelegate operationsDelegate;
@@ -69,6 +74,20 @@ public class HadoopServerComponent extends JMXServerComponent<ResourceComponent<
super.start(context);
configurationDelegate = new HadoopServerConfigurationDelegate(context);
this.operationsDelegate = new HadoopOperationsDelegate(context);
+
+ EventContext events = context.getEventContext();
+ if (events != null) {
+ File logFile = determineLogFile();
+ int interval = Integer.parseInt(context.getPluginConfiguration().getSimpleValue(LOG_POLLING_INTERVAL_PROPERTY, "60"));
+ events.registerEventPoller(new LogFileEventPoller(events, LOG_EVENT_TYPE, logFile, new Log4JLogEntryProcessor(LOG_EVENT_TYPE, logFile)), interval);
+ }
+
+ // percentage metrics obtained from Hadoop JMX api are from interval (0,100) and RHQ expects interval (0,1)
+ Set<MeasurementDefinition> measDefinitions = context.getResourceType().getMetricDefinitions();
+ percentageMeasurements = new HashMap<String, Boolean>(measDefinitions.size());
+ for (MeasurementDefinition measDefinition : measDefinitions) {
+ percentageMeasurements.put(measDefinition.getName(), MeasurementUnits.PERCENTAGE.equals(measDefinition.getUnits()));
+ }
}
@Override
@@ -139,7 +158,12 @@ public class HadoopServerComponent extends JMXServerComponent<ResourceComponent<
Object valueObject = attribute.refresh();
if (valueObject instanceof Number) {
Number value = (Number) valueObject;
- report.addData(new MeasurementDataNumeric(request, value.doubleValue()));
+ if (percentageMeasurements.get(name)) {
+ report.addData(new MeasurementDataNumeric(request, value.doubleValue() / 100));
+ } else {
+ report.addData(new MeasurementDataNumeric(request, value.doubleValue()));
+ }
+
} else {
report.addData(new MeasurementDataTrait(request, valueObject.toString()));
}
diff --git a/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopSupportedOperations.java b/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopSupportedOperations.java
index ec0fe0e..56ae9a0 100644
--- a/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopSupportedOperations.java
+++ b/modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopSupportedOperations.java
@@ -29,7 +29,9 @@ public enum HadoopSupportedOperations {
LS("/bin/hadoop", "fs -ls"),
START("/bin/hadoop-daemon.sh", "start "),
STOP("/bin/hadoop-daemon.sh", "stop "),
- QUEUE_LIST("/bin/hadoop", "queue -list");
+ QUEUE_LIST("/bin/hadoop", "queue -list"),
+ JOB_LIST("/bin/hadoop", "job -list"),
+ REBALANCE_DFS("/bin/hadoop", "balancer");
private final String relativePathToExecutable;
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
index 7e75fa3..e648af9 100644
--- a/modules/plugins/hadoop/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/hadoop/src/main/resources/META-INF/rhq-plugin.xml
@@ -21,6 +21,11 @@
<c:simple-property name="operationResult" description="Outcome of formatting the dfs."/>
</results>
</operation>
+ <operation name="rebalance_dfs" displayName="Rebalance dfs" description="Rebalance the data blocks across all DataNodes.">
+ <results>
+ <c:simple-property name="operationResult" description="Outcome of the rebalancing."/>
+ </results>
+ </operation>
<operation name="fsck" displayName="Check dfs" description="Runs a HDFS filesystem checking utility.">
<results>
<c:simple-property name="operationResult" description="Outcome of checking the dfs."/>
@@ -57,14 +62,13 @@
<metric property="Hadoop:service=NameNode,name=NameNodeInfo:Used" displayName="DFS Used" units="bytes"
description="DFS used" displayType="summary"/>
<metric property="Hadoop:service=NameNode,name=NameNodeInfo:PercentUsed" displayName="DFS Used %"
- description="DFS Used %" displayType="summary"/>
+ description="DFS Used %" displayType="summary" units="percentage"/>
<metric property="Hadoop:service=NameNode,name=NameNodeInfo:NonDfsUsedSpace" displayName="Non DFS Used"
units="bytes" description="Non DFS used"/>
<metric property="Hadoop:service=NameNode,name=NameNodeInfo:Free" displayName="DFS Capacity Remaining" units="bytes"
- description="DFS remaining"/>
- <!-- jmx returns number from interval (0,100) not from (0,1) units="percentage" -->
+ description="DFS remaining" />
<metric property="Hadoop:service=NameNode,name=NameNodeInfo:PercentRemaining" displayName="DFS Capacity Remaining %"
- description="DFS remaining"/>
+ description="DFS remaining" units="percentage"/>
<metric property="Hadoop:service=NameNode,name=NameNodeInfo:TotalBlocks" displayName="Blocks Total" units="none"/>
<metric property="Hadoop:service=NameNode,name=FSNamesystemState:FilesTotal" displayName="FilesTotal" units="none"/>
<metric property="Hadoop:service=NameNode,name=FSNamesystemState:PendingReplicationBlocks" displayName="Pending Replication Blocks"
@@ -163,7 +167,12 @@
<c:simple-property name="operationResult" description="Outcome of stopping the JobTracker"/>
</results>
</operation>
- <operation name="queue_list" displayName="Lists job queue" description="Lists the content of the job queue.">
+ <operation name="job_list" displayName="Lists Running Jobs" description="Lists the currently running jobs.">
+ <results>
+ <c:simple-property name="operationResult" description="Outcome of listing the running jobs"/>
+ </results>
+ </operation>
+ <operation name="queue_list" displayName="Lists Job Queue" description="Lists the content of the job queue.">
<results>
<c:simple-property name="operationResult" description="Outcome of listing the job queue"/>
</results>
More information about the rhq-commits
mailing list