HDFS-8025. Addendum fix for HDFS-3087 Decomissioning on NN restart can complete without blocks being replicated. Contributed by Ming Ma.
This commit is contained in:
parent
82d56b337d
commit
5a540c3d31
|
@ -399,6 +399,9 @@ Release 2.8.0 - UNRELEASED
|
|||
HDFS-8076. Code cleanup for DFSInputStream: use offset instead of
|
||||
LocatedBlock when possible. (Zhe Zhang via wang)
|
||||
|
||||
HDFS-8025. Addendum fix for HDFS-3087 Decomissioning on NN restart can
|
||||
complete without blocks being replicated. (Ming Ma via wang)
|
||||
|
||||
OPTIMIZATIONS
|
||||
|
||||
HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than
|
||||
|
|
|
@ -3305,6 +3305,11 @@ public class BlockManager {
|
|||
* liveness. Dead nodes cannot always be safely decommissioned.
|
||||
*/
|
||||
boolean isNodeHealthyForDecommission(DatanodeDescriptor node) {
|
||||
if (!node.checkBlockReportReceived()) {
|
||||
LOG.info("Node {} hasn't sent its first block report.", node);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (node.isAlive) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -882,9 +882,12 @@ public class TestDecommission {
|
|||
int numNamenodes = 1;
|
||||
int numDatanodes = 1;
|
||||
int replicas = 1;
|
||||
conf.setLong(DFSConfigKeys.DFS_BLOCKREPORT_INTERVAL_MSEC_KEY,
|
||||
DFSConfigKeys.DFS_BLOCKREPORT_INTERVAL_MSEC_DEFAULT);
|
||||
conf.setLong(DFSConfigKeys.DFS_BLOCKREPORT_INITIAL_DELAY_KEY, 5);
|
||||
|
||||
startCluster(numNamenodes, numDatanodes, conf);
|
||||
Path file1 = new Path("testDecommission.dat");
|
||||
Path file1 = new Path("testDecommissionWithNamenodeRestart.dat");
|
||||
FileSystem fileSys = cluster.getFileSystem();
|
||||
writeFile(fileSys, file1, replicas);
|
||||
|
||||
|
@ -909,22 +912,11 @@ public class TestDecommission {
|
|||
// Ensure decommissioned datanode is not automatically shutdown
|
||||
assertEquals("All datanodes must be alive", numDatanodes,
|
||||
client.datanodeReport(DatanodeReportType.LIVE).length);
|
||||
// wait for the block to be replicated
|
||||
int tries = 0;
|
||||
while (tries++ < 20) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
if (checkFile(fileSys, file1, replicas, datanodeInfo.getXferAddr(),
|
||||
numDatanodes) == null) {
|
||||
break;
|
||||
}
|
||||
} catch (InterruptedException ie) {
|
||||
}
|
||||
}
|
||||
assertTrue("Checked if block was replicated after decommission, tried "
|
||||
+ tries + " times.", tries < 20);
|
||||
cleanupFile(fileSys, file1);
|
||||
assertTrue("Checked if block was replicated after decommission.",
|
||||
checkFile(fileSys, file1, replicas, datanodeInfo.getXferAddr(),
|
||||
numDatanodes) == null);
|
||||
|
||||
cleanupFile(fileSys, file1);
|
||||
// Restart the cluster and ensure recommissioned datanodes
|
||||
// are allowed to register with the namenode
|
||||
cluster.shutdown();
|
||||
|
|
Loading…
Reference in New Issue