Block blockWithWildcardGenstamp = new Block(block.getBlockId());
BlockInfo storedBlock = blocksMap.getStoredBlock(blockWithWildcardGenstamp);
if (storedBlock == null) {
String msg = block + " is already commited, storedBlock == null.";
LOG.info(msg);
throw new BlockAlreadyCommittedException(msg);
}
INodeFile fileINode = storedBlock.getINode();
if (!fileINode.isUnderConstruction()) {
String msg = block + " is already commited, !fileINode.isUnderConstruction().";
LOG.info(msg);
throw new BlockAlreadyCommittedException(msg);
}
// Disallow client-initiated recovery once
// NameNode initiated lease recovery starts
String path = null;
try {
path = fileINode.getFullPathName();
} catch (IOException ioe) {
throw (BlockAlreadyCommittedException)
new BlockAlreadyCommittedException(
block + " is already deleted").initCause(ioe);
}
if (!fromNN && HdfsConstants.NN_RECOVERY_LEASEHOLDER.equals(
leaseManager.getLeaseByPath(path).getHolder())) {
String msg = block +