From 5573b691d519ea0e1d7d2a0ad43a795c548dc99f Mon Sep 17 00:00:00 2001 From: Eli Collins Date: Sun, 20 Nov 2011 06:28:37 +0000 Subject: [PATCH] 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 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../hadoop/hdfs/server/namenode/NamenodeJspHelper.java | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 25f5a28e08b..c1ce60ebd85 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/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 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 3d2fd8b0be2..496423d4a67 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 @@ -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);