use of org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.PipelineAction 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());
}
use of org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.PipelineAction in project ozone by apache.
the class HeartbeatEndpointTask method addPipelineActions.
/**
* Adds all the pending PipelineActions to the heartbeat.
*
* @param requestBuilder builder to which the report has to be added.
*/
private void addPipelineActions(SCMHeartbeatRequestProto.Builder requestBuilder) {
List<PipelineAction> actions = context.getPendingPipelineAction(rpcEndpoint.getAddress(), maxPipelineActionsPerHB);
if (!actions.isEmpty()) {
PipelineActionsProto pap = PipelineActionsProto.newBuilder().addAllPipelineActions(actions).build();
requestBuilder.setPipelineActions(pap);
}
}
use of org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.PipelineAction 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);
}
}
use of org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.PipelineAction 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());
}
Aggregations