Search in sources :

Example 16 with ContainerWithPipeline

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);
}
Also used : XceiverServerRatis(org.apache.hadoop.ozone.container.common.transport.server.ratis.XceiverServerRatis) EventPublisher(org.apache.hadoop.hdds.server.events.EventPublisher) RaftGroupId(org.apache.ratis.protocol.RaftGroupId) ContainerWithPipeline(org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline) EventQueue(org.apache.hadoop.hdds.server.events.EventQueue) ContainerWithPipeline(org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline) PipelineActionsFromDatanode(org.apache.hadoop.hdds.scm.server.SCMDatanodeHeartbeatDispatcher.PipelineActionsFromDatanode) DatanodeDetails(org.apache.hadoop.hdds.protocol.DatanodeDetails) ContainerInfo(org.apache.hadoop.hdds.scm.container.ContainerInfo) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 17 with ContainerWithPipeline

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());
}
Also used : ContainerWithPipeline(org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline) Test(org.junit.Test)

Example 18 with ContainerWithPipeline

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());
}
Also used : ContainerWithPipeline(org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline) Test(org.junit.Test)

Example 19 with ContainerWithPipeline

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);
}
Also used : ContainerWithPipeline(org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline) Test(org.junit.Test)

Example 20 with ContainerWithPipeline

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());
}
Also used : ContainerWithPipeline(org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline) Test(org.junit.Test)

Aggregations

ContainerWithPipeline (org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline)76 Test (org.junit.Test)45 ContainerInfo (org.apache.hadoop.hdds.scm.container.ContainerInfo)27 Pipeline (org.apache.hadoop.hdds.scm.pipeline.Pipeline)25 XceiverClientSpi (org.apache.hadoop.hdds.scm.XceiverClientSpi)21 IOException (java.io.IOException)17 BlockID (org.apache.hadoop.hdds.client.BlockID)16 ArrayList (java.util.ArrayList)15 DatanodeDetails (org.apache.hadoop.hdds.protocol.DatanodeDetails)13 XceiverClientManager (org.apache.hadoop.hdds.scm.XceiverClientManager)13 OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)12 ContainerID (org.apache.hadoop.hdds.scm.container.ContainerID)12 ContainerProtos (org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos)10 XceiverClientReply (org.apache.hadoop.hdds.scm.XceiverClientReply)6 Map (java.util.Map)5 HddsProtos (org.apache.hadoop.hdds.protocol.proto.HddsProtos)5 XceiverClientRatis (org.apache.hadoop.hdds.scm.XceiverClientRatis)5 OmKeyInfo (org.apache.hadoop.ozone.om.helpers.OmKeyInfo)5 OmKeyLocationInfo (org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo)5 StorageContainerServiceProvider (org.apache.hadoop.ozone.recon.spi.StorageContainerServiceProvider)5