From e4ef7774b55a82dac99f1feedc5cbb0d3912ac89 Mon Sep 17 00:00:00 2001 From: Chris Nauroth Date: Fri, 7 Mar 2014 19:45:24 +0000 Subject: [PATCH] HDFS-5986. Merging change r1575384 from trunk to branch-2. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1575385 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../apache/hadoop/hdfs/server/namenode/FSNamesystem.java | 1 + .../hdfs/server/namenode/metrics/FSNamesystemMBean.java | 6 ++++++ .../hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html | 1 + .../hadoop/hdfs/server/namenode/TestFSNamesystemMBean.java | 6 +++++- 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 75a0ef36da8..d06eb7eb550 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -141,6 +141,9 @@ Release 2.4.0 - UNRELEASED HDFS-6061. Allow dfs.datanode.shared.file.descriptor.path to contain multiple entries and fall back when needed (cmccabe) + HDFS-5986. Capture the number of blocks pending deletion on namenode webUI. + (cnauroth) + OPTIMIZATIONS HDFS-5790. LeaseManager.findPath is very slow when many leases need recovery diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java index 555f8bdd92f..f96ce7eccf4 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java @@ -5501,6 +5501,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats, return blockManager.getScheduledReplicationBlocksCount(); } + @Override @Metric public long getPendingDeletionBlocks() { return blockManager.getPendingDeletionBlocksCount(); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/metrics/FSNamesystemMBean.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/metrics/FSNamesystemMBean.java index 340d9a3fce4..f02eb846930 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/metrics/FSNamesystemMBean.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/metrics/FSNamesystemMBean.java @@ -145,4 +145,10 @@ public interface FSNamesystemMBean { * Return the maximum number of inodes in the file system */ public long getMaxObjects(); + + /** + * Number of blocks pending deletion + * @return number of blocks pending deletion + */ + long getPendingDeletionBlocks(); } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html index 0df17b53889..0acd2c3abde 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html @@ -148,6 +148,7 @@ Dead Nodes{NumDeadDataNodes} (Decommissioned: {NumDecomDeadDataNodes}) Decommissioning Nodes{NumDecommissioningDataNodes} Number of Under-Replicated Blocks{UnderReplicatedBlocks} + Number of Blocks Pending Deletion{PendingDeletionBlocks} {/fs} diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSNamesystemMBean.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSNamesystemMBean.java index dcfd83ded68..db8f92e360c 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSNamesystemMBean.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSNamesystemMBean.java @@ -17,7 +17,7 @@ */ package org.apache.hadoop.hdfs.server.namenode; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; import java.lang.management.ManagementFactory; import java.util.Map; @@ -63,6 +63,10 @@ public class TestFSNamesystemMBean { assertTrue(stat.containsKey("Snapshots") && (Long) stat.get("Snapshots") == fsn.getNumSnapshots()); + Object pendingDeletionBlocks = mbs.getAttribute(mxbeanName, + "PendingDeletionBlocks"); + assertNotNull(pendingDeletionBlocks); + assertTrue(pendingDeletionBlocks instanceof Long); } finally { if (cluster != null) { cluster.shutdown();