TestRaidDfs.waitForFileRaided(LOG, fileSys, file1, destPath);
cnode.stop(); cnode.join();
FileStatus srcStat = fileSys.getFileStatus(file1);
DistributedFileSystem dfs = (DistributedFileSystem)fileSys;
LocatedBlocks locs = RaidDFSUtil.getBlockLocations(
dfs, file1.toUri().getPath(), 0, srcStat.getLen());
String[] corruptFiles = DFSUtil.getCorruptFiles(dfs);
assertEquals("no corrupt files expected", 0, corruptFiles.length);
assertEquals("filesFixed() should return 0 before fixing files",
0, cnode.blockIntegrityMonitor.getNumFilesFixed());
corruptBlock(locs.get(0).getBlock().getBlockName(), dfsCluster);
RaidDFSUtil.reportCorruptBlocks(dfs, file1, new int[]{0}, blockSize);
corruptFiles = DFSUtil.getCorruptFiles(dfs);
assertEquals("file not corrupted",
1, corruptFiles.length);
assertEquals("wrong file corrupted",
corruptFiles[0], file1.toUri().getPath());
cnode = RaidNode.createRaidNode(null, localConf);
long start = System.currentTimeMillis();
while (cnode.blockIntegrityMonitor.getNumFilesFixed() < 1 &&
System.currentTimeMillis() - start < 120000) {
LOG.info("Test " + testName + " waiting for files to be fixed.");
Thread.sleep(1000);
}
assertEquals("file not fixed",
1, cnode.blockIntegrityMonitor.getNumFilesFixed());
// Stop RaidNode
cnode.stop(); cnode.join(); cnode = null;
// The block has successfully been reconstructed.
dfs = getDFS(conf, dfs);
assertTrue("file not fixed",
TestRaidDfs.validateFile(dfs, file1, file1Len, crc1));
// Now corrupt the generated block.
locs = RaidDFSUtil.getBlockLocations(
dfs, file1.toUri().getPath(), 0, srcStat.getLen());
corruptBlock(locs.get(0).getBlock().getBlockName(), dfsCluster);
RaidDFSUtil.reportCorruptBlocks(dfs, file1, new int[]{0}, blockSize);
try {
Thread.sleep(5*1000);
} catch (InterruptedException ignore) {