assertTrue(scanLog.delete());
// restart the datanode so the corrupt replica will be detected
cluster.restartDataNode(0);
DFSTestUtil.waitReplication(fs, fileName, (short)2);
final DatanodeID corruptDataNode =
cluster.getDataNodes().get(2).dnRegistration;
final FSNamesystem namesystem = FSNamesystem.getFSNamesystem();
synchronized (namesystem.heartbeats) {
// set live datanode's remaining space to be 0
// so they will be chosen to be deleted when over-replication occurs
for (DatanodeDescriptor datanode : namesystem.heartbeats) {
if (!corruptDataNode.equals(datanode)) {
datanode.updateHeartbeat(100L, 100L, 0L, 0);
}
}
// decrease the replication factor to 1;