Skip to content

Commit

Permalink
HDFS-16180.FsVolumeImpl.nextBlock should consider that the block met…
Browse files Browse the repository at this point in the history
…a file has been deleted. (#3315)
  • Loading branch information
Neilxzn authored Aug 24, 2021
1 parent b6d1971 commit 9084c72
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileNotFoundException;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -98,7 +99,8 @@ public boolean accept(File dir, String name) {
});

if (matches == null || matches.length == 0) {
throw new IOException("Meta file not found, blockFile=" + blockFile);
throw new FileNotFoundException(
"Meta file not found, blockFile=" + blockFile);
}
if (matches.length > 1) {
throw new IOException("Found more than one meta files: "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.OutputStreamWriter;
Expand Down Expand Up @@ -865,7 +866,15 @@ public ExtendedBlock nextBlock() throws IOException {
}

File blkFile = getBlockFile(bpid, block);
File metaFile = FsDatasetUtil.findMetaFile(blkFile);
File metaFile ;
try {
metaFile = FsDatasetUtil.findMetaFile(blkFile);
} catch (FileNotFoundException e){
LOG.warn("nextBlock({}, {}): {}", storageID, bpid,
e.getMessage());
continue;
}

block.setGenerationStamp(
Block.getGenerationStamp(metaFile.getName()));
block.setNumBytes(blkFile.length());
Expand Down

0 comments on commit 9084c72

Please sign in to comment.