use of org.apache.hadoop.hdds.scm.server.SCMDatanodeHeartbeatDispatcher.IncrementalContainerReportFromDatanode in project ozone by apache.
the class TestReconIncrementalContainerReportHandler method testProcessICR.
@Test
public void testProcessICR() throws IOException, NodeNotFoundException {
ContainerID containerID = ContainerID.valueOf(100L);
DatanodeDetails datanodeDetails = randomDatanodeDetails();
IncrementalContainerReportFromDatanode reportMock = mock(IncrementalContainerReportFromDatanode.class);
when(reportMock.getDatanodeDetails()).thenReturn(datanodeDetails);
IncrementalContainerReportProto containerReport = getIncrementalContainerReportProto(containerID, State.OPEN, datanodeDetails.getUuidString());
when(reportMock.getReport()).thenReturn(containerReport);
final String path = GenericTestUtils.getTempPath(UUID.randomUUID().toString());
Path scmPath = Paths.get(path, "scm-meta");
final OzoneConfiguration conf = new OzoneConfiguration();
conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, scmPath.toString());
NetworkTopology clusterMap = new NetworkTopologyImpl(conf);
EventQueue eventQueue = new EventQueue();
SCMStorageConfig storageConfig = new SCMStorageConfig(conf);
this.versionManager = Mockito.mock(HDDSLayoutVersionManager.class);
Mockito.when(versionManager.getMetadataLayoutVersion()).thenReturn(maxLayoutVersion());
Mockito.when(versionManager.getSoftwareLayoutVersion()).thenReturn(maxLayoutVersion());
NodeManager nodeManager = new SCMNodeManager(conf, storageConfig, eventQueue, clusterMap, SCMContext.emptyContext(), versionManager);
nodeManager.register(datanodeDetails, null, null);
ReconContainerManager containerManager = getContainerManager();
ReconIncrementalContainerReportHandler reconIcr = new ReconIncrementalContainerReportHandler(nodeManager, containerManager, SCMContext.emptyContext());
EventPublisher eventPublisherMock = mock(EventPublisher.class);
reconIcr.onMessage(reportMock, eventPublisherMock);
nodeManager.addContainer(datanodeDetails, containerID);
assertTrue(containerManager.containerExist(containerID));
assertEquals(1, containerManager.getContainerReplicas(containerID).size());
assertEquals(OPEN, containerManager.getContainer(containerID).getState());
}
use of org.apache.hadoop.hdds.scm.server.SCMDatanodeHeartbeatDispatcher.IncrementalContainerReportFromDatanode in project ozone by apache.
the class TestIncrementalContainerReportHandler method testDeleteContainer.
@Test
public void testDeleteContainer() throws IOException {
final IncrementalContainerReportHandler reportHandler = new IncrementalContainerReportHandler(nodeManager, containerManager, scmContext);
final ContainerInfo container = getContainer(LifeCycleState.CLOSED);
final DatanodeDetails datanodeOne = randomDatanodeDetails();
final DatanodeDetails datanodeTwo = randomDatanodeDetails();
final DatanodeDetails datanodeThree = randomDatanodeDetails();
nodeManager.register(datanodeOne, null, null);
nodeManager.register(datanodeTwo, null, null);
nodeManager.register(datanodeThree, null, null);
final Set<ContainerReplica> containerReplicas = getReplicas(container.containerID(), CLOSED, datanodeOne, datanodeTwo, datanodeThree);
containerStateManager.addContainer(container.getProtobuf());
containerReplicas.forEach(r -> containerStateManager.updateContainerReplica(container.containerID(), r));
Assertions.assertEquals(3, containerStateManager.getContainerReplicas(container.containerID()).size());
final IncrementalContainerReportProto containerReport = getIncrementalContainerReportProto(container.containerID(), ContainerReplicaProto.State.DELETED, datanodeThree.getUuidString());
final IncrementalContainerReportFromDatanode icr = new IncrementalContainerReportFromDatanode(datanodeOne, containerReport);
reportHandler.onMessage(icr, publisher);
Assertions.assertEquals(2, containerStateManager.getContainerReplicas(container.containerID()).size());
}
use of org.apache.hadoop.hdds.scm.server.SCMDatanodeHeartbeatDispatcher.IncrementalContainerReportFromDatanode in project ozone by apache.
the class TestIncrementalContainerReportHandler method testClosingToClosed.
@Test
public void testClosingToClosed() throws IOException {
final IncrementalContainerReportHandler reportHandler = new IncrementalContainerReportHandler(nodeManager, containerManager, scmContext);
final ContainerInfo container = getContainer(LifeCycleState.CLOSING);
final DatanodeDetails datanodeOne = randomDatanodeDetails();
final DatanodeDetails datanodeTwo = randomDatanodeDetails();
final DatanodeDetails datanodeThree = randomDatanodeDetails();
nodeManager.register(datanodeOne, null, null);
nodeManager.register(datanodeTwo, null, null);
nodeManager.register(datanodeThree, null, null);
final Set<ContainerReplica> containerReplicas = getReplicas(container.containerID(), ContainerReplicaProto.State.CLOSING, datanodeOne, datanodeTwo, datanodeThree);
containerStateManager.addContainer(container.getProtobuf());
containerReplicas.forEach(r -> containerStateManager.updateContainerReplica(container.containerID(), r));
final IncrementalContainerReportProto containerReport = getIncrementalContainerReportProto(container.containerID(), ContainerReplicaProto.State.CLOSED, datanodeOne.getUuidString());
final IncrementalContainerReportFromDatanode icrFromDatanode = new IncrementalContainerReportFromDatanode(datanodeOne, containerReport);
reportHandler.onMessage(icrFromDatanode, publisher);
Assertions.assertEquals(LifeCycleState.CLOSED, containerManager.getContainer(container.containerID()).getState());
}
Aggregations