You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by yj...@apache.org on 2018/02/07 23:21:47 UTC

[2/2] hadoop git commit: HDFS-13115. In getNumUnderConstructionBlocks(), ignore the inodeIds for which the inodes have been deleted. Contributed by Yongjun Zhang. (cherry picked from commit f491f717e9ee6b75ad5cfca48da9c6297e94a8f7)

HDFS-13115. In getNumUnderConstructionBlocks(), ignore the inodeIds for which the inodes have been deleted. Contributed by Yongjun Zhang.
(cherry picked from commit f491f717e9ee6b75ad5cfca48da9c6297e94a8f7)

Conflicts:

	hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/LeaseManager.java


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/60d82ac6
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/60d82ac6
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/60d82ac6

Branch: refs/heads/branch-3.0.1
Commit: 60d82ac61f2afa2a61c8eeabf20e45b5a89311d0
Parents: 8217299
Author: Yongjun Zhang <yz...@cloudera.com>
Authored: Wed Feb 7 14:19:18 2018 -0800
Committer: Yongjun Zhang <yz...@cloudera.com>
Committed: Wed Feb 7 15:12:29 2018 -0800

----------------------------------------------------------------------
 .../hadoop/hdfs/server/namenode/LeaseManager.java      | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/60d82ac6/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/LeaseManager.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/LeaseManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/LeaseManager.java
index 29b4fe1..47e0891 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/LeaseManager.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/LeaseManager.java
@@ -142,7 +142,15 @@ public class LeaseManager {
       + "acquired before counting under construction blocks";
     long numUCBlocks = 0;
     for (Long id : getINodeIdWithLeases()) {
-      final INodeFile cons = fsnamesystem.getFSDirectory().getInode(id).asFile();
+      INode inode = fsnamesystem.getFSDirectory().getInode(id);
+      if (inode == null) {
+        // The inode could have been deleted after getINodeIdWithLeases() is
+        // called, check here, and ignore it if so
+        LOG.warn("Failed to find inode " + id +
+            " in getNumUnderConstructionBlocks().");
+        continue;
+      }
+      final INodeFile cons = inode.asFile();
       if (!cons.isUnderConstruction()) {
         LOG.warn("The file " + cons.getFullPathName()
             + " is not under construction but has lease.");
@@ -153,10 +161,11 @@ public class LeaseManager {
         continue;
       }
       for(BlockInfo b : blocks) {
-        if(!b.isComplete())
+        if(!b.isComplete()) {
           numUCBlocks++;
         }
       }
+    }
     LOG.info("Number of blocks under construction: " + numUCBlocks);
     return numUCBlocks;
   }


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org