hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From deva...@apache.org
Subject hadoop git commit: MAPREDUCE-6405. NullPointerException in App Attempts page. Contributed by Siqi Li and Gera Shegalov.
Date Sat, 20 Jun 2015 05:08:35 GMT
Repository: hadoop
Updated Branches:
  refs/heads/trunk d112d1832 -> 311a4179c


MAPREDUCE-6405. NullPointerException in App Attempts page.  Contributed by
Siqi Li and Gera Shegalov.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/311a4179
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/311a4179
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/311a4179

Branch: refs/heads/trunk
Commit: 311a4179cc53a2754d1185b1cb10e6adb1b95d3d
Parents: d112d18
Author: Devaraj K <devaraj@apache.org>
Authored: Sat Jun 20 10:35:04 2015 +0530
Committer: Devaraj K <devaraj@apache.org>
Committed: Sat Jun 20 10:35:04 2015 +0530

----------------------------------------------------------------------
 hadoop-mapreduce-project/CHANGES.txt            |  3 +
 .../mapreduce/v2/app/webapp/TaskPage.java       | 82 +++++++++++---------
 2 files changed, 49 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/311a4179/hadoop-mapreduce-project/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt
index 7e57804..dfac028 100644
--- a/hadoop-mapreduce-project/CHANGES.txt
+++ b/hadoop-mapreduce-project/CHANGES.txt
@@ -483,6 +483,9 @@ Release 2.8.0 - UNRELEASED
     MAPREDUCE-6373. The logger reports total input paths but it is referring
     to input files. (Bibin A Chundatt via devaraj)
 
+    MAPREDUCE-6405. NullPointerException in App Attempts page.
+    (Siqi Li and Gera Shegalov via devaraj)
+
 Release 2.7.1 - UNRELEASED
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/311a4179/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/webapp/TaskPage.java
----------------------------------------------------------------------
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/webapp/TaskPage.java
b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/webapp/TaskPage.java
index 758b02c..d9f17c8 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/webapp/TaskPage.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/webapp/TaskPage.java
@@ -24,11 +24,14 @@ import static org.apache.hadoop.yarn.webapp.view.JQueryUI.DATATABLES_ID;
 import static org.apache.hadoop.yarn.webapp.view.JQueryUI.initID;
 import static org.apache.hadoop.yarn.webapp.view.JQueryUI.tableInit;
 
+import java.util.EnumSet;
 import java.util.Collection;
 
 import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.mapreduce.MRConfig;
+import org.apache.hadoop.mapreduce.v2.api.records.JobId;
+import org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptState;
 import org.apache.hadoop.mapreduce.v2.app.job.TaskAttempt;
 import org.apache.hadoop.mapreduce.v2.app.webapp.dao.TaskAttemptInfo;
 import org.apache.hadoop.mapreduce.v2.util.MRWebAppUtil;
@@ -48,7 +51,6 @@ public class TaskPage extends AppView {
   static class AttemptsBlock extends HtmlBlock {
     final App app;
     final boolean enableUIActions;
-    private String stateURLFormat;
 
     @Inject
     AttemptsBlock(App ctx, Configuration conf) {
@@ -66,37 +68,36 @@ public class TaskPage extends AppView {
         return;
       }
 
+      JobId jobId = app.getJob().getID();
       if (enableUIActions) {
         // Kill task attempt
-        String appID = app.getJob().getID().getAppId().toString();
-        String jobID = app.getJob().getID().toString();
-        String taskID = app.getTask().getID().toString();
-        stateURLFormat =
-            String.format("/proxy/%s/ws/v1/mapreduce/jobs/%s/tasks/%s/"
-                + "attempts", appID, jobID, taskID) + "/%s/state";
-
-        String current =
-            String.format("/proxy/%s/mapreduce/task/%s", appID, taskID);
 
         StringBuilder script = new StringBuilder();
-        script.append("function confirmAction(stateURL) {")
-            .append(" b = confirm(\"Are you sure?\");")
-            .append(" if (b == true) {")
-            .append(" $.ajax({")
-            .append(" type: 'PUT',")
-            .append(" url: stateURL,")
-            .append(" contentType: 'application/json',")
-            .append(" data: '{\"state\":\"KILLED\"}',")
-            .append(" dataType: 'json'")
-            .append(" }).done(function(data){")
-            .append(" setTimeout(function(){")
-            .append(" location.href = '").append(current).append("';")
-            .append(" }, 1000);")
-            .append(" }).fail(function(data){")
-            .append(" console.log(data);")
-            .append(" });")
-            .append(" }")
-            .append("}");
+        script
+            .append("function confirmAction(appID, jobID, taskID, attID) {\n")
+            .append("  var b = confirm(\"Are you sure?\");\n")
+            .append("  if (b == true) {\n")
+            .append("    var current = '/proxy/' + appID")
+            .append("      + '/mapreduce/task/' + taskID;\n")
+            .append("    var stateURL = '/proxy/' + appID")
+            .append("      + '/ws/v1/mapreduce/jobs/' + jobID")
+            .append("      + '/tasks/' + taskID")
+            .append("      + '/attempts/' + attID + '/state';\n")
+            .append("    $.ajax({\n")
+            .append("      type: 'PUT',\n")
+            .append("      url: stateURL,\n")
+            .append("      contentType: 'application/json',\n")
+            .append("      data: '{\"state\":\"KILLED\"}',\n")
+            .append("      dataType: 'json'\n")
+            .append("    }).done(function(data) {\n")
+            .append("         setTimeout(function() {\n")
+            .append("           location.href = current;\n")
+            .append("         }, 1000);\n")
+            .append("    }).fail(function(data) {\n")
+            .append("         console.log(data);\n")
+            .append("    });\n")
+            .append("  }\n")
+            .append("}\n");
 
         html.script().$type("text/javascript")._(script.toString())._();
       }
@@ -135,8 +136,8 @@ public class TaskPage extends AppView {
               StringEscapeUtils.escapeHtml(ta.getStatus()))).append("\",\"")
 
         .append(nodeHttpAddr == null ? "N/A" :
-          "<a class='nodelink' href='" + MRWebAppUtil.getYARNWebappScheme() + nodeHttpAddr
+ "'>"
-          + nodeHttpAddr + "</a>")
+            "<a class='nodelink' href='" + MRWebAppUtil.getYARNWebappScheme() + nodeHttpAddr
+ "'>"
+                + nodeHttpAddr + "</a>")
         .append("\",\"")
 
         .append(ta.getAssignedContainerId() == null ? "N/A" :
@@ -151,12 +152,21 @@ public class TaskPage extends AppView {
         .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(
           diag)));
         if (enableUIActions) {
-          attemptsTableData.append("\",\"")
-          .append("<a href=javascript:void(0) onclick=confirmAction('")
-          .append(String.format(stateURLFormat, ta.getId()))
-          .append("');>Kill</a>")
-          .append("\"],\n");
-        } else {
+          attemptsTableData.append("\",\"");
+          if (EnumSet.of(
+                  TaskAttemptState.SUCCEEDED,
+                  TaskAttemptState.FAILED,
+                  TaskAttemptState.KILLED).contains(attempt.getState())) {
+            attemptsTableData.append("N/A");
+          } else {
+            attemptsTableData
+              .append("<a href=javascript:void(0) onclick=confirmAction('")
+              .append(jobId.getAppId()).append("','")
+              .append(jobId).append("','")
+              .append(attempt.getID().getTaskId()).append("','")
+              .append(ta.getId())
+              .append("');>Kill</a>");
+          }
           attemptsTableData.append("\"],\n");
         }
       }


Mime
View raw message