You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mapreduce-commits@hadoop.apache.org by bo...@apache.org on 2012/05/04 17:02:55 UTC
svn commit: r1334013 - in /hadoop/common/trunk/hadoop-mapreduce-project: ./
hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/webapp/
hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/o...
Author: bobby
Date: Fri May 4 15:02:54 2012
New Revision: 1334013
URL: http://svn.apache.org/viewvc?rev=1334013&view=rev
Log:
MAPREDUCE-4048. NullPointerException exception while accessing the Application Master UI (Devaraj K via bobby)
Added:
hadoop/common/trunk/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAppController.java
Modified:
hadoop/common/trunk/hadoop-mapreduce-project/CHANGES.txt
hadoop/common/trunk/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/webapp/AppController.java
Modified: hadoop/common/trunk/hadoop-mapreduce-project/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-mapreduce-project/CHANGES.txt?rev=1334013&r1=1334012&r2=1334013&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-mapreduce-project/CHANGES.txt (original)
+++ hadoop/common/trunk/hadoop-mapreduce-project/CHANGES.txt Fri May 4 15:02:54 2012
@@ -452,6 +452,9 @@ Release 0.23.3 - UNRELEASED
MAPREDUCE-4163. consistently set the bind address (Daryn Sharp via bobby)
+ MAPREDUCE-4048. NullPointerException exception while accessing the
+ Application Master UI (Devaraj K via bobby)
+
Release 0.23.2 - UNRELEASED
INCOMPATIBLE CHANGES
Modified: hadoop/common/trunk/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/webapp/AppController.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/webapp/AppController.java?rev=1334013&r1=1334012&r2=1334013&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/webapp/AppController.java (original)
+++ hadoop/common/trunk/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/webapp/AppController.java Fri May 4 15:02:54 2012
@@ -27,6 +27,8 @@ import java.util.Locale;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.mapreduce.JobACL;
import org.apache.hadoop.mapreduce.v2.api.records.JobId;
@@ -47,6 +49,8 @@ import com.google.inject.Inject;
* This class renders the various pages that the web app supports.
*/
public class AppController extends Controller implements AMParams {
+ private static final Log LOG = LogFactory.getLog(AppController.class);
+
protected final App app;
protected AppController(App app, Configuration conf, RequestContext ctx,
@@ -220,6 +224,8 @@ public class AppController extends Contr
toString().toLowerCase(Locale.US));
setTitle(join(tt, " Tasks for ", $(JOB_ID)));
} catch (Exception e) {
+ LOG.error("Failed to render tasks page with task type : "
+ + $(TASK_TYPE) + " for job id : " + $(JOB_ID), e);
badRequest(e.getMessage());
}
}
@@ -283,6 +289,8 @@ public class AppController extends Contr
render(attemptsPage());
} catch (Exception e) {
+ LOG.error("Failed to render attempts page with task type : "
+ + $(TASK_TYPE) + " for job id : " + $(JOB_ID), e);
badRequest(e.getMessage());
}
}
@@ -316,7 +324,8 @@ public class AppController extends Contr
*/
void badRequest(String s) {
setStatus(HttpServletResponse.SC_BAD_REQUEST);
- setTitle(join("Bad request: ", s));
+ String title = "Bad request: ";
+ setTitle((s != null) ? join(title, s) : title);
}
/**
Added: hadoop/common/trunk/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAppController.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAppController.java?rev=1334013&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAppController.java (added)
+++ hadoop/common/trunk/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/webapp/TestAppController.java Fri May 4 15:02:54 2012
@@ -0,0 +1,71 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.mapreduce.v2.app.webapp;
+
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.mapreduce.v2.app.AppContext;
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.util.Records;
+import org.apache.hadoop.yarn.webapp.Controller.RequestContext;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestAppController {
+
+ private AppController appController;
+ private RequestContext ctx;
+
+ @Before
+ public void setUp() {
+ AppContext context = mock(AppContext.class);
+ when(context.getApplicationID()).thenReturn(
+ Records.newRecord(ApplicationId.class));
+ App app = new App(context);
+ Configuration conf = new Configuration();
+ ctx = mock(RequestContext.class);
+ appController = new AppController(app, conf, ctx);
+ }
+
+ @Test
+ public void testBadRequest() {
+ String message = "test string";
+ appController.badRequest(message);
+ verifyExpectations(message);
+ }
+
+ @Test
+ public void testBadRequestWithNullMessage() {
+ // It should not throw NullPointerException
+ appController.badRequest(null);
+ verifyExpectations(StringUtils.EMPTY);
+ }
+
+ private void verifyExpectations(String message) {
+ verify(ctx).setStatus(400);
+ verify(ctx).set("app.id", "application_0_0000");
+ verify(ctx).set(eq("rm.web"), anyString());
+ verify(ctx).set("title", "Bad request: " + message);
+ }
+}