Browse Source

HDFS-2567. When 0 DNs are available, show a proper error when trying to browse DFS via web UI. Contributed by Harsh J

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1204131 13f79535-47bb-0310-9956-ffa450edef68
Eli Collins 13 years ago
parent
commit
5573b691d5

+ 3 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

@@ -152,6 +152,9 @@ Release 0.23.1 - UNRELEASED
 
     HDFS-2502. hdfs-default.xml should include dfs.name.dir.restore.
     (harsh via eli)
+
+    HDFS-2567. When 0 DNs are available, show a proper error when
+    trying to browse DFS via web UI. (harsh via eli)
     
 Release 0.23.0 - 2011-11-01 
 

+ 7 - 1
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NamenodeJspHelper.java

@@ -380,7 +380,13 @@ class NamenodeJspHelper {
     final NameNode nn = NameNodeHttpServer.getNameNodeFromContext(context);
     final Configuration conf = (Configuration) context
         .getAttribute(JspHelper.CURRENT_CONF);
-    final DatanodeID datanode = getRandomDatanode(nn);
+    // We can't redirect if there isn't a DN to redirect to.
+    // Lets instead show a proper error message.
+    if (nn.getNamesystem().getNumLiveDataNodes() < 1) {
+      throw new IOException("Can't browse the DFS since there are no " +
+          "live nodes available to redirect to.");
+    }
+    final DatanodeID datanode = getRandomDatanode(nn);;
     UserGroupInformation ugi = JspHelper.getUGI(context, request, conf);
     String tokenString = getDelegationToken(
         nn.getRpcServer(), request, conf, ugi);