HDFS-13592. TestNameNodePrunesMissingStorages#testNameNodePrunesUnreportedStorages does not shut down cluster properly. Contributed by Anbang Hu.
(cherry picked from commit 57b893de3d
)
This commit is contained in:
parent
472495ed1e
commit
da5eff8325
|
@ -383,6 +383,8 @@ public class TestNameNodePrunesMissingStorages {
|
||||||
.Builder(conf).numDataNodes(1)
|
.Builder(conf).numDataNodes(1)
|
||||||
.storagesPerDatanode(2)
|
.storagesPerDatanode(2)
|
||||||
.build();
|
.build();
|
||||||
|
try {
|
||||||
|
cluster.waitActive();
|
||||||
// Create two files to ensure each storage has a block
|
// Create two files to ensure each storage has a block
|
||||||
DFSTestUtil.createFile(cluster.getFileSystem(), new Path("file1"),
|
DFSTestUtil.createFile(cluster.getFileSystem(), new Path("file1"),
|
||||||
102400, 102400, 102400, (short)1,
|
102400, 102400, 102400, (short)1,
|
||||||
|
@ -392,7 +394,8 @@ public class TestNameNodePrunesMissingStorages {
|
||||||
0x1BAD5EED);
|
0x1BAD5EED);
|
||||||
// Get the datanode storages and data directories
|
// Get the datanode storages and data directories
|
||||||
DataNode dn = cluster.getDataNodes().get(0);
|
DataNode dn = cluster.getDataNodes().get(0);
|
||||||
BlockManager bm = cluster.getNameNode().getNamesystem().getBlockManager();
|
BlockManager bm =
|
||||||
|
cluster.getNameNode().getNamesystem().getBlockManager();
|
||||||
DatanodeDescriptor dnDescriptor = bm.getDatanodeManager().
|
DatanodeDescriptor dnDescriptor = bm.getDatanodeManager().
|
||||||
getDatanode(cluster.getDataNodes().get(0).getDatanodeUuid());
|
getDatanode(cluster.getDataNodes().get(0).getDatanodeUuid());
|
||||||
DatanodeStorageInfo[] dnStoragesInfosBeforeRestart =
|
DatanodeStorageInfo[] dnStoragesInfosBeforeRestart =
|
||||||
|
@ -421,7 +424,8 @@ public class TestNameNodePrunesMissingStorages {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertEquals(1, numFailedStoragesWithBlocks);
|
assertEquals(1, numFailedStoragesWithBlocks);
|
||||||
// Heartbeat manager removes the blocks associated with this failed storage
|
// Heartbeat manager removes the blocks associated with this failed
|
||||||
|
// storage
|
||||||
bm.getDatanodeManager().getHeartbeatManager().heartbeatCheck();
|
bm.getDatanodeManager().getHeartbeatManager().heartbeatCheck();
|
||||||
assertTrue(!failedStorageInfo.areBlocksOnFailedStorage());
|
assertTrue(!failedStorageInfo.areBlocksOnFailedStorage());
|
||||||
// pruneStorageMap removes the unreported storage
|
// pruneStorageMap removes the unreported storage
|
||||||
|
@ -429,5 +433,10 @@ public class TestNameNodePrunesMissingStorages {
|
||||||
// Assert that the unreported storage is pruned
|
// Assert that the unreported storage is pruned
|
||||||
assertEquals(DataNode.getStorageLocations(dn.getConf()).size(),
|
assertEquals(DataNode.getStorageLocations(dn.getConf()).size(),
|
||||||
dnDescriptor.getStorageInfos().length);
|
dnDescriptor.getStorageInfos().length);
|
||||||
|
} finally {
|
||||||
|
if (cluster != null) {
|
||||||
|
cluster.shutdown();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue