From ca2265b581a0eccbd366a9a1b504a61eb67d23df Mon Sep 17 00:00:00 2001 From: Jason Darrell Lowe Date: Fri, 17 May 2013 20:19:48 +0000 Subject: [PATCH] MAPREDUCE-4927. Historyserver 500 error due to NPE when accessing specific counters page for failed job. Contributed by Ashwin Shankar git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1483974 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-mapreduce-project/CHANGES.txt | 6 ++++++ .../hadoop/mapreduce/v2/app/webapp/SingleCounterBlock.java | 5 +++-- .../apache/hadoop/mapreduce/v2/app/webapp/TestAMWebApp.java | 5 +++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt index a1a4f6c892..337144af92 100644 --- a/hadoop-mapreduce-project/CHANGES.txt +++ b/hadoop-mapreduce-project/CHANGES.txt @@ -426,6 +426,9 @@ Release 2.0.5-beta - UNRELEASED MAPREDUCE-5244. Two functions changed their visibility in JobStatus. (zjshen via tucu) + MAPREDUCE-4927. Historyserver 500 error due to NPE when accessing specific + counters page for failed job. (Ashwin Shankar via jlowe) + Release 2.0.4-alpha - 2013-04-25 INCOMPATIBLE CHANGES @@ -991,6 +994,9 @@ Release 0.23.8 - UNRELEASED MAPREDUCE-5147. Maven build should create hadoop-mapreduce-client-app-VERSION.jar directly (Robert Parker via tgraves) + MAPREDUCE-4927. Historyserver 500 error due to NPE when accessing specific + counters page for failed job. (Ashwin Shankar via jlowe) + Release 0.23.7 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/webapp/SingleCounterBlock.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/webapp/SingleCounterBlock.java index cf083ccb27..974b3ff8f8 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/webapp/SingleCounterBlock.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/webapp/SingleCounterBlock.java @@ -143,8 +143,9 @@ private void populateMembers(AppContext ctx) { Map tasks = job.getTasks(); for(Map.Entry entry : tasks.entrySet()) { long value = 0; - CounterGroup group = entry.getValue().getCounters() - .getGroup($(COUNTER_GROUP)); + Counters counters = entry.getValue().getCounters(); + CounterGroup group = (counters != null) ? counters + .getGroup($(COUNTER_GROUP)) : null; if(group != null) { Counter c = group.findCounter($(COUNTER_NAME)); if(c != null) { diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAMWebApp.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAMWebApp.java index fdf650d647..7622a9ab95 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAMWebApp.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAMWebApp.java @@ -182,6 +182,11 @@ public static Map getTaskParams(AppContext appContext) { @Test public void testSingleCounterView() { AppContext appContext = new TestAppContext(); + Job job = appContext.getAllJobs().values().iterator().next(); + // add a failed task to the job without any counters + Task failedTask = MockJobs.newTask(job.getID(), 2, 1, true); + Map tasks = job.getTasks(); + tasks.put(failedTask.getID(), failedTask); Map params = getJobParams(appContext); params.put(AMParams.COUNTER_GROUP, "org.apache.hadoop.mapreduce.FileSystemCounter");