HDFS-13115. In getNumUnderConstructionBlocks(), ignore the inodeIds for which the inodes have been deleted. Contributed by Yongjun Zhang.
This commit is contained in:
parent
b061215ecf
commit
f491f717e9
@ -144,7 +144,15 @@ synchronized long getNumUnderConstructionBlocks() {
|
||||
+ "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 {} in getNumUnderConstructionBlocks().",
|
||||
id);
|
||||
continue;
|
||||
}
|
||||
final INodeFile cons = inode.asFile();
|
||||
if (!cons.isUnderConstruction()) {
|
||||
LOG.warn("The file {} is not under construction but has lease.",
|
||||
cons.getFullPathName());
|
||||
@ -155,10 +163,11 @@ synchronized long getNumUnderConstructionBlocks() {
|
||||
continue;
|
||||
}
|
||||
for(BlockInfo b : blocks) {
|
||||
if(!b.isComplete())
|
||||
if(!b.isComplete()) {
|
||||
numUCBlocks++;
|
||||
}
|
||||
}
|
||||
}
|
||||
LOG.info("Number of blocks under construction: {}", numUCBlocks);
|
||||
return numUCBlocks;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user