use of org.apache.hadoop.hdds.scm.server.SCMDatanodeHeartbeatDispatcher.CommandStatusReportFromDatanode in project ozone by apache.
the class TestSCMDatanodeHeartbeatDispatcher method testContainerReportDispatcher.
@Test
public void testContainerReportDispatcher() throws IOException {
AtomicInteger eventReceived = new AtomicInteger();
ContainerReportsProto containerReport = ContainerReportsProto.getDefaultInstance();
CommandStatusReportsProto commandStatusReport = CommandStatusReportsProto.getDefaultInstance();
NodeManager mockNodeManager = Mockito.mock(NodeManager.class);
Mockito.when(mockNodeManager.isNodeRegistered(Mockito.any())).thenReturn(true);
SCMDatanodeHeartbeatDispatcher dispatcher = new SCMDatanodeHeartbeatDispatcher(mockNodeManager, new EventPublisher() {
@Override
public <PAYLOAD, EVENT extends Event<PAYLOAD>> void fireEvent(EVENT event, PAYLOAD payload) {
Assert.assertTrue(event.equals(CONTAINER_REPORT) || event.equals(CMD_STATUS_REPORT));
if (payload instanceof ContainerReportFromDatanode) {
Assert.assertEquals(containerReport, ((ContainerReportFromDatanode) payload).getReport());
}
if (payload instanceof CommandStatusReportFromDatanode) {
Assert.assertEquals(commandStatusReport, ((CommandStatusReportFromDatanode) payload).getReport());
}
eventReceived.incrementAndGet();
}
});
DatanodeDetails datanodeDetails = randomDatanodeDetails();
SCMHeartbeatRequestProto heartbeat = SCMHeartbeatRequestProto.newBuilder().setDatanodeDetails(datanodeDetails.getProtoBufMessage()).setContainerReport(containerReport).addCommandStatusReports(commandStatusReport).build();
dispatcher.dispatch(heartbeat);
Assert.assertEquals(2, eventReceived.get());
}
use of org.apache.hadoop.hdds.scm.server.SCMDatanodeHeartbeatDispatcher.CommandStatusReportFromDatanode in project ozone by apache.
the class TestCommandStatusReportHandler method testCommandStatusReport.
@Test
public void testCommandStatusReport() {
GenericTestUtils.LogCapturer logCapturer = GenericTestUtils.LogCapturer.captureLogs(LOG);
CommandStatusReportFromDatanode report = this.getStatusReport(Collections.emptyList());
cmdStatusReportHandler.onMessage(report, this);
assertFalse(logCapturer.getOutput().contains("Delete_Block_Status"));
assertFalse(logCapturer.getOutput().contains("Replicate_Command_Status"));
report = this.getStatusReport(this.getCommandStatusList());
cmdStatusReportHandler.onMessage(report, this);
assertTrue(logCapturer.getOutput().contains("firing event of type " + "Delete_Block_Status"));
assertTrue(logCapturer.getOutput().contains("type: " + "deleteBlocksCommand"));
}
use of org.apache.hadoop.hdds.scm.server.SCMDatanodeHeartbeatDispatcher.CommandStatusReportFromDatanode in project ozone by apache.
the class TestCommandStatusReportHandler method getStatusReport.
private CommandStatusReportFromDatanode getStatusReport(List<CommandStatus> reports) {
CommandStatusReportsProto report = HddsTestUtils.createCommandStatusReport(reports);
DatanodeDetails dn = MockDatanodeDetails.randomDatanodeDetails();
return new SCMDatanodeHeartbeatDispatcher.CommandStatusReportFromDatanode(dn, report);
}
Aggregations