Skip to content
Merged
Show file tree
Hide file tree
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 @@ -320,6 +320,10 @@ public void blockIdCK(String blockId) {
}
out.println("No. of corrupted Replica: " +
numberReplicas.corruptReplicas());
// for striped blocks only and number of redundant internal block replicas.
if (blockInfo.isStriped()) {
out.println("No. of redundant Replica: " + numberReplicas.redundantInternalBlocks());
}
//record datanodes that have corrupted block replica
Collection<DatanodeDescriptor> corruptionRecord = null;
if (blockManager.getCorruptReplicas(block) != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2450,6 +2450,68 @@ public void testFsckMissingECFile() throws Exception {
assertTrue(outStr.contains("has 1 CORRUPT blocks"));
}

@Test
public void testFsckECBlockIdRedundantInternalBlocks() throws Exception {
final int dataBlocks = StripedFileTestUtil.getDefaultECPolicy().getNumDataUnits();
final int parityBlocks = StripedFileTestUtil.getDefaultECPolicy().getNumParityUnits();
final int cellSize = StripedFileTestUtil.getDefaultECPolicy().getCellSize();
final short groupSize = (short) (dataBlocks + parityBlocks);
final File builderBaseDir = new File(GenericTestUtils.getRandomizedTempPath());
final Path dirPath = new Path("/ec_dir");
final Path filePath = new Path(dirPath, "file");

conf.setInt(DFSConfigKeys.DFS_NAMENODE_REDUNDANCY_INTERVAL_SECONDS_KEY, 1);
cluster = new MiniDFSCluster.Builder(conf, builderBaseDir).numDataNodes(groupSize + 1).build();
cluster.waitActive();

DistributedFileSystem fs = cluster.getFileSystem();
fs.enableErasureCodingPolicy(
StripedFileTestUtil.getDefaultECPolicy().getName());

try {
fs.mkdirs(dirPath);
fs.setErasureCodingPolicy(dirPath, StripedFileTestUtil.getDefaultECPolicy().getName());
DFSTestUtil.createFile(fs, filePath, cellSize * dataBlocks * 2, (short) 1, 0L);
LocatedBlocks blks = fs.getClient().getLocatedBlocks(filePath.toString(), 0);
LocatedStripedBlock block = (LocatedStripedBlock) blks.getLastLocatedBlock();
Assert.assertEquals(groupSize, block.getLocations().length);

//general test.
String runFsckResult = runFsck(conf, 0, true, "/",
"-blockId", block.getBlock().getBlockName());
assertTrue(runFsckResult.contains(block.getBlock().getBlockName()));
assertTrue(runFsckResult.contains("No. of Expected Replica: " + groupSize));
assertTrue(runFsckResult.contains("No. of live Replica: " + groupSize));
assertTrue(runFsckResult.contains("No. of redundant Replica: " + 0));

// stop a dn.
DatanodeInfo dnToStop = block.getLocations()[0];
MiniDFSCluster.DataNodeProperties dnProp = cluster.stopDataNode(dnToStop.getXferAddr());
cluster.setDataNodeDead(dnToStop);

// wait for reconstruction to happen.
DFSTestUtil.waitForReplication(fs, filePath, groupSize, 15 * 1000);

// bring the dn back: 10 internal blocks now.
cluster.restartDataNode(dnProp);
cluster.waitActive();

blks = fs.getClient().getLocatedBlocks(filePath.toString(), 0);
block = (LocatedStripedBlock) blks.getLastLocatedBlock();
Assert.assertEquals(groupSize + 1, block.getLocations().length);

//general test, number of redundant internal block replicas.
runFsckResult = runFsck(conf, 0, true, "/",
"-blockId", block.getBlock().getBlockName());
assertTrue(runFsckResult.contains(block.getBlock().getBlockName()));
assertTrue(runFsckResult.contains("No. of Expected Replica: " + groupSize));
assertTrue(runFsckResult.contains("No. of live Replica: " + groupSize));
assertTrue(runFsckResult.contains("No. of redundant Replica: " + 1));
} finally {
cluster.shutdown();
}
}

private void waitForUnrecoverableBlockGroup(Configuration configuration)
throws TimeoutException, InterruptedException {
GenericTestUtils.waitFor(new Supplier<Boolean>() {
Expand Down