Search in sources :

Example 1 with SCMHeartbeatRequestProto

use of org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMHeartbeatRequestProto in project ozone by apache.

the class TestEndPoint method testHeartbeat.

@Test
public void testHeartbeat() throws Exception {
    DatanodeDetails dataNode = randomDatanodeDetails();
    try (EndpointStateMachine rpcEndPoint = createEndpoint(SCMTestUtils.getConf(), serverAddress, 1000)) {
        SCMHeartbeatRequestProto request = SCMHeartbeatRequestProto.newBuilder().setDatanodeDetails(dataNode.getProtoBufMessage()).setNodeReport(HddsTestUtils.createNodeReport(Arrays.asList(getStorageReports(dataNode.getUuid())), Arrays.asList(getMetadataStorageReports(dataNode.getUuid())))).build();
        SCMHeartbeatResponseProto responseProto = rpcEndPoint.getEndPoint().sendHeartbeat(request);
        Assert.assertNotNull(responseProto);
        Assert.assertEquals(0, responseProto.getCommandsCount());
    }
}
Also used : EndpointStateMachine(org.apache.hadoop.ozone.container.common.statemachine.EndpointStateMachine) SCMHeartbeatRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMHeartbeatRequestProto) MockDatanodeDetails.randomDatanodeDetails(org.apache.hadoop.hdds.protocol.MockDatanodeDetails.randomDatanodeDetails) DatanodeDetails(org.apache.hadoop.hdds.protocol.DatanodeDetails) SCMHeartbeatResponseProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMHeartbeatResponseProto) Test(org.junit.Test)

Example 2 with SCMHeartbeatRequestProto

use of org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMHeartbeatRequestProto in project ozone by apache.

the class TestHeartbeatEndpointTask method testheartbeatWithoutReports.

@Test
public void testheartbeatWithoutReports() throws Exception {
    StorageContainerDatanodeProtocolClientSideTranslatorPB scm = Mockito.mock(StorageContainerDatanodeProtocolClientSideTranslatorPB.class);
    ArgumentCaptor<SCMHeartbeatRequestProto> argument = ArgumentCaptor.forClass(SCMHeartbeatRequestProto.class);
    Mockito.when(scm.sendHeartbeat(argument.capture())).thenAnswer(invocation -> SCMHeartbeatResponseProto.newBuilder().setDatanodeUUID(((SCMHeartbeatRequestProto) invocation.getArgument(0)).getDatanodeDetails().getUuid()).build());
    HeartbeatEndpointTask endpointTask = getHeartbeatEndpointTask(scm);
    endpointTask.call();
    SCMHeartbeatRequestProto heartbeat = argument.getValue();
    Assert.assertTrue(heartbeat.hasDatanodeDetails());
    Assert.assertFalse(heartbeat.hasNodeReport());
    Assert.assertFalse(heartbeat.hasContainerReport());
    Assert.assertTrue(heartbeat.getCommandStatusReportsCount() == 0);
    Assert.assertFalse(heartbeat.hasContainerActions());
}
Also used : SCMHeartbeatRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMHeartbeatRequestProto) StorageContainerDatanodeProtocolClientSideTranslatorPB(org.apache.hadoop.ozone.protocolPB.StorageContainerDatanodeProtocolClientSideTranslatorPB) Test(org.junit.Test)

Example 3 with SCMHeartbeatRequestProto

use of org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMHeartbeatRequestProto in project ozone by apache.

the class TestHeartbeatEndpointTask method testheartbeatWithContainerActions.

@Test
public void testheartbeatWithContainerActions() throws Exception {
    OzoneConfiguration conf = new OzoneConfiguration();
    StateContext context = new StateContext(conf, DatanodeStates.RUNNING, Mockito.mock(DatanodeStateMachine.class));
    StorageContainerDatanodeProtocolClientSideTranslatorPB scm = Mockito.mock(StorageContainerDatanodeProtocolClientSideTranslatorPB.class);
    ArgumentCaptor<SCMHeartbeatRequestProto> argument = ArgumentCaptor.forClass(SCMHeartbeatRequestProto.class);
    Mockito.when(scm.sendHeartbeat(argument.capture())).thenAnswer(invocation -> SCMHeartbeatResponseProto.newBuilder().setDatanodeUUID(((SCMHeartbeatRequestProto) invocation.getArgument(0)).getDatanodeDetails().getUuid()).build());
    HeartbeatEndpointTask endpointTask = getHeartbeatEndpointTask(conf, context, scm);
    context.addEndpoint(TEST_SCM_ENDPOINT);
    context.addContainerAction(getContainerAction());
    endpointTask.call();
    SCMHeartbeatRequestProto heartbeat = argument.getValue();
    Assert.assertTrue(heartbeat.hasDatanodeDetails());
    Assert.assertFalse(heartbeat.hasNodeReport());
    Assert.assertFalse(heartbeat.hasContainerReport());
    Assert.assertTrue(heartbeat.getCommandStatusReportsCount() == 0);
    Assert.assertTrue(heartbeat.hasContainerActions());
}
Also used : SCMHeartbeatRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMHeartbeatRequestProto) StorageContainerDatanodeProtocolClientSideTranslatorPB(org.apache.hadoop.ozone.protocolPB.StorageContainerDatanodeProtocolClientSideTranslatorPB) StateContext(org.apache.hadoop.ozone.container.common.statemachine.StateContext) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) DatanodeStateMachine(org.apache.hadoop.ozone.container.common.statemachine.DatanodeStateMachine) Test(org.junit.Test)

Example 4 with SCMHeartbeatRequestProto

use of org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMHeartbeatRequestProto in project ozone by apache.

the class TestHeartbeatEndpointTask method testheartbeatWithCommandStatusReports.

@Test
public void testheartbeatWithCommandStatusReports() throws Exception {
    OzoneConfiguration conf = new OzoneConfiguration();
    StateContext context = new StateContext(conf, DatanodeStates.RUNNING, Mockito.mock(DatanodeStateMachine.class));
    StorageContainerDatanodeProtocolClientSideTranslatorPB scm = Mockito.mock(StorageContainerDatanodeProtocolClientSideTranslatorPB.class);
    ArgumentCaptor<SCMHeartbeatRequestProto> argument = ArgumentCaptor.forClass(SCMHeartbeatRequestProto.class);
    Mockito.when(scm.sendHeartbeat(argument.capture())).thenAnswer(invocation -> SCMHeartbeatResponseProto.newBuilder().setDatanodeUUID(((SCMHeartbeatRequestProto) invocation.getArgument(0)).getDatanodeDetails().getUuid()).build());
    HeartbeatEndpointTask endpointTask = getHeartbeatEndpointTask(conf, context, scm);
    context.addEndpoint(TEST_SCM_ENDPOINT);
    context.addIncrementalReport(CommandStatusReportsProto.getDefaultInstance());
    endpointTask.call();
    SCMHeartbeatRequestProto heartbeat = argument.getValue();
    Assert.assertTrue(heartbeat.hasDatanodeDetails());
    Assert.assertFalse(heartbeat.hasNodeReport());
    Assert.assertFalse(heartbeat.hasContainerReport());
    Assert.assertTrue(heartbeat.getCommandStatusReportsCount() != 0);
    Assert.assertFalse(heartbeat.hasContainerActions());
}
Also used : SCMHeartbeatRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMHeartbeatRequestProto) StorageContainerDatanodeProtocolClientSideTranslatorPB(org.apache.hadoop.ozone.protocolPB.StorageContainerDatanodeProtocolClientSideTranslatorPB) StateContext(org.apache.hadoop.ozone.container.common.statemachine.StateContext) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) DatanodeStateMachine(org.apache.hadoop.ozone.container.common.statemachine.DatanodeStateMachine) Test(org.junit.Test)

Example 5 with SCMHeartbeatRequestProto

use of org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMHeartbeatRequestProto in project ozone by apache.

the class TestHeartbeatEndpointTask method testheartbeatWithNodeReports.

@Test
public void testheartbeatWithNodeReports() throws Exception {
    OzoneConfiguration conf = new OzoneConfiguration();
    StateContext context = new StateContext(conf, DatanodeStates.RUNNING, Mockito.mock(DatanodeStateMachine.class));
    StorageContainerDatanodeProtocolClientSideTranslatorPB scm = Mockito.mock(StorageContainerDatanodeProtocolClientSideTranslatorPB.class);
    ArgumentCaptor<SCMHeartbeatRequestProto> argument = ArgumentCaptor.forClass(SCMHeartbeatRequestProto.class);
    Mockito.when(scm.sendHeartbeat(argument.capture())).thenAnswer(invocation -> SCMHeartbeatResponseProto.newBuilder().setDatanodeUUID(((SCMHeartbeatRequestProto) invocation.getArgument(0)).getDatanodeDetails().getUuid()).build());
    HeartbeatEndpointTask endpointTask = getHeartbeatEndpointTask(conf, context, scm);
    context.addEndpoint(TEST_SCM_ENDPOINT);
    context.refreshFullReport(NodeReportProto.getDefaultInstance());
    endpointTask.call();
    SCMHeartbeatRequestProto heartbeat = argument.getValue();
    Assert.assertTrue(heartbeat.hasDatanodeDetails());
    Assert.assertTrue(heartbeat.hasNodeReport());
    Assert.assertFalse(heartbeat.hasContainerReport());
    Assert.assertTrue(heartbeat.getCommandStatusReportsCount() == 0);
    Assert.assertFalse(heartbeat.hasContainerActions());
}
Also used : SCMHeartbeatRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMHeartbeatRequestProto) StorageContainerDatanodeProtocolClientSideTranslatorPB(org.apache.hadoop.ozone.protocolPB.StorageContainerDatanodeProtocolClientSideTranslatorPB) StateContext(org.apache.hadoop.ozone.container.common.statemachine.StateContext) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) DatanodeStateMachine(org.apache.hadoop.ozone.container.common.statemachine.DatanodeStateMachine) Test(org.junit.Test)

Aggregations

SCMHeartbeatRequestProto (org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMHeartbeatRequestProto)14 Test (org.junit.Test)11 StateContext (org.apache.hadoop.ozone.container.common.statemachine.StateContext)6 StorageContainerDatanodeProtocolClientSideTranslatorPB (org.apache.hadoop.ozone.protocolPB.StorageContainerDatanodeProtocolClientSideTranslatorPB)6 OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)5 DatanodeDetails (org.apache.hadoop.hdds.protocol.DatanodeDetails)5 MockDatanodeDetails.randomDatanodeDetails (org.apache.hadoop.hdds.protocol.MockDatanodeDetails.randomDatanodeDetails)5 DatanodeStateMachine (org.apache.hadoop.ozone.container.common.statemachine.DatanodeStateMachine)5 SCMHeartbeatResponseProto (org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMHeartbeatResponseProto)3 NodeManager (org.apache.hadoop.hdds.scm.node.NodeManager)3 EventPublisher (org.apache.hadoop.hdds.server.events.EventPublisher)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 EndpointStateMachine (org.apache.hadoop.ozone.container.common.statemachine.EndpointStateMachine)2 IOException (java.io.IOException)1 UUID (java.util.UUID)1 CommandStatusReportsProto (org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.CommandStatusReportsProto)1 ContainerReportsProto (org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerReportsProto)1 LayoutVersionProto (org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.LayoutVersionProto)1 NodeReportProto (org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.NodeReportProto)1 CommandStatusReportFromDatanode (org.apache.hadoop.hdds.scm.server.SCMDatanodeHeartbeatDispatcher.CommandStatusReportFromDatanode)1