use of org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline in project ozone by apache.
the class TestPipelineClose method testPipelineCloseWithLogFailure.
@Test
@Ignore("HDDS-5604")
public void testPipelineCloseWithLogFailure() throws IOException {
EventQueue eventQ = (EventQueue) scm.getEventQueue();
PipelineActionHandler pipelineActionTest = Mockito.mock(PipelineActionHandler.class);
eventQ.addHandler(SCMEvents.PIPELINE_ACTIONS, pipelineActionTest);
ArgumentCaptor<PipelineActionsFromDatanode> actionCaptor = ArgumentCaptor.forClass(PipelineActionsFromDatanode.class);
ContainerInfo containerInfo = containerManager.allocateContainer(RatisReplicationConfig.getInstance(ReplicationFactor.THREE), "testOwner");
ContainerWithPipeline containerWithPipeline = new ContainerWithPipeline(containerInfo, pipelineManager.getPipeline(containerInfo.getPipelineID()));
Pipeline openPipeline = containerWithPipeline.getPipeline();
RaftGroupId groupId = RaftGroupId.valueOf(openPipeline.getId().getId());
try {
pipelineManager.getPipeline(openPipeline.getId());
} catch (PipelineNotFoundException e) {
Assert.assertTrue("pipeline should exist", false);
}
DatanodeDetails datanodeDetails = openPipeline.getNodes().get(0);
int index = cluster.getHddsDatanodeIndex(datanodeDetails);
XceiverServerRatis xceiverRatis = (XceiverServerRatis) cluster.getHddsDatanodes().get(index).getDatanodeStateMachine().getContainer().getWriteChannel();
/**
* Notify Datanode Ratis Server endpoint of a Ratis log failure.
* This is expected to trigger an immediate pipeline actions report to SCM
*/
xceiverRatis.handleNodeLogFailure(groupId, null);
// verify SCM receives a pipeline action report "immediately"
Mockito.verify(pipelineActionTest, Mockito.timeout(100)).onMessage(actionCaptor.capture(), Mockito.any(EventPublisher.class));
PipelineActionsFromDatanode actionsFromDatanode = actionCaptor.getValue();
// match the pipeline id
verifyCloseForPipeline(openPipeline, actionsFromDatanode);
}
use of org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline in project ozone by apache.
the class TestContainerStateManagerIntegration method testAllocateContainer.
@Test
public void testAllocateContainer() throws IOException {
// Allocate a container and verify the container info
ContainerWithPipeline container1 = scm.getClientProtocolServer().allocateContainer(SCMTestUtils.getReplicationType(conf), SCMTestUtils.getReplicationFactor(conf), OzoneConsts.OZONE);
ContainerInfo info = containerManager.getMatchingContainer(OzoneConsts.GB * 3, OzoneConsts.OZONE, container1.getPipeline(), excludedContainerIDS);
Assert.assertNotEquals(container1.getContainerInfo().getContainerID(), info.getContainerID());
Assert.assertEquals(OzoneConsts.OZONE, info.getOwner());
Assert.assertEquals(SCMTestUtils.getReplicationType(conf), info.getReplicationType());
Assert.assertEquals(SCMTestUtils.getReplicationFactor(conf), ReplicationConfig.getLegacyFactor(info.getReplicationConfig()));
Assert.assertEquals(HddsProtos.LifeCycleState.OPEN, info.getState());
// Check there are two containers in ALLOCATED state after allocation
ContainerWithPipeline container2 = scm.getClientProtocolServer().allocateContainer(SCMTestUtils.getReplicationType(conf), SCMTestUtils.getReplicationFactor(conf), OzoneConsts.OZONE);
Assert.assertNotEquals(container1.getContainerInfo().getContainerID(), container2.getContainerInfo().getContainerID());
}
use of org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline in project ozone by apache.
the class TestContainerStateManagerIntegration method testGetMatchingContainer.
@Test
public void testGetMatchingContainer() throws IOException {
long cid;
ContainerWithPipeline container1 = scm.getClientProtocolServer().allocateContainer(SCMTestUtils.getReplicationType(conf), SCMTestUtils.getReplicationFactor(conf), OzoneConsts.OZONE);
cid = container1.getContainerInfo().getContainerID();
// containers.
for (int i = 1; i < numContainerPerOwnerInPipeline; i++) {
ContainerInfo info = containerManager.getMatchingContainer(OzoneConsts.GB * 3, OzoneConsts.OZONE, container1.getPipeline(), excludedContainerIDS);
Assert.assertTrue(info.getContainerID() > cid);
cid = info.getContainerID();
}
// At this point there are already three containers in the pipeline.
// next container should be the same as first container
ContainerInfo info = containerManager.getMatchingContainer(OzoneConsts.GB * 3, OzoneConsts.OZONE, container1.getPipeline(), excludedContainerIDS);
Assert.assertEquals(container1.getContainerInfo().getContainerID(), info.getContainerID());
}
use of org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline in project ozone by apache.
the class TestContainerStateManagerIntegration method testCreateContainerLogicWithExcludedList.
@Test
public void testCreateContainerLogicWithExcludedList() throws IOException {
long cid;
ContainerWithPipeline container1 = scm.getClientProtocolServer().allocateContainer(SCMTestUtils.getReplicationType(conf), SCMTestUtils.getReplicationFactor(conf), OzoneConsts.OZONE);
cid = container1.getContainerInfo().getContainerID();
for (int i = 1; i < numContainerPerOwnerInPipeline; i++) {
ContainerInfo info = containerManager.getMatchingContainer(OzoneConsts.GB * 3, OzoneConsts.OZONE, container1.getPipeline(), excludedContainerIDS);
Assert.assertTrue(info.getContainerID() > cid);
cid = info.getContainerID();
}
ContainerInfo info = containerManager.getMatchingContainer(OzoneConsts.GB * 3, OzoneConsts.OZONE, container1.getPipeline(), new HashSet<>(Arrays.asList(ContainerID.valueOf(1), ContainerID.valueOf(2), ContainerID.valueOf(3))));
Assert.assertEquals(info.getContainerID(), 4);
}
use of org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline in project ozone by apache.
the class TestContainerStateManagerIntegration method testGetMatchingContainerWithExcludedList.
@Test
public void testGetMatchingContainerWithExcludedList() throws IOException {
long cid;
ContainerWithPipeline container1 = scm.getClientProtocolServer().allocateContainer(SCMTestUtils.getReplicationType(conf), SCMTestUtils.getReplicationFactor(conf), OzoneConsts.OZONE);
cid = container1.getContainerInfo().getContainerID();
// containers.
for (int i = 1; i < numContainerPerOwnerInPipeline; i++) {
ContainerInfo info = containerManager.getMatchingContainer(OzoneConsts.GB * 3, OzoneConsts.OZONE, container1.getPipeline(), excludedContainerIDS);
Assert.assertTrue(info.getContainerID() > cid);
cid = info.getContainerID();
}
// At this point there are already three containers in the pipeline.
// next container should be the same as first container
ContainerInfo info = containerManager.getMatchingContainer(OzoneConsts.GB * 3, OzoneConsts.OZONE, container1.getPipeline(), new HashSet<>(Collections.singletonList(ContainerID.valueOf(1))));
Assert.assertNotEquals(container1.getContainerInfo().getContainerID(), info.getContainerID());
}
Aggregations