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

This commit is contained in:
Yongjun Zhang 2018-02-07 12:58:09 -08:00
parent b061215ecf
commit f491f717e9
1 changed files with 11 additions and 2 deletions

View File

@ -144,7 +144,15 @@ public class LeaseManager {
+ "acquired before counting under construction blocks"; + "acquired before counting under construction blocks";
long numUCBlocks = 0; long numUCBlocks = 0;
for (Long id : getINodeIdWithLeases()) { 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 {} in getNumUnderConstructionBlocks().",
id);
continue;
}
final INodeFile cons = inode.asFile();
if (!cons.isUnderConstruction()) { if (!cons.isUnderConstruction()) {
LOG.warn("The file {} is not under construction but has lease.", LOG.warn("The file {} is not under construction but has lease.",
cons.getFullPathName()); cons.getFullPathName());
@ -155,10 +163,11 @@ public class LeaseManager {
continue; continue;
} }
for(BlockInfo b : blocks) { for(BlockInfo b : blocks) {
if(!b.isComplete()) if(!b.isComplete()) {
numUCBlocks++; numUCBlocks++;
} }
} }
}
LOG.info("Number of blocks under construction: {}", numUCBlocks); LOG.info("Number of blocks under construction: {}", numUCBlocks);
return numUCBlocks; return numUCBlocks;
} }