hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aengin...@apache.org
Subject [25/40] hadoop git commit: YARN-4810. NM applicationpage cause internal error 500. Contributed by Bibin A Chundatt.
Date Thu, 14 Apr 2016 06:15:32 GMT
YARN-4810. NM applicationpage cause internal error 500. Contributed by Bibin A Chundatt.


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

Branch: refs/heads/HDFS-7240
Commit: 437e9d6475a91cafc4c993b206312912b5f13ad9
Parents: 209303b
Author: Naganarasimha <naganarasimha_gr@apache.org>
Authored: Tue Apr 12 17:59:46 2016 +0530
Committer: Naganarasimha <naganarasimha_gr@apache.org>
Committed: Tue Apr 12 17:59:46 2016 +0530

----------------------------------------------------------------------
 .../nodemanager/webapp/ApplicationPage.java     | 18 +++-
 .../nodemanager/webapp/TestNMAppsPage.java      | 86 ++++++++++++++++++++
 2 files changed, 101 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/437e9d64/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/ApplicationPage.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/ApplicationPage.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/ApplicationPage.java
index 1a92491..bc90d8e 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/ApplicationPage.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/ApplicationPage.java
@@ -34,6 +34,7 @@ import org.apache.hadoop.yarn.util.ConverterUtils;
 import org.apache.hadoop.yarn.webapp.SubView;
 import org.apache.hadoop.yarn.webapp.YarnWebParams;
 import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
+import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.DIV;
 import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE;
 import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
 import org.apache.hadoop.yarn.webapp.view.InfoBlock;
@@ -75,10 +76,21 @@ public class ApplicationPage extends NMView implements YarnWebParams {
 
     @Override
     protected void render(Block html) {
-      ApplicationId applicationID =
-          ConverterUtils.toApplicationId(this.recordFactory,
-              $(APPLICATION_ID));
+      ApplicationId applicationID = null;
+      try {
+        applicationID = ConverterUtils.toApplicationId(this.recordFactory,
+            $(APPLICATION_ID));
+      } catch (IllegalArgumentException e) {
+        html.p()._("Invalid Application Id " + $(APPLICATION_ID))._();
+        return;
+      }
+      DIV<Hamlet> div = html.div("#content");
       Application app = this.nmContext.getApplications().get(applicationID);
+      if (app == null) {
+        div.h1("Unknown application with id " + applicationID
+            + ". Application might have been completed")._();
+        return;
+      }
       AppInfo info = new AppInfo(app);
       info("Application's information")
             ._("ApplicationId", info.getId())

http://git-wip-us.apache.org/repos/asf/hadoop/blob/437e9d64/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMAppsPage.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMAppsPage.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMAppsPage.java
new file mode 100644
index 0000000..e64d43c
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMAppsPage.java
@@ -0,0 +1,86 @@
+/**
+ * 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.yarn.server.nodemanager.webapp;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.yarn.server.nodemanager.Context;
+import org.apache.hadoop.yarn.server.nodemanager.NodeManager;
+import org.apache.hadoop.yarn.server.nodemanager.NodeManager.NMContext;
+import org.apache.hadoop.yarn.server.nodemanager.recovery.NMNullStateStoreService;
+import org.apache.hadoop.yarn.server.nodemanager.security.NMContainerTokenSecretManager;
+import org.apache.hadoop.yarn.server.nodemanager.security.NMTokenSecretManagerInNM;
+import org.apache.hadoop.yarn.server.nodemanager.webapp.ApplicationPage.ApplicationBlock;
+import org.apache.hadoop.yarn.server.security.ApplicationACLsManager;
+import org.apache.hadoop.yarn.webapp.YarnWebParams;
+import org.apache.hadoop.yarn.webapp.test.WebAppTests;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import com.google.inject.Binder;
+import com.google.inject.Injector;
+import com.google.inject.Module;
+
+@RunWith(Parameterized.class)
+public class TestNMAppsPage {
+
+  String applicationid;
+
+  public TestNMAppsPage(String appid) {
+    this.applicationid = appid;
+  }
+
+  @Parameterized.Parameters
+  public static Collection<Object[]> getAppIds() {
+    return Arrays.asList(new Object[][] { { "appid" },
+        { "application_123123213_0001" }, { "" } });
+  }
+
+  @Test
+  public void testNMAppsPage() {
+    Configuration conf = new Configuration();
+    final NMContext nmcontext = new NMContext(
+        new NMContainerTokenSecretManager(conf), new NMTokenSecretManagerInNM(),
+        null, new ApplicationACLsManager(conf), new NMNullStateStoreService());
+    Injector injector = WebAppTests.createMockInjector(NMContext.class,
+        nmcontext, new Module() {
+          @Override
+          public void configure(Binder binder) {
+            NodeManager nm = TestNMAppsPage.mocknm(nmcontext);
+            binder.bind(NodeManager.class).toInstance(nm);
+            binder.bind(Context.class).toInstance(nmcontext);
+          }
+        });
+    ApplicationBlock instance = injector.getInstance(ApplicationBlock.class);
+    instance.set(YarnWebParams.APPLICATION_ID, applicationid);
+    instance.render();
+  }
+
+  protected static NodeManager mocknm(NMContext nmcontext) {
+    NodeManager rm = mock(NodeManager.class);
+    when(rm.getNMContext()).thenReturn(nmcontext);
+    return rm;
+  }
+
+}


Mime
View raw message