|
96 | 96 | import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_SNAPSHOT_DIFF_LISTING_LIMIT_DEFAULT; |
97 | 97 | import static org.apache.hadoop.hdfs.DFSUtil.isParentEntry; |
98 | 98 |
|
| 99 | +import java.util.Objects; |
99 | 100 | import java.util.concurrent.atomic.AtomicLong; |
100 | 101 |
|
101 | 102 | import org.apache.commons.text.CaseUtils; |
@@ -6132,17 +6133,19 @@ static class CorruptFileBlockInfo { |
6132 | 6133 | final String path; |
6133 | 6134 | final Block block; |
6134 | 6135 | private final int replication; |
| 6136 | + private final String ecPolicy; |
6135 | 6137 |
|
6136 | | - CorruptFileBlockInfo(String p, Block b, int r) { |
| 6138 | + CorruptFileBlockInfo(String p, Block b, int r, String ec) { |
6137 | 6139 | path = p; |
6138 | 6140 | block = b; |
6139 | 6141 | replication = r; |
| 6142 | + ecPolicy = ec; |
6140 | 6143 | } |
6141 | 6144 |
|
6142 | 6145 | @Override |
6143 | 6146 | public String toString() { |
6144 | 6147 | return block.getBlockName() + "\t" + |
6145 | | - (replication == -1 ? "EC" : replication) + "\t" + path; |
| 6148 | + (replication == -1 ? ecPolicy : replication) + "\t" + path; |
6146 | 6149 | } |
6147 | 6150 | } |
6148 | 6151 | /** |
@@ -6198,15 +6201,21 @@ Collection<CorruptFileBlockInfo> listCorruptFileBlocks(String path, |
6198 | 6201 | if (inode != null) { |
6199 | 6202 | String src = inode.getFullPathName(); |
6200 | 6203 | if (isParentEntry(src, path)) { |
6201 | | - int repl = 0; |
| 6204 | + int repl = -1; |
| 6205 | + String ecPolicyName = null; |
6202 | 6206 | if (inode.isFile()) { |
6203 | 6207 | 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 | + } |
6205 | 6214 | } else { |
6206 | 6215 | repl = inode.asFile().getFileReplication(); |
6207 | 6216 | } |
6208 | 6217 | } |
6209 | | - corruptFiles.add(new CorruptFileBlockInfo(src, blk, repl)); |
| 6218 | + corruptFiles.add(new CorruptFileBlockInfo(src, blk, repl, ecPolicyName)); |
6210 | 6219 | count++; |
6211 | 6220 | if (count >= maxCorruptFileBlocksReturn) |
6212 | 6221 | break; |
|
0 commit comments