hadoop-mapreduce-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jl...@apache.org
Subject svn commit: r1494293 - in /hadoop/common/branches/branch-0.23/hadoop-mapreduce-project: ./ hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/tools/ hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/te...
Date Tue, 18 Jun 2013 20:40:03 GMT
Author: jlowe
Date: Tue Jun 18 20:40:03 2013
New Revision: 1494293

URL: http://svn.apache.org/r1494293
Log:
MAPREDUCE-5316. job -list-attempt-ids command does not handle illegal task-state. Contributed
by Ashwin Shankar

Modified:
    hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/CHANGES.txt
    hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/tools/CLI.java
    hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapreduce/tools/TestCLI.java

Modified: hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/CHANGES.txt?rev=1494293&r1=1494292&r2=1494293&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/CHANGES.txt (original)
+++ hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/CHANGES.txt Tue Jun 18 20:40:03
2013
@@ -24,6 +24,9 @@ Release 0.23.9 - UNRELEASED
     MAPREDUCE-4019. -list-attempt-ids is not working (Ashwin Shankar,
     Devaraj K, and B Anil Kumar via jlowe)
 
+    MAPREDUCE-5316. job -list-attempt-ids command does not handle illegal
+    task-state (Ashwin Shankar via jlowe)
+
 Release 0.23.8 - 2013-06-05
 
   INCOMPATIBLE CHANGES

Modified: hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/tools/CLI.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/tools/CLI.java?rev=1494293&r1=1494292&r2=1494293&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/tools/CLI.java
(original)
+++ hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/tools/CLI.java
Tue Jun 18 20:40:03 2013
@@ -21,9 +21,9 @@ import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
-import java.util.HashSet;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
@@ -65,7 +65,9 @@ public class CLI extends Configured impl
   protected Cluster cluster;
   private static final Set<String> taskTypes = new HashSet<String>(
       Arrays.asList("MAP", "REDUCE"));
-
+  private final Set<String> taskStates = new HashSet<String>(Arrays.asList(
+      "running", "completed", "pending", "failed", "killed"));
+ 
   public CLI() {
   }
   
@@ -218,7 +220,12 @@ public class CLI extends Configured impl
       taskState = argv[3];
       displayTasks = true;
       if (!taskTypes.contains(taskType.toUpperCase())) {
-        System.out.println("Error: Invalid task-type: "+taskType);
+        System.out.println("Error: Invalid task-type: " + taskType);
+        displayUsage(cmd);
+        return exitCode;
+      }
+      if (!taskStates.contains(taskState.toLowerCase())) {
+        System.out.println("Error: Invalid task-state: " + taskState);
         displayUsage(cmd);
         return exitCode;
       }
@@ -566,11 +573,11 @@ public class CLI extends Configured impl
     TaskReport[] reports = job.getTaskReports(TaskType.valueOf(type.toUpperCase()));
     for (TaskReport report : reports) {
       TIPStatus status = report.getCurrentStatus();
-      if ((state.equals("pending") && status ==TIPStatus.PENDING) ||
-          (state.equals("running") && status ==TIPStatus.RUNNING) ||
-          (state.equals("completed") && status == TIPStatus.COMPLETE) ||
-          (state.equals("failed") && status == TIPStatus.FAILED) ||
-          (state.equals("killed") && status == TIPStatus.KILLED)) {
+      if ((state.equalsIgnoreCase("pending") && status ==TIPStatus.PENDING) ||
+          (state.equalsIgnoreCase("running") && status ==TIPStatus.RUNNING) ||
+          (state.equalsIgnoreCase("completed") && status == TIPStatus.COMPLETE) ||
+          (state.equalsIgnoreCase("failed") && status == TIPStatus.FAILED) ||
+          (state.equalsIgnoreCase("killed") && status == TIPStatus.KILLED)) {
         printTaskAttempts(report);
       }
     }

Modified: hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapreduce/tools/TestCLI.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapreduce/tools/TestCLI.java?rev=1494293&r1=1494292&r2=1494293&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapreduce/tools/TestCLI.java
(original)
+++ hadoop/common/branches/branch-0.23/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapreduce/tools/TestCLI.java
Tue Jun 18 20:40:03 2013
@@ -58,13 +58,19 @@ public class TestCLI {
     int retCode_REDUCE = cli.run(new String[] { "-list-attempt-ids", jobIdStr,
         "REDUCE", "running" });
 
+    int retCode_completed = cli.run(new String[] { "-list-attempt-ids",
+        jobIdStr, "REDUCE", "completed" });
+
     assertEquals("MAP is a valid input,exit code should be 0", 0, retCode_MAP);
     assertEquals("map is a valid input,exit code should be 0", 0, retCode_map);
     assertEquals("REDUCE is a valid input,exit code should be 0", 0,
         retCode_REDUCE);
+    assertEquals(
+        "REDUCE and completed are a valid inputs to -list-attempt-ids,exit code should be
0",
+        0, retCode_completed);
 
     verify(job, times(2)).getTaskReports(TaskType.MAP);
-    verify(job, times(1)).getTaskReports(TaskType.REDUCE);
+    verify(job, times(2)).getTaskReports(TaskType.REDUCE);
   }
 
   @Test
@@ -79,13 +85,19 @@ public class TestCLI {
 
     int retCode_JOB_SETUP = cli.run(new String[] { "-list-attempt-ids",
         jobIdStr, "JOB_SETUP", "running" });
+
     int retCode_JOB_CLEANUP = cli.run(new String[] { "-list-attempt-ids",
         jobIdStr, "JOB_CLEANUP", "running" });
 
-    assertEquals("JOB_SETUP is a invalid input,exit code should be -1", -1,
+    int retCode_invalidTaskState = cli.run(new String[] { "-list-attempt-ids",
+        jobIdStr, "REDUCE", "complete" });
+
+    assertEquals("JOB_SETUP is an invalid input,exit code should be -1", -1,
         retCode_JOB_SETUP);
-    assertEquals("JOB_CLEANUP is a invalid input,exit code should be -1", -1,
+    assertEquals("JOB_CLEANUP is an invalid input,exit code should be -1", -1,
         retCode_JOB_CLEANUP);
+    assertEquals("complete is an invalid input,exit code should be -1", -1,
+        retCode_invalidTaskState);
 
   }
 



Mime
View raw message