Search in sources :

Example 1 with ClosePipelineInfo

use of org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ClosePipelineInfo in project ozone by apache.

the class XceiverServerRatis method triggerPipelineClose.

private void triggerPipelineClose(RaftGroupId groupId, String detail, ClosePipelineInfo.Reason reasonCode, boolean triggerHB) {
    PipelineID pipelineID = PipelineID.valueOf(groupId.getUuid());
    ClosePipelineInfo.Builder closePipelineInfo = ClosePipelineInfo.newBuilder().setPipelineID(pipelineID.getProtobuf()).setReason(reasonCode).setDetailedReason(detail);
    PipelineAction action = PipelineAction.newBuilder().setClosePipeline(closePipelineInfo).setAction(PipelineAction.Action.CLOSE).build();
    context.addPipelineActionIfAbsent(action);
    // wait for the next HB timeout or right away?
    if (triggerHB) {
        context.getParent().triggerHeartbeat();
    }
    LOG.error("pipeline Action {} on pipeline {}.Reason : {}", action.getAction(), pipelineID, action.getClosePipeline().getDetailedReason());
}
Also used : ClosePipelineInfo(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ClosePipelineInfo) PipelineID(org.apache.hadoop.hdds.scm.pipeline.PipelineID) PipelineAction(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.PipelineAction)

Example 2 with ClosePipelineInfo

use of org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ClosePipelineInfo in project ozone by apache.

the class PipelineActionHandler method processPipelineAction.

/**
 * Process the given PipelineAction.
 *
 * @param datanode the datanode which has sent the PipelineAction
 * @param pipelineAction the PipelineAction
 * @param publisher EventPublisher to fire new events if required
 */
private void processPipelineAction(final DatanodeDetails datanode, final PipelineAction pipelineAction, final EventPublisher publisher) {
    final ClosePipelineInfo info = pipelineAction.getClosePipeline();
    final PipelineAction.Action action = pipelineAction.getAction();
    final PipelineID pid = PipelineID.getFromProtobuf(info.getPipelineID());
    try {
        LOG.info("Received pipeline action {} for {} from datanode {}. " + "Reason : {}", action, pid, datanode.getUuidString(), info.getDetailedReason());
        if (action == PipelineAction.Action.CLOSE) {
            pipelineManager.closePipeline(pipelineManager.getPipeline(pid), false);
        } else {
            LOG.error("unknown pipeline action:{}", action);
        }
    } catch (PipelineNotFoundException e) {
        LOG.warn("Pipeline action {} received for unknown pipeline {}, " + "firing close pipeline event.", action, pid);
        SCMCommand<?> command = new ClosePipelineCommand(pid);
        try {
            command.setTerm(scmContext.getTermOfLeader());
        } catch (NotLeaderException nle) {
            LOG.warn("Skip sending ClosePipelineCommand for pipeline {}," + " since not leader SCM.", pid);
            return;
        }
        publisher.fireEvent(SCMEvents.DATANODE_COMMAND, new CommandForDatanode<>(datanode.getUuid(), command));
    } catch (IOException ioe) {
        LOG.error("Could not execute pipeline action={} pipeline={}", action, pid, ioe);
    }
}
Also used : CommandForDatanode(org.apache.hadoop.ozone.protocol.commands.CommandForDatanode) NotLeaderException(org.apache.ratis.protocol.exceptions.NotLeaderException) ClosePipelineInfo(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ClosePipelineInfo) ClosePipelineCommand(org.apache.hadoop.ozone.protocol.commands.ClosePipelineCommand) IOException(java.io.IOException) PipelineAction(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.PipelineAction) SCMCommand(org.apache.hadoop.ozone.protocol.commands.SCMCommand)

Example 3 with ClosePipelineInfo

use of org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ClosePipelineInfo 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 ClosePipelineInfo

use of org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ClosePipelineInfo in project ozone by apache.

the class TestStateContext method testActionAPIs.

@Test
public void testActionAPIs() {
    OzoneConfiguration conf = new OzoneConfiguration();
    DatanodeStateMachine datanodeStateMachineMock = mock(DatanodeStateMachine.class);
    StateContext stateContext = new StateContext(conf, DatanodeStates.getInitState(), datanodeStateMachineMock);
    InetSocketAddress scm1 = new InetSocketAddress("scm1", 9001);
    InetSocketAddress scm2 = new InetSocketAddress("scm2", 9001);
    // Try to get containerActions for endpoint which is not yet added.
    List<ContainerAction> containerActions = stateContext.getPendingContainerAction(scm1, 10);
    assertTrue(containerActions.isEmpty());
    // Try to get pipelineActions for endpoint which is not yet added.
    List<PipelineAction> pipelineActions = stateContext.getPendingPipelineAction(scm1, 10);
    assertTrue(pipelineActions.isEmpty());
    // Add 2 scm endpoints.
    stateContext.addEndpoint(scm1);
    stateContext.addEndpoint(scm2);
    final ClosePipelineInfo closePipelineInfo = ClosePipelineInfo.newBuilder().setPipelineID(PipelineID.randomId().getProtobuf()).setReason(ClosePipelineInfo.Reason.PIPELINE_FAILED).setDetailedReason("Test").build();
    final PipelineAction pipelineAction = PipelineAction.newBuilder().setClosePipeline(closePipelineInfo).setAction(PipelineAction.Action.CLOSE).build();
    // Add PipelineAction. Should be added to all endpoints.
    stateContext.addPipelineActionIfAbsent(pipelineAction);
    pipelineActions = stateContext.getPendingPipelineAction(scm2, 10);
    assertEquals(1, pipelineActions.size());
    // The pipeline action is dequeued from scm2 now, but still in scm1
    // The same pipeline action will not be added if it already exists
    stateContext.addPipelineActionIfAbsent(pipelineAction);
    pipelineActions = stateContext.getPendingPipelineAction(scm1, 10);
    assertEquals(1, pipelineActions.size());
    // The pipeline action should have been be added back to the scm2
    pipelineActions = stateContext.getPendingPipelineAction(scm2, 10);
    assertEquals(1, pipelineActions.size());
    // Add ContainerAction. Should be added to all endpoints.
    stateContext.addContainerAction(ContainerAction.newBuilder().setAction(CLOSE).setContainerID(100L).build());
    containerActions = stateContext.getPendingContainerAction(scm2, 10);
    assertEquals(1, containerActions.size());
}
Also used : ClosePipelineInfo(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ClosePipelineInfo) ContainerAction(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerAction) InetSocketAddress(java.net.InetSocketAddress) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) PipelineAction(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.PipelineAction) Test(org.junit.Test)

Aggregations

ClosePipelineInfo (org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ClosePipelineInfo)4 PipelineAction (org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.PipelineAction)3 PipelineID (org.apache.hadoop.hdds.scm.pipeline.PipelineID)2 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)1 ContainerAction (org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerAction)1 PipelineActionsProto (org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.PipelineActionsProto)1 PipelineActionsFromDatanode (org.apache.hadoop.hdds.scm.server.SCMDatanodeHeartbeatDispatcher.PipelineActionsFromDatanode)1 ClosePipelineCommand (org.apache.hadoop.ozone.protocol.commands.ClosePipelineCommand)1 CommandForDatanode (org.apache.hadoop.ozone.protocol.commands.CommandForDatanode)1 SCMCommand (org.apache.hadoop.ozone.protocol.commands.SCMCommand)1 NotLeaderException (org.apache.ratis.protocol.exceptions.NotLeaderException)1 Test (org.junit.Test)1