[rhq] Branch 'feature/hadoop-plugin' - modules/plugins
Jiri Kremser
jkremser at fedoraproject.org
Tue Aug 7 15:16:42 UTC 2012
modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopOperationsDelegate.java | 23 +++++++---
modules/plugins/hadoop/src/main/java/org/rhq/plugins/hadoop/HadoopSupportedOperations.java | 15 +++++-
modules/plugins/hadoop/src/main/resources/META-INF/rhq-plugin.xml | 15 ++++++
3 files changed, 43 insertions(+), 10 deletions(-)
New commits:
commit 3229a0ed4f181bd69c84322ee9d17335576c8c0b
Author: Jirka Kremser <jkremser at redhat.com>
Date: Tue Aug 7 17:16:29 2012 +0200
New operation -- kill job
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 ba39eae..922f11a 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,12 +72,18 @@ public class HadoopOperationsDelegate {
case QUEUE_LIST:
results = queueList(operation);
break;
- case JOB_LIST:
+ case JOB_LIST_RUNNING:
+ results = invokeGeneralOperation(operation);
+ break;
+ case JOB_LIST_ALL:
results = invokeGeneralOperation(operation);
break;
case REBALANCE_DFS:
results = invokeGeneralOperation(operation);
- break;
+ break;
+ case KILL:
+ results = invokeGeneralOperation(operation, parameters, null);
+ break;
default:
throw new UnsupportedOperationException(operation.toString());
}
@@ -106,7 +112,7 @@ public class HadoopOperationsDelegate {
* @return the object encapsulating the exit code, err output and std output
*/
private ProcessExecutionResults stop(HadoopSupportedOperations operation, String serverType) {
- return invokeGeneralOperation(operation, serverType);
+ return invokeGeneralOperation(operation, null, serverType);
}
/**
@@ -115,7 +121,7 @@ public class HadoopOperationsDelegate {
* @return the object encapsulating the exit code, err output and std output
*/
private ProcessExecutionResults start(HadoopSupportedOperations operation, String serverType) {
- return invokeGeneralOperation(operation, serverType);
+ return invokeGeneralOperation(operation, null, serverType);
}
/**
@@ -188,14 +194,19 @@ public class HadoopOperationsDelegate {
}
private ProcessExecutionResults invokeGeneralOperation(HadoopSupportedOperations operation) {
- return invokeGeneralOperation(operation, null);
+ return invokeGeneralOperation(operation, null, null);
}
- private ProcessExecutionResults invokeGeneralOperation(HadoopSupportedOperations operation, String serverType) {
+ private ProcessExecutionResults invokeGeneralOperation(HadoopSupportedOperations operation, Configuration parameters, String serverType) {
String hadoopHome = resourceContext.getPluginConfiguration()
.getSimple(HadoopServerDiscovery.HOME_DIR_PROPERTY).getStringValue();
String executable = hadoopHome + operation.getRelativePathToExecutable();
String args = operation.getArgs() + (serverType == null ? "" : serverType.toLowerCase());
+ if (operation.getClass() != null) {
+ for (String paramName : operation.getParamsNames()) {
+ args += " " + parameters.getSimpleValue(paramName);
+ }
+ }
ProcessExecutionResults results = executeExecutable(resourceContext.getSystemInformation(), executable, args,
MAX_WAIT, true, true);
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 56ae9a0..12e6b5e 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
@@ -30,16 +30,21 @@ public enum HadoopSupportedOperations {
START("/bin/hadoop-daemon.sh", "start "),
STOP("/bin/hadoop-daemon.sh", "stop "),
QUEUE_LIST("/bin/hadoop", "queue -list"),
- JOB_LIST("/bin/hadoop", "job -list"),
- REBALANCE_DFS("/bin/hadoop", "balancer");
+ JOB_LIST_RUNNING("/bin/hadoop", "job -list"),
+ JOB_LIST_ALL("/bin/hadoop", "job -list all"),
+ REBALANCE_DFS("/bin/hadoop", "balancer"),
+ KILL("/bin/hadoop", "job -kill", "pid");
private final String relativePathToExecutable;
private final String args;
+
+ private final String[] paramNames;
- private HadoopSupportedOperations(String relativePathToExecutable, String args) {
+ private HadoopSupportedOperations(String relativePathToExecutable, String args, String... paramNames) {
this.relativePathToExecutable = relativePathToExecutable;
this.args = args;
+ this.paramNames = paramNames;
}
public String getRelativePathToExecutable() {
@@ -49,4 +54,8 @@ public enum HadoopSupportedOperations {
public String getArgs() {
return args;
}
+
+ public String[] getParamsNames() {
+ return paramNames;
+ }
}
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 c255ef4..4af9680 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
@@ -167,16 +167,29 @@
<c:simple-property name="operationResult" description="Outcome of stopping the JobTracker"/>
</results>
</operation>
- <operation name="job_list" displayName="Lists Running Jobs" description="Lists the currently running jobs.">
+ <operation name="job_list_running" 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="job_list_all" displayName="Lists All Jobs" description="Lists all jobs.">
+ <results>
+ <c:simple-property name="operationResult" description="Outcome of listing the all 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>
</operation>
+ <operation name="kill" displayName="Kill Running Job" description="Kills the specified running job.">
+ <parameters>
+ <c:simple-property name="pid"/>
+ </parameters>
+ <results>
+ <c:simple-property name="operationResult" description="Outcome of killing the job"/>
+ </results>
+ </operation>
<metric property="Hadoop:service=JobTracker,name=JobTrackerMetrics:jobs_completed" displayName="Jobs Completed"
displayType="summary"/>
More information about the rhq-commits
mailing list