private void deleteReplica(final ReplicaInfo replicaToDelete) { // Delete the files on disk. Failure here is okay. if (!replicaToDelete.deleteBlockData()) { LOG.warn("Failed to delete block file for replica " + replicaToDelete); } if (!replicaToDelete.deleteMetadata()) { LOG.warn("Failed to delete meta file for replica " + replicaToDelete); } }
/** * Remove a block from disk * @param info the replica that needs to be deleted * @return true if data for the replica are deleted; false otherwise */ private boolean delBlockFromDisk(ReplicaInfo info) { if (!info.deleteBlockData()) { LOG.warn("Not able to delete the block data for replica " + info); return false; } else { // remove the meta file if (!info.deleteMetadata()) { LOG.warn("Not able to delete the meta data for replica " + info); return false; } } return true; }
private boolean deleteFiles() { return replicaToDelete.deleteBlockData() && (replicaToDelete.deleteMetadata() || !replicaToDelete.metadataExists()); }
/** * Finalizes newReplica by calling finalizeReplica internally. * * @param newReplicaInfo - ReplicaInfo * @param block - Extended Block * @throws IOException */ @VisibleForTesting void finalizeNewReplica(ReplicaInfo newReplicaInfo, ExtendedBlock block) throws IOException { // Finalize the copied files try { String bpid = block.getBlockPoolId(); finalizeReplica(bpid, newReplicaInfo); FsVolumeImpl volume = (FsVolumeImpl) newReplicaInfo.getVolume(); volume.incrNumBlocks(bpid); } catch (IOException ioe) { // Cleanup block data and metadata // Decrement of dfsUsed and noOfBlocks for volume not required newReplicaInfo.deleteBlockData(); newReplicaInfo.deleteMetadata(); throw ioe; } }
/** * Cleanup the replicaInfo object passed. * * @param bpid - block pool id * @param replicaInfo - ReplicaInfo */ private void cleanupReplica(String bpid, ReplicaInfo replicaInfo) { if (replicaInfo.deleteBlockData() || !replicaInfo.blockDataExists()) { FsVolumeImpl volume = (FsVolumeImpl) replicaInfo.getVolume(); volume.onBlockFileDeletion(bpid, replicaInfo.getBytesOnDisk()); if (replicaInfo.deleteMetadata() || !replicaInfo.metadataExists()) { volume.onMetaFileDeletion(bpid, replicaInfo.getMetadataLength()); } } }