}
}
private void transferBlock(int namespaceId, Block block,
DatanodeInfo xferTargets[]) throws IOException {
DatanodeProtocol nn = getNSNamenode(namespaceId);
DatanodeRegistration nsReg = getDNRegistrationForNS(namespaceId);
if (!data.isValidBlock(namespaceId, block, true)) {
// block does not exist or is under-construction
String errStr = "Can't send invalid block " + block;
LOG.info(errStr);
nn.errorReport(nsReg, DatanodeProtocol.INVALID_BLOCK, errStr);
return;
}
// Check if NN recorded length matches on-disk length
long onDiskLength = data.getFinalizedBlockLength(namespaceId, block);
if (block.getNumBytes() > onDiskLength) {
// Shorter on-disk len indicates corruption so report NN the corrupt block
nn.reportBadBlocks(new LocatedBlock[] { new LocatedBlock(block,
new DatanodeInfo[] { new DatanodeInfo(nsReg) }) });
LOG.info("Can't replicate block " + block + " because on-disk length "
+ onDiskLength + " is shorter than NameNode recorded length "
+ block.getNumBytes());
return;