public void finalizeBlockInternal(int namespaceId, Block b, boolean reFinalizeOk)
throws IOException {
lock.writeLock().lock();
DatanodeBlockInfo replicaInfo = volumeMap.get(namespaceId, b);
try {
ActiveFile activeFile = volumeMap.getOngoingCreates(namespaceId, b);
if (activeFile == null) {
if (reFinalizeOk) {
return;
} else {
throw new IOException("Block " + b + " is already finalized.");
}
}
File f = activeFile.file;
if (f == null || !f.exists()) {
throw new IOException("No temporary file " + f + " for block " + b);
}
FSVolume v = replicaInfo.getVolume();
if (v == null) {
throw new IOException("No volume for temporary file " + f +
" for block " + b);
}
File dest = null;
dest = v.addBlock(namespaceId, b, f);
volumeMap.add(namespaceId, b,
new DatanodeBlockInfo(v, dest, activeFile.getBytesOnDisk()));
volumeMap.removeOngoingCreates(namespaceId, b);
} finally {
lock.writeLock().unlock();
}
}