Skip to content

Commit b6957d7

Browse files
committed
HDFS-17197. Show file replication when listing corrupt files.
1 parent 56b928b commit b6957d7

File tree

1 file changed

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

1 file changed

+9
-3
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6131,15 +6131,17 @@ void releaseBackupNode(NamenodeRegistration registration)
61316131
static class CorruptFileBlockInfo {
61326132
final String path;
61336133
final Block block;
6134+
final int replication;
61346135

6135-
public CorruptFileBlockInfo(String p, Block b) {
6136+
public CorruptFileBlockInfo(String p, Block b, int r) {
61366137
path = p;
61376138
block = b;
6139+
replication = r;
61386140
}
61396141

61406142
@Override
61416143
public String toString() {
6142-
return block.getBlockName() + "\t" + path;
6144+
return block.getBlockName() + "\t" + replication + "\t" + path;
61436145
}
61446146
}
61456147
/**
@@ -6195,7 +6197,11 @@ Collection<CorruptFileBlockInfo> listCorruptFileBlocks(String path,
61956197
if (inode != null) {
61966198
String src = inode.getFullPathName();
61976199
if (isParentEntry(src, path)) {
6198-
corruptFiles.add(new CorruptFileBlockInfo(src, blk));
6200+
int repl = 0;
6201+
if (inode.isFile()) {
6202+
repl = inode.asFile().getFileReplication();
6203+
}
6204+
corruptFiles.add(new CorruptFileBlockInfo(src, blk, repl));
61996205
count++;
62006206
if (count >= maxCorruptFileBlocksReturn)
62016207
break;

0 commit comments

Comments
 (0)