use of org.apache.hadoop.ozone.container.common.transport.server.ratis.XceiverServerRatis 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.ozone.container.common.transport.server.ratis.XceiverServerRatis in project ozone by apache.
the class TestContainerStateMachineFailures method testContainerStateMachineCloseOnMissingPipeline.
@Test
public void testContainerStateMachineCloseOnMissingPipeline() throws Exception {
// This integration test is a bit of a hack to see if the highly
// improbable event where the Datanode does not have the pipeline
// in its Ratis channel but still receives a close container command
// for a container that is open or in closing state.
// Bugs in code can lead to this sequence of events but for this test
// to inject this state, it removes the pipeline by directly calling
// the underlying method.
OzoneOutputStream key = objectStore.getVolume(volumeName).getBucket(bucketName).createKey("testQuasiClosed1", 1024, ReplicationType.RATIS, ReplicationFactor.THREE, new HashMap<>());
key.write("ratis".getBytes(UTF_8));
key.flush();
KeyOutputStream groupOutputStream = (KeyOutputStream) key.getOutputStream();
List<OmKeyLocationInfo> locationInfoList = groupOutputStream.getLocationInfoList();
Assert.assertEquals(1, locationInfoList.size());
OmKeyLocationInfo omKeyLocationInfo = locationInfoList.get(0);
Set<HddsDatanodeService> datanodeSet = TestHelper.getDatanodeServices(cluster, omKeyLocationInfo.getPipeline());
long containerID = omKeyLocationInfo.getContainerID();
for (HddsDatanodeService dn : datanodeSet) {
XceiverServerRatis wc = (XceiverServerRatis) dn.getDatanodeStateMachine().getContainer().getWriteChannel();
if (wc == null) {
// Test applicable only for RATIS based channel.
return;
}
wc.notifyGroupRemove(RaftGroupId.valueOf(omKeyLocationInfo.getPipeline().getId().getId()));
SCMCommand<?> command = new CloseContainerCommand(containerID, omKeyLocationInfo.getPipeline().getId());
command.setTerm(cluster.getStorageContainerManager().getScmContext().getTermOfLeader());
cluster.getStorageContainerManager().getScmNodeManager().addDatanodeCommand(dn.getDatanodeDetails().getUuid(), command);
}
for (HddsDatanodeService dn : datanodeSet) {
LambdaTestUtils.await(20000, 1000, () -> (dn.getDatanodeStateMachine().getContainer().getContainerSet().getContainer(containerID).getContainerState().equals(QUASI_CLOSED)));
}
key.close();
}
use of org.apache.hadoop.ozone.container.common.transport.server.ratis.XceiverServerRatis in project ozone by apache.
the class TestHelper method waitForPipelineClose.
public static void waitForPipelineClose(List<Pipeline> pipelineList, MiniOzoneCluster cluster) throws TimeoutException, InterruptedException, IOException {
for (Pipeline pipeline1 : pipelineList) {
// issue pipeline destroy command
cluster.getStorageContainerManager().getPipelineManager().closePipeline(pipeline1, false);
}
// wait for the pipeline to get destroyed in the datanodes
for (Pipeline pipeline : pipelineList) {
HddsProtos.PipelineID pipelineId = pipeline.getId().getProtobuf();
for (DatanodeDetails dn : pipeline.getNodes()) {
XceiverServerSpi server = cluster.getHddsDatanodes().get(cluster.getHddsDatanodeIndex(dn)).getDatanodeStateMachine().getContainer().getWriteChannel();
Assert.assertTrue(server instanceof XceiverServerRatis);
GenericTestUtils.waitFor(() -> !server.isExist(pipelineId), 100, 30_000);
}
}
}
use of org.apache.hadoop.ozone.container.common.transport.server.ratis.XceiverServerRatis in project ozone by apache.
the class TestHelper method createPipelineOnDatanode.
public static void createPipelineOnDatanode(Pipeline pipeline, MiniOzoneCluster cluster) throws IOException {
// wait for the pipeline to get destroyed in the datanodes
for (DatanodeDetails dn : pipeline.getNodes()) {
XceiverServerSpi server = cluster.getHddsDatanodes().get(cluster.getHddsDatanodeIndex(dn)).getDatanodeStateMachine().getContainer().getWriteChannel();
Assert.assertTrue(server instanceof XceiverServerRatis);
try {
server.addGroup(pipeline.getId().getProtobuf(), Collections.unmodifiableList(pipeline.getNodes()));
} catch (Exception e) {
// ignore exception
}
}
}
use of org.apache.hadoop.ozone.container.common.transport.server.ratis.XceiverServerRatis in project ozone by apache.
the class TestRatisPipelineLeader method verifyLeaderInfo.
private boolean verifyLeaderInfo(Pipeline ratisPipeline) throws Exception {
Optional<HddsDatanodeService> hddsDatanodeService = cluster.getHddsDatanodes().stream().filter(s -> s.getDatanodeStateMachine().getDatanodeDetails().getUuid().equals(ratisPipeline.getLeaderId())).findFirst();
Assert.assertTrue(hddsDatanodeService.isPresent());
XceiverServerRatis serverRatis = (XceiverServerRatis) hddsDatanodeService.get().getDatanodeStateMachine().getContainer().getWriteChannel();
GroupInfoRequest groupInfoRequest = new GroupInfoRequest(ClientId.randomId(), serverRatis.getServer().getId(), RaftGroupId.valueOf(ratisPipeline.getId().getId()), 100);
GroupInfoReply reply = serverRatis.getServer().getGroupInfo(groupInfoRequest);
return reply.getRoleInfoProto().hasLeaderInfo() && ratisPipeline.getLeaderId().toString().equals(reply.getRoleInfoProto().getSelf().getId().toStringUtf8());
}
Aggregations