Search in sources :

Example 1 with CommandStatusReportFromDatanode

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());
}
Also used : EventPublisher(org.apache.hadoop.hdds.server.events.EventPublisher) CommandStatusReportFromDatanode(org.apache.hadoop.hdds.scm.server.SCMDatanodeHeartbeatDispatcher.CommandStatusReportFromDatanode) ContainerReportFromDatanode(org.apache.hadoop.hdds.scm.server.SCMDatanodeHeartbeatDispatcher.ContainerReportFromDatanode) SCMHeartbeatRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMHeartbeatRequestProto) NodeManager(org.apache.hadoop.hdds.scm.node.NodeManager) ContainerReportsProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerReportsProto) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MockDatanodeDetails.randomDatanodeDetails(org.apache.hadoop.hdds.protocol.MockDatanodeDetails.randomDatanodeDetails) DatanodeDetails(org.apache.hadoop.hdds.protocol.DatanodeDetails) CommandStatusReportsProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.CommandStatusReportsProto) Test(org.junit.Test)

Example 2 with CommandStatusReportFromDatanode

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"));
}
Also used : CommandStatusReportFromDatanode(org.apache.hadoop.hdds.scm.server.SCMDatanodeHeartbeatDispatcher.CommandStatusReportFromDatanode) GenericTestUtils(org.apache.ozone.test.GenericTestUtils) Test(org.junit.Test)

Example 3 with CommandStatusReportFromDatanode

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);
}
Also used : CommandStatusReportFromDatanode(org.apache.hadoop.hdds.scm.server.SCMDatanodeHeartbeatDispatcher.CommandStatusReportFromDatanode) DatanodeDetails(org.apache.hadoop.hdds.protocol.DatanodeDetails) MockDatanodeDetails(org.apache.hadoop.hdds.protocol.MockDatanodeDetails) CommandStatusReportsProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.CommandStatusReportsProto)

Aggregations

CommandStatusReportFromDatanode (org.apache.hadoop.hdds.scm.server.SCMDatanodeHeartbeatDispatcher.CommandStatusReportFromDatanode)3 DatanodeDetails (org.apache.hadoop.hdds.protocol.DatanodeDetails)2 CommandStatusReportsProto (org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.CommandStatusReportsProto)2 Test (org.junit.Test)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 MockDatanodeDetails (org.apache.hadoop.hdds.protocol.MockDatanodeDetails)1 MockDatanodeDetails.randomDatanodeDetails (org.apache.hadoop.hdds.protocol.MockDatanodeDetails.randomDatanodeDetails)1 ContainerReportsProto (org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerReportsProto)1 SCMHeartbeatRequestProto (org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMHeartbeatRequestProto)1 NodeManager (org.apache.hadoop.hdds.scm.node.NodeManager)1 ContainerReportFromDatanode (org.apache.hadoop.hdds.scm.server.SCMDatanodeHeartbeatDispatcher.ContainerReportFromDatanode)1 EventPublisher (org.apache.hadoop.hdds.server.events.EventPublisher)1 GenericTestUtils (org.apache.ozone.test.GenericTestUtils)1