|
@@ -167,18 +167,26 @@ class FsDatasetAsyncDiskService {
|
|
|
* Execute the task sometime in the future, using ThreadPools.
|
|
|
*/
|
|
|
synchronized void execute(FsVolumeImpl volume, Runnable task) {
|
|
|
- if (executors == null) {
|
|
|
- throw new RuntimeException("AsyncDiskService is already shutdown");
|
|
|
- }
|
|
|
- if (volume == null) {
|
|
|
- throw new RuntimeException("A null volume does not have a executor");
|
|
|
- }
|
|
|
- ThreadPoolExecutor executor = executors.get(volume.getStorageID());
|
|
|
- if (executor == null) {
|
|
|
- throw new RuntimeException("Cannot find volume " + volume
|
|
|
- + " for execution of task " + task);
|
|
|
- } else {
|
|
|
- executor.execute(task);
|
|
|
+ try {
|
|
|
+ if (executors == null) {
|
|
|
+ throw new RuntimeException("AsyncDiskService is already shutdown");
|
|
|
+ }
|
|
|
+ if (volume == null) {
|
|
|
+ throw new RuntimeException("A null volume does not have a executor");
|
|
|
+ }
|
|
|
+ ThreadPoolExecutor executor = executors.get(volume.getStorageID());
|
|
|
+ if (executor == null) {
|
|
|
+ throw new RuntimeException("Cannot find volume " + volume
|
|
|
+ + " for execution of task " + task);
|
|
|
+ } else {
|
|
|
+ executor.execute(task);
|
|
|
+ }
|
|
|
+ } catch (RuntimeException re) {
|
|
|
+ if (task instanceof ReplicaFileDeleteTask) {
|
|
|
+ IOUtils.cleanupWithLogger(null,
|
|
|
+ ((ReplicaFileDeleteTask) task).volumeRef);
|
|
|
+ }
|
|
|
+ throw re;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -314,28 +322,31 @@ class FsDatasetAsyncDiskService {
|
|
|
|
|
|
@Override
|
|
|
public void run() {
|
|
|
- final long blockLength = replicaToDelete.getBlockDataLength();
|
|
|
- final long metaLength = replicaToDelete.getMetadataLength();
|
|
|
- boolean result;
|
|
|
+ try {
|
|
|
+ final long blockLength = replicaToDelete.getBlockDataLength();
|
|
|
+ final long metaLength = replicaToDelete.getMetadataLength();
|
|
|
+ boolean result;
|
|
|
|
|
|
- result = (trashDirectory == null) ? deleteFiles() : moveFiles();
|
|
|
+ result = (trashDirectory == null) ? deleteFiles() : moveFiles();
|
|
|
|
|
|
- if (!result) {
|
|
|
- LOG.warn("Unexpected error trying to "
|
|
|
- + (trashDirectory == null ? "delete" : "move")
|
|
|
- + " block " + block.getBlockPoolId() + " " + block.getLocalBlock()
|
|
|
- + " at file " + replicaToDelete.getBlockURI() + ". Ignored.");
|
|
|
- } else {
|
|
|
- if(block.getLocalBlock().getNumBytes() != BlockCommand.NO_ACK){
|
|
|
- datanode.notifyNamenodeDeletedBlock(block, volume.getStorageID());
|
|
|
+ if (!result) {
|
|
|
+ LOG.warn("Unexpected error trying to "
|
|
|
+ + (trashDirectory == null ? "delete" : "move")
|
|
|
+ + " block " + block.getBlockPoolId() + " " + block.getLocalBlock()
|
|
|
+ + " at file " + replicaToDelete.getBlockURI() + ". Ignored.");
|
|
|
+ } else {
|
|
|
+ if (block.getLocalBlock().getNumBytes() != BlockCommand.NO_ACK) {
|
|
|
+ datanode.notifyNamenodeDeletedBlock(block, volume.getStorageID());
|
|
|
+ }
|
|
|
+ volume.onBlockFileDeletion(block.getBlockPoolId(), blockLength);
|
|
|
+ volume.onMetaFileDeletion(block.getBlockPoolId(), metaLength);
|
|
|
+ LOG.info("Deleted " + block.getBlockPoolId() + " " +
|
|
|
+ block.getLocalBlock() + " URI " + replicaToDelete.getBlockURI());
|
|
|
}
|
|
|
- volume.onBlockFileDeletion(block.getBlockPoolId(), blockLength);
|
|
|
- volume.onMetaFileDeletion(block.getBlockPoolId(), metaLength);
|
|
|
- LOG.info("Deleted " + block.getBlockPoolId() + " "
|
|
|
- + block.getLocalBlock() + " URI " + replicaToDelete.getBlockURI());
|
|
|
+ updateDeletedBlockId(block);
|
|
|
+ } finally {
|
|
|
+ IOUtils.cleanupWithLogger(null, this.volumeRef);
|
|
|
}
|
|
|
- updateDeletedBlockId(block);
|
|
|
- IOUtils.cleanupWithLogger(null, volumeRef);
|
|
|
}
|
|
|
}
|
|
|
|