// Shutdown and wait for datanode to be marked dead
dn.shutdown();
waitForDatanodeState(reg, false, 20000);
DatanodeProtocol dnp = cluster.getNameNode();
Block block = new Block(0);
Block[] blocks = new Block[] { block };
String[] delHints = new String[] { "" };
// Ensure blockReceived call from dead datanode is rejected with IOException
try {
dnp.blockReceived(reg, blocks, delHints);
Assert.fail("Expected IOException is not thrown");
} catch (IOException ex) {
// Expected
}
// Ensure blockReport from dead datanode is rejected with IOException
long[] blockReport = new long[] { 0L, 0L, 0L };
try {
dnp.blockReport(reg, blockReport);
Assert.fail("Expected IOException is not thrown");
} catch (IOException ex) {
// Expected
}
// Ensure heartbeat from dead datanode is rejected with a command
// that asks datanode to register again
DatanodeCommand[] cmd = dnp.sendHeartbeat(reg, 0, 0, 0, 0, 0);
Assert.assertEquals(1, cmd.length);
Assert.assertEquals(cmd[0].getAction(), DatanodeCommand.REGISTER
.getAction());
}