Skip to content

HDFS-17197. Show file replication when listing corrupt files. #6095

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6131,15 +6131,20 @@ void releaseBackupNode(NamenodeRegistration registration)
static class CorruptFileBlockInfo {
final String path;
final Block block;
private final int replication;
private final String ecPolicy;

public CorruptFileBlockInfo(String p, Block b) {
CorruptFileBlockInfo(String p, Block b, int r, String ec) {
path = p;
block = b;
replication = r;
ecPolicy = ec;
}

@Override
public String toString() {
return block.getBlockName() + "\t" + path;
return block.getBlockName() + "\t" +
(replication == -1 ? ecPolicy : replication) + "\t" + path;
}
}
/**
Expand Down Expand Up @@ -6195,7 +6200,21 @@ Collection<CorruptFileBlockInfo> listCorruptFileBlocks(String path,
if (inode != null) {
String src = inode.getFullPathName();
if (isParentEntry(src, path)) {
corruptFiles.add(new CorruptFileBlockInfo(src, blk));
int repl = -1;
String ecPolicyName = null;
if (inode.isFile()) {
if (inode.asFile().isStriped()) {
ErasureCodingPolicy ecPolicy =
ErasureCodingPolicyManager.getInstance()
.getByID(inode.asFile().getErasureCodingPolicyID());
if (ecPolicy != null) {
ecPolicyName = ecPolicy.getName();
}
} else {
repl = inode.asFile().getFileReplication();
}
}
corruptFiles.add(new CorruptFileBlockInfo(src, blk, repl, ecPolicyName));
count++;
if (count >= maxCorruptFileBlocksReturn)
break;
Expand Down