Search in sources :

Example 1 with PipelineActionsFromDatanode

use of org.apache.hadoop.hdds.scm.server.SCMDatanodeHeartbeatDispatcher.PipelineActionsFromDatanode 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 2 with PipelineActionsFromDatanode

use of org.apache.hadoop.hdds.scm.server.SCMDatanodeHeartbeatDispatcher.PipelineActionsFromDatanode in project ozone by apache.

the class TestPipelineClose method testPipelineCloseWithPipelineAction.

@Test
public void testPipelineCloseWithPipelineAction() throws Exception {
    List<DatanodeDetails> dns = ratisContainer.getPipeline().getNodes();
    PipelineActionsFromDatanode pipelineActionsFromDatanode = HddsTestUtils.getPipelineActionFromDatanode(dns.get(0), ratisContainer.getPipeline().getId());
    // send closing action for pipeline
    PipelineActionHandler pipelineActionHandler = new PipelineActionHandler(pipelineManager, SCMContext.emptyContext(), conf);
    pipelineActionHandler.onMessage(pipelineActionsFromDatanode, new EventQueue());
    Thread.sleep(5000);
    OzoneContainer ozoneContainer = cluster.getHddsDatanodes().get(0).getDatanodeStateMachine().getContainer();
    List<PipelineReport> pipelineReports = ozoneContainer.getPipelineReport().getPipelineReportList();
    for (PipelineReport pipelineReport : pipelineReports) {
        // ensure the pipeline is not reported by any dn
        Assert.assertNotEquals(PipelineID.getFromProtobuf(pipelineReport.getPipelineID()), ratisContainer.getPipeline().getId());
    }
    try {
        pipelineManager.getPipeline(ratisContainer.getPipeline().getId());
        Assert.fail("Pipeline should not exist in SCM");
    } catch (PipelineNotFoundException e) {
    }
}
Also used : PipelineReport(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.PipelineReport) PipelineActionsFromDatanode(org.apache.hadoop.hdds.scm.server.SCMDatanodeHeartbeatDispatcher.PipelineActionsFromDatanode) DatanodeDetails(org.apache.hadoop.hdds.protocol.DatanodeDetails) OzoneContainer(org.apache.hadoop.ozone.container.ozoneimpl.OzoneContainer) EventQueue(org.apache.hadoop.hdds.server.events.EventQueue) Test(org.junit.Test)

Example 3 with PipelineActionsFromDatanode

use of org.apache.hadoop.hdds.scm.server.SCMDatanodeHeartbeatDispatcher.PipelineActionsFromDatanode in project ozone by apache.

the class HddsTestUtils method getPipelineActionFromDatanode.

public static PipelineActionsFromDatanode getPipelineActionFromDatanode(DatanodeDetails dn, PipelineID... pipelineIDs) {
    PipelineActionsProto.Builder actionsProtoBuilder = PipelineActionsProto.newBuilder();
    for (PipelineID pipelineID : pipelineIDs) {
        ClosePipelineInfo closePipelineInfo = ClosePipelineInfo.newBuilder().setPipelineID(pipelineID.getProtobuf()).setReason(ClosePipelineInfo.Reason.PIPELINE_FAILED).setDetailedReason("").build();
        actionsProtoBuilder.addPipelineActions(PipelineAction.newBuilder().setClosePipeline(closePipelineInfo).setAction(PipelineAction.Action.CLOSE).build());
    }
    return new PipelineActionsFromDatanode(dn, actionsProtoBuilder.build());
}
Also used : ClosePipelineInfo(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ClosePipelineInfo) PipelineActionsFromDatanode(org.apache.hadoop.hdds.scm.server.SCMDatanodeHeartbeatDispatcher.PipelineActionsFromDatanode) PipelineID(org.apache.hadoop.hdds.scm.pipeline.PipelineID) PipelineActionsProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.PipelineActionsProto)

Example 4 with PipelineActionsFromDatanode

use of org.apache.hadoop.hdds.scm.server.SCMDatanodeHeartbeatDispatcher.PipelineActionsFromDatanode in project ozone by apache.

the class TestPipelineActionHandler method testCloseActionForMissingPipeline.

@Test
public void testCloseActionForMissingPipeline() throws PipelineNotFoundException, NotLeaderException {
    final PipelineManager manager = Mockito.mock(PipelineManager.class);
    final EventQueue queue = Mockito.mock(EventQueue.class);
    Mockito.when(manager.getPipeline(Mockito.any(PipelineID.class))).thenThrow(new PipelineNotFoundException());
    final PipelineActionHandler actionHandler = new PipelineActionHandler(manager, SCMContext.emptyContext(), null);
    final PipelineActionsProto actionsProto = PipelineActionsProto.newBuilder().addPipelineActions(PipelineAction.newBuilder().setClosePipeline(ClosePipelineInfo.newBuilder().setPipelineID(HddsProtos.PipelineID.newBuilder().setId(UUID.randomUUID().toString()).build()).setReason(ClosePipelineInfo.Reason.PIPELINE_FAILED)).setAction(PipelineAction.Action.CLOSE).build()).build();
    final PipelineActionsFromDatanode pipelineActions = new PipelineActionsFromDatanode(MockDatanodeDetails.randomDatanodeDetails(), actionsProto);
    actionHandler.onMessage(pipelineActions, queue);
    Mockito.verify(queue, Mockito.times(1)).fireEvent(Mockito.any(), Mockito.any(CommandForDatanode.class));
}
Also used : CommandForDatanode(org.apache.hadoop.ozone.protocol.commands.CommandForDatanode) PipelineActionsFromDatanode(org.apache.hadoop.hdds.scm.server.SCMDatanodeHeartbeatDispatcher.PipelineActionsFromDatanode) PipelineActionsProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.PipelineActionsProto) EventQueue(org.apache.hadoop.hdds.server.events.EventQueue) Test(org.junit.Test)

Aggregations

PipelineActionsFromDatanode (org.apache.hadoop.hdds.scm.server.SCMDatanodeHeartbeatDispatcher.PipelineActionsFromDatanode)4 EventQueue (org.apache.hadoop.hdds.server.events.EventQueue)3 Test (org.junit.Test)3 DatanodeDetails (org.apache.hadoop.hdds.protocol.DatanodeDetails)2 PipelineActionsProto (org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.PipelineActionsProto)2 ClosePipelineInfo (org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ClosePipelineInfo)1 PipelineReport (org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.PipelineReport)1 ContainerInfo (org.apache.hadoop.hdds.scm.container.ContainerInfo)1 ContainerWithPipeline (org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline)1 PipelineID (org.apache.hadoop.hdds.scm.pipeline.PipelineID)1 EventPublisher (org.apache.hadoop.hdds.server.events.EventPublisher)1 XceiverServerRatis (org.apache.hadoop.ozone.container.common.transport.server.ratis.XceiverServerRatis)1 OzoneContainer (org.apache.hadoop.ozone.container.ozoneimpl.OzoneContainer)1 CommandForDatanode (org.apache.hadoop.ozone.protocol.commands.CommandForDatanode)1 RaftGroupId (org.apache.ratis.protocol.RaftGroupId)1 Ignore (org.junit.Ignore)1