/// <exception cref="System.IO.IOException"/> private void CorruptBlock(MiniDFSCluster cluster, FileSystem fs, Path fileName, int dnIndex, ExtendedBlock block) { // corrupt the block on datanode dnIndex // the indexes change once the nodes are restarted. // But the datadirectory will not change NUnit.Framework.Assert.IsTrue(cluster.CorruptReplica(dnIndex, block)); MiniDFSCluster.DataNodeProperties dnProps = cluster.StopDataNode(0); // Each datanode has multiple data dirs, check each for (int dirIndex = 0; dirIndex < 2; dirIndex++) { string bpid = cluster.GetNamesystem().GetBlockPoolId(); FilePath storageDir = cluster.GetStorageDir(dnIndex, dirIndex); FilePath dataDir = MiniDFSCluster.GetFinalizedDir(storageDir, bpid); FilePath scanLogFile = new FilePath(dataDir, "dncp_block_verification.log.curr"); if (scanLogFile.Exists()) { // wait for one minute for deletion to succeed; for (int i = 0; !scanLogFile.Delete(); i++) { NUnit.Framework.Assert.IsTrue("Could not delete log file in one minute", i < 60); try { Sharpen.Thread.Sleep(1000); } catch (Exception) { } } } } // restart the detained so the corrupt replica will be detected cluster.RestartDataNode(dnProps); }