From acacde55e6a4488cd749eba630ff2e68c4dc5c63 Mon Sep 17 00:00:00 2001 From: Jitendra Nath Pandey Date: Tue, 7 Feb 2012 19:29:39 +0000 Subject: [PATCH] HDFS-2901. Improvements for SBN web UI - not show under-replicated/missing blocks. Contributed by Brandon Li. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-1623@1241568 13f79535-47bb-0310-9956-ffa450edef68 --- .../hadoop-hdfs/CHANGES.HDFS-1623.txt | 2 ++ .../server/namenode/NamenodeJspHelper.java | 18 +++++++++++++----- .../hdfs/server/namenode/ha/TestHAWebUI.java | 7 +++++-- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt index baeffd7bf3..8b10741ed4 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt @@ -178,3 +178,5 @@ HDFS-2894. HA: automatically determine the nameservice Id if only one nameservic HDFS-2733. Document HA configuration and CLI. (atm) HDFS-2794. Active NN may purge edit log files before standby NN has a chance to read them (todd) + +HDFS-2901. Improvements for SBN web UI - not show under-replicated/missing blocks. (Brandon Li via jitendra) 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 496423d4a6..6f81b94075 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 @@ -36,6 +36,7 @@ import javax.servlet.jsp.JspWriter; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.ha.HAServiceProtocol.HAServiceState; import org.apache.hadoop.hdfs.DFSConfigKeys; import org.apache.hadoop.hdfs.DFSUtil; import org.apache.hadoop.hdfs.protocol.Block; @@ -308,7 +309,16 @@ void generateHealthReport(JspWriter out, NameNode nn, long bpUsed = fsnStats[6]; float percentBpUsed = DFSUtil.getPercentUsed(bpUsed, total); - + + // don't show under-replicated/missing blocks or corrupt files for SBN + // since the standby namenode doesn't compute replication queues + String underReplicatedBlocks = ""; + if (nn.getServiceState() == HAServiceState.ACTIVE) { + underReplicatedBlocks = new String(rowTxt() + + colTxt("Excludes missing blocks.") + + "Number of Under-Replicated Blocks" + colTxt() + ":" + colTxt() + + fsn.getBlockManager().getUnderReplicatedNotMissingBlocks()); + } out.print("
\n" + rowTxt() + colTxt() + "Configured Capacity" + colTxt() + ":" + colTxt() + StringUtils.byteDesc(total) + rowTxt() + colTxt() + "DFS Used" @@ -343,10 +353,8 @@ void generateHealthReport(JspWriter out, NameNode nn, + rowTxt() + colTxt() + "" + "Decommissioning Nodes " - + colTxt() + ":" + colTxt() + decommissioning.size() - + rowTxt() + colTxt("Excludes missing blocks.") - + "Number of Under-Replicated Blocks" + colTxt() + ":" + colTxt() - + fsn.getBlockManager().getUnderReplicatedNotMissingBlocks() + + colTxt() + ":" + colTxt() + decommissioning.size() + + underReplicatedBlocks + "

\n"); if (live.isEmpty() && dead.isEmpty()) { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestHAWebUI.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestHAWebUI.java index ccb4f5b5cd..be01430117 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestHAWebUI.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestHAWebUI.java @@ -32,11 +32,11 @@ public class TestHAWebUI { /** * Tests that the web UI of the name node provides a link to browse the file - * system only in active state + * system and summary of under-replicated blocks only in active state * */ @Test - public void testLinkToBrowseFilesystem() throws Exception { + public void testLinkAndClusterSummary() throws Exception { Configuration conf = new Configuration(); MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf) @@ -50,18 +50,21 @@ public void testLinkToBrowseFilesystem() throws Exception { + NameNode.getHttpAddress(cluster.getConfiguration(0)).getPort() + "/dfshealth.jsp")); assertTrue(pageContents.contains("Browse the filesystem")); + assertTrue(pageContents.contains("Number of Under-Replicated Blocks")); cluster.transitionToStandby(0); pageContents = DFSTestUtil.urlGet(new URL("http://localhost:" + NameNode.getHttpAddress(cluster.getConfiguration(0)).getPort() + "/dfshealth.jsp")); assertFalse(pageContents.contains("Browse the filesystem")); + assertFalse(pageContents.contains("Number of Under-Replicated Blocks")); cluster.transitionToActive(0); pageContents = DFSTestUtil.urlGet(new URL("http://localhost:" + NameNode.getHttpAddress(cluster.getConfiguration(0)).getPort() + "/dfshealth.jsp")); assertTrue(pageContents.contains("Browse the filesystem")); + assertTrue(pageContents.contains("Number of Under-Replicated Blocks")); } finally { cluster.shutdown();