Skip to content

Commit fced809

Browse files
committed
refactor.
1 parent 77b8819 commit fced809

File tree

1 file changed

+14
-5
lines changed
  • hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode

1 file changed

+14
-5
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_SNAPSHOT_DIFF_LISTING_LIMIT_DEFAULT;
9797
import static org.apache.hadoop.hdfs.DFSUtil.isParentEntry;
9898

99+
import java.util.Objects;
99100
import java.util.concurrent.atomic.AtomicLong;
100101

101102
import org.apache.commons.text.CaseUtils;
@@ -6132,17 +6133,19 @@ static class CorruptFileBlockInfo {
61326133
final String path;
61336134
final Block block;
61346135
private final int replication;
6136+
private final String ecPolicy;
61356137

6136-
CorruptFileBlockInfo(String p, Block b, int r) {
6138+
CorruptFileBlockInfo(String p, Block b, int r, String ec) {
61376139
path = p;
61386140
block = b;
61396141
replication = r;
6142+
ecPolicy = ec;
61406143
}
61416144

61426145
@Override
61436146
public String toString() {
61446147
return block.getBlockName() + "\t" +
6145-
(replication == -1 ? "EC" : replication) + "\t" + path;
6148+
(replication == -1 ? ecPolicy : replication) + "\t" + path;
61466149
}
61476150
}
61486151
/**
@@ -6198,15 +6201,21 @@ Collection<CorruptFileBlockInfo> listCorruptFileBlocks(String path,
61986201
if (inode != null) {
61996202
String src = inode.getFullPathName();
62006203
if (isParentEntry(src, path)) {
6201-
int repl = 0;
6204+
int repl = -1;
6205+
String ecPolicyName = null;
62026206
if (inode.isFile()) {
62036207
if (inode.asFile().isStriped()) {
6204-
repl = -1;
6208+
ErasureCodingPolicy ecPolicy =
6209+
ErasureCodingPolicyManager.getInstance()
6210+
.getByID(inode.asFile().getErasureCodingPolicyID());
6211+
if (ecPolicy != null) {
6212+
ecPolicyName = ecPolicy.getName();
6213+
}
62056214
} else {
62066215
repl = inode.asFile().getFileReplication();
62076216
}
62086217
}
6209-
corruptFiles.add(new CorruptFileBlockInfo(src, blk, repl));
6218+
corruptFiles.add(new CorruptFileBlockInfo(src, blk, repl, ecPolicyName));
62106219
count++;
62116220
if (count >= maxCorruptFileBlocksReturn)
62126221
break;

0 commit comments

Comments
 (0)