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);
}
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) {
}
}
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());
}
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));
}
Aggregations