use of org.apache.hadoop.ozone.recon.scm.ReconContainerManager in project ozone by apache.
the class TestReconTasks method testMissingContainerDownNode.
@Test
public void testMissingContainerDownNode() throws Exception {
ReconStorageContainerManagerFacade reconScm = (ReconStorageContainerManagerFacade) cluster.getReconServer().getReconStorageContainerManager();
StorageContainerManager scm = cluster.getStorageContainerManager();
PipelineManager reconPipelineManager = reconScm.getPipelineManager();
PipelineManager scmPipelineManager = scm.getPipelineManager();
// Make sure Recon's pipeline state is initialized.
LambdaTestUtils.await(60000, 5000, () -> (reconPipelineManager.getPipelines().size() >= 1));
ContainerManager scmContainerManager = scm.getContainerManager();
ReconContainerManager reconContainerManager = (ReconContainerManager) reconScm.getContainerManager();
ContainerInfo containerInfo = scmContainerManager.allocateContainer(RatisReplicationConfig.getInstance(ONE), "test");
long containerID = containerInfo.getContainerID();
Pipeline pipeline = scmPipelineManager.getPipeline(containerInfo.getPipelineID());
XceiverClientGrpc client = new XceiverClientGrpc(pipeline, conf);
runTestOzoneContainerViaDataNode(containerID, client);
// Make sure Recon got the container report with new container.
Assert.assertEquals(scmContainerManager.getContainerIDs(), reconContainerManager.getContainerIDs());
// Bring down the Datanode that had the container replica.
cluster.shutdownHddsDatanode(pipeline.getFirstNode());
LambdaTestUtils.await(120000, 10000, () -> {
List<UnhealthyContainers> allMissingContainers = reconContainerManager.getContainerSchemaManager().getUnhealthyContainers(ContainerSchemaDefinition.UnHealthyContainerStates.MISSING, 0, 1000);
return (allMissingContainers.size() == 1);
});
// Restart the Datanode to make sure we remove the missing container.
cluster.restartHddsDatanode(pipeline.getFirstNode(), true);
LambdaTestUtils.await(120000, 10000, () -> {
List<UnhealthyContainers> allMissingContainers = reconContainerManager.getContainerSchemaManager().getUnhealthyContainers(ContainerSchemaDefinition.UnHealthyContainerStates.MISSING, 0, 1000);
return (allMissingContainers.isEmpty());
});
}
Aggregations