From b838ac89a673c465d96b71c9c5eae8e4e26b8608 Mon Sep 17 00:00:00 2001 From: Suresh Srinivas Date: Tue, 24 Sep 2013 05:31:02 +0000 Subject: [PATCH] HDFS-5251. Race between the initialization of NameNode and the http server. Contributed by Haohui Mai. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1525787 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../hdfs/server/namenode/NamenodeJspHelper.java | 4 ++++ .../server/namenode/TestNameNodeJspHelper.java | 14 ++++++++++++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index ac3bc726061..25db6583df4 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -327,6 +327,9 @@ Release 2.2.0 - UNRELEASED HDFS-5139. Remove redundant -R option from setrep. + HDFS-5251. Race between the initialization of NameNode and the http + server. (Haohui Mai via suresh) + Release 2.1.1-beta - 2013-09-23 INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NamenodeJspHelper.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NamenodeJspHelper.java index e2aa4fcf7c5..022c7ba0eae 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NamenodeJspHelper.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NamenodeJspHelper.java @@ -101,6 +101,10 @@ class NamenodeJspHelper { } static String getRollingUpgradeText(FSNamesystem fsn) { + if (fsn == null) { + return ""; + } + DatanodeManager dm = fsn.getBlockManager().getDatanodeManager(); Map list = dm.getDatanodesSoftwareVersions(); if(list.size() > 1) { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeJspHelper.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeJspHelper.java index 8119d662a6f..a847a9438a3 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeJspHelper.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeJspHelper.java @@ -18,8 +18,13 @@ package org.apache.hadoop.hdfs.server.namenode; -import static org.apache.hadoop.hdfs.server.namenode.startupprogress.Phase.*; -import static org.mockito.Mockito.*; +import static org.apache.hadoop.hdfs.server.namenode.startupprogress.Phase.LOADING_EDITS; +import static org.apache.hadoop.hdfs.server.namenode.startupprogress.Phase.LOADING_FSIMAGE; +import static org.apache.hadoop.hdfs.server.namenode.startupprogress.Phase.SAFEMODE; +import static org.apache.hadoop.hdfs.server.namenode.startupprogress.Phase.SAVING_CHECKPOINT; +import static org.mockito.Mockito.atLeastOnce; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; import java.io.IOException; import java.util.List; @@ -107,6 +112,11 @@ public class TestNameNodeJspHelper { Assert.assertTrue(containsMatch(contents, SAFEMODE.getDescription())); } + @Test + public void testGetRollingUpgradeText() { + Assert.assertEquals("", NamenodeJspHelper.getRollingUpgradeText(null)); + } + /** * Checks if the list contains any string that partially matches the regex. *