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
This commit is contained in:
Jitendra Nath Pandey 2012-02-07 19:29:39 +00:00
parent 7f0a99f6e6
commit acacde55e6
3 changed files with 20 additions and 7 deletions

View File

@ -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-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-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)

View File

@ -36,6 +36,7 @@ import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.JspWriter; import javax.servlet.jsp.JspWriter;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.ha.HAServiceProtocol.HAServiceState;
import org.apache.hadoop.hdfs.DFSConfigKeys; import org.apache.hadoop.hdfs.DFSConfigKeys;
import org.apache.hadoop.hdfs.DFSUtil; import org.apache.hadoop.hdfs.DFSUtil;
import org.apache.hadoop.hdfs.protocol.Block; import org.apache.hadoop.hdfs.protocol.Block;
@ -308,7 +309,16 @@ class NamenodeJspHelper {
long bpUsed = fsnStats[6]; long bpUsed = fsnStats[6];
float percentBpUsed = DFSUtil.getPercentUsed(bpUsed, total); 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("<div id=\"dfstable\"> <table>\n" + rowTxt() + colTxt() out.print("<div id=\"dfstable\"> <table>\n" + rowTxt() + colTxt()
+ "Configured Capacity" + colTxt() + ":" + colTxt() + "Configured Capacity" + colTxt() + ":" + colTxt()
+ StringUtils.byteDesc(total) + rowTxt() + colTxt() + "DFS Used" + StringUtils.byteDesc(total) + rowTxt() + colTxt() + "DFS Used"
@ -343,10 +353,8 @@ class NamenodeJspHelper {
+ rowTxt() + colTxt() + rowTxt() + colTxt()
+ "<a href=\"dfsnodelist.jsp?whatNodes=DECOMMISSIONING\">" + "<a href=\"dfsnodelist.jsp?whatNodes=DECOMMISSIONING\">"
+ "Decommissioning Nodes</a> " + "Decommissioning Nodes</a> "
+ colTxt() + ":" + colTxt() + decommissioning.size() + colTxt() + ":" + colTxt() + decommissioning.size()
+ rowTxt() + colTxt("Excludes missing blocks.") + underReplicatedBlocks
+ "Number of Under-Replicated Blocks" + colTxt() + ":" + colTxt()
+ fsn.getBlockManager().getUnderReplicatedNotMissingBlocks()
+ "</table></div><br>\n"); + "</table></div><br>\n");
if (live.isEmpty() && dead.isEmpty()) { if (live.isEmpty() && dead.isEmpty()) {

View File

@ -32,11 +32,11 @@ public class TestHAWebUI {
/** /**
* Tests that the web UI of the name node provides a link to browse the file * 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 @Test
public void testLinkToBrowseFilesystem() throws Exception { public void testLinkAndClusterSummary() throws Exception {
Configuration conf = new Configuration(); Configuration conf = new Configuration();
MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf) MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf)
@ -50,18 +50,21 @@ public class TestHAWebUI {
+ NameNode.getHttpAddress(cluster.getConfiguration(0)).getPort() + NameNode.getHttpAddress(cluster.getConfiguration(0)).getPort()
+ "/dfshealth.jsp")); + "/dfshealth.jsp"));
assertTrue(pageContents.contains("Browse the filesystem")); assertTrue(pageContents.contains("Browse the filesystem"));
assertTrue(pageContents.contains("Number of Under-Replicated Blocks"));
cluster.transitionToStandby(0); cluster.transitionToStandby(0);
pageContents = DFSTestUtil.urlGet(new URL("http://localhost:" pageContents = DFSTestUtil.urlGet(new URL("http://localhost:"
+ NameNode.getHttpAddress(cluster.getConfiguration(0)).getPort() + NameNode.getHttpAddress(cluster.getConfiguration(0)).getPort()
+ "/dfshealth.jsp")); + "/dfshealth.jsp"));
assertFalse(pageContents.contains("Browse the filesystem")); assertFalse(pageContents.contains("Browse the filesystem"));
assertFalse(pageContents.contains("Number of Under-Replicated Blocks"));
cluster.transitionToActive(0); cluster.transitionToActive(0);
pageContents = DFSTestUtil.urlGet(new URL("http://localhost:" pageContents = DFSTestUtil.urlGet(new URL("http://localhost:"
+ NameNode.getHttpAddress(cluster.getConfiguration(0)).getPort() + NameNode.getHttpAddress(cluster.getConfiguration(0)).getPort()
+ "/dfshealth.jsp")); + "/dfshealth.jsp"));
assertTrue(pageContents.contains("Browse the filesystem")); assertTrue(pageContents.contains("Browse the filesystem"));
assertTrue(pageContents.contains("Number of Under-Replicated Blocks"));
} finally { } finally {
cluster.shutdown(); cluster.shutdown();