MAPREDUCE-2944. Improve checking of input for JobClient.displayTasks() (XieXianshan via harsh)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1225188 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9eb87574a3
commit
a9ffbdd0d7
|
@ -49,6 +49,8 @@ Trunk (unreleased changes)
|
||||||
Move the support for multiple protocols to lower layer so that Writable,
|
Move the support for multiple protocols to lower layer so that Writable,
|
||||||
PB and Avro can all use it (Sanjay)
|
PB and Avro can all use it (Sanjay)
|
||||||
|
|
||||||
|
MAPREDUCE-2944. Improve checking of input for JobClient.displayTasks() (XieXianshan via harsh)
|
||||||
|
|
||||||
BUG FIXES
|
BUG FIXES
|
||||||
MAPREDUCE-3349. Log rack-name in JobHistory for unsuccessful tasks.
|
MAPREDUCE-3349. Log rack-name in JobHistory for unsuccessful tasks.
|
||||||
(Devaraj K and Amar Kamat via amarrk)
|
(Devaraj K and Amar Kamat via amarrk)
|
||||||
|
|
|
@ -723,6 +723,8 @@ public class JobClient extends CLI {
|
||||||
* @param type the type of the task (map/reduce/setup/cleanup)
|
* @param type the type of the task (map/reduce/setup/cleanup)
|
||||||
* @param state the state of the task
|
* @param state the state of the task
|
||||||
* (pending/running/completed/failed/killed)
|
* (pending/running/completed/failed/killed)
|
||||||
|
* @throws IOException when there is an error communicating with the master
|
||||||
|
* @throws IllegalArgumentException if an invalid type/state is passed
|
||||||
*/
|
*/
|
||||||
public void displayTasks(final JobID jobId, String type, String state)
|
public void displayTasks(final JobID jobId, String type, String state)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
|
@ -20,6 +20,9 @@ package org.apache.hadoop.mapreduce.tools;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
@ -56,6 +59,10 @@ import org.apache.hadoop.yarn.logaggregation.LogDumper;
|
||||||
public class CLI extends Configured implements Tool {
|
public class CLI extends Configured implements Tool {
|
||||||
private static final Log LOG = LogFactory.getLog(CLI.class);
|
private static final Log LOG = LogFactory.getLog(CLI.class);
|
||||||
protected Cluster cluster;
|
protected Cluster cluster;
|
||||||
|
private final Set<String> taskTypes = new HashSet<String>(
|
||||||
|
Arrays.asList("map", "reduce", "setup", "cleanup"));
|
||||||
|
private final Set<String> taskStates = new HashSet<String>(
|
||||||
|
Arrays.asList("pending", "running", "completed", "failed", "killed"));
|
||||||
|
|
||||||
public CLI() {
|
public CLI() {
|
||||||
}
|
}
|
||||||
|
@ -545,9 +552,21 @@ public class CLI extends Configured implements Tool {
|
||||||
* @param type the type of the task (map/reduce/setup/cleanup)
|
* @param type the type of the task (map/reduce/setup/cleanup)
|
||||||
* @param state the state of the task
|
* @param state the state of the task
|
||||||
* (pending/running/completed/failed/killed)
|
* (pending/running/completed/failed/killed)
|
||||||
|
* @throws IOException when there is an error communicating with the master
|
||||||
|
* @throws InterruptedException
|
||||||
|
* @throws IllegalArgumentException if an invalid type/state is passed
|
||||||
*/
|
*/
|
||||||
protected void displayTasks(Job job, String type, String state)
|
protected void displayTasks(Job job, String type, String state)
|
||||||
throws IOException, InterruptedException {
|
throws IOException, InterruptedException {
|
||||||
|
if (!taskTypes.contains(type)) {
|
||||||
|
throw new IllegalArgumentException("Invalid type: " + type +
|
||||||
|
". Valid types for task are: map, reduce, setup, cleanup.");
|
||||||
|
}
|
||||||
|
if (!taskStates.contains(state)) {
|
||||||
|
throw new java.lang.IllegalArgumentException("Invalid state: " + state +
|
||||||
|
". Valid states for task are: pending, running, completed, failed, killed.");
|
||||||
|
}
|
||||||
|
|
||||||
TaskReport[] reports = job.getTaskReports(TaskType.valueOf(type));
|
TaskReport[] reports = job.getTaskReports(TaskType.valueOf(type));
|
||||||
for (TaskReport report : reports) {
|
for (TaskReport report : reports) {
|
||||||
TIPStatus status = report.getCurrentStatus();
|
TIPStatus status = report.getCurrentStatus();
|
||||||
|
|
Loading…
Reference in New Issue