Search in sources :

Example 1 with SCMHeartbeatResponseProto

use of org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMHeartbeatResponseProto 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 SCMHeartbeatResponseProto

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

the class HeartbeatEndpointTask method call.

/**
 * Computes a result, or throws an exception if unable to do so.
 *
 * @return computed result
 * @throws Exception if unable to compute a result
 */
@Override
public EndpointStateMachine.EndPointStates call() throws Exception {
    rpcEndpoint.lock();
    SCMHeartbeatRequestProto.Builder requestBuilder = null;
    try {
        Preconditions.checkState(this.datanodeDetailsProto != null);
        LayoutVersionProto layoutinfo = toLayoutVersionProto(layoutVersionManager.getMetadataLayoutVersion(), layoutVersionManager.getSoftwareLayoutVersion());
        requestBuilder = SCMHeartbeatRequestProto.newBuilder().setDatanodeDetails(datanodeDetailsProto).setDataNodeLayoutVersion(layoutinfo);
        addReports(requestBuilder);
        addContainerActions(requestBuilder);
        addPipelineActions(requestBuilder);
        SCMHeartbeatRequestProto request = requestBuilder.build();
        if (LOG.isDebugEnabled()) {
            LOG.debug("Sending heartbeat message :: {}", request.toString());
        }
        SCMHeartbeatResponseProto response = rpcEndpoint.getEndPoint().sendHeartbeat(request);
        processResponse(response, datanodeDetailsProto);
        rpcEndpoint.setLastSuccessfulHeartbeat(ZonedDateTime.now());
        rpcEndpoint.zeroMissedCount();
    } catch (IOException ex) {
        Preconditions.checkState(requestBuilder != null);
        // put back the reports which failed to be sent
        putBackIncrementalReports(requestBuilder);
        rpcEndpoint.logIfNeeded(ex);
    } finally {
        rpcEndpoint.unlock();
    }
    return rpcEndpoint.getState();
}
Also used : SCMHeartbeatRequestProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMHeartbeatRequestProto) UpgradeUtils.toLayoutVersionProto(org.apache.hadoop.ozone.container.upgrade.UpgradeUtils.toLayoutVersionProto) LayoutVersionProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.LayoutVersionProto) SCMHeartbeatResponseProto(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMHeartbeatResponseProto) IOException(java.io.IOException)

Example 3 with SCMHeartbeatResponseProto

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

the class TestEndPoint method testHeartbeatWithCommandStatusReport.

@Test
public void testHeartbeatWithCommandStatusReport() throws Exception {
    DatanodeDetails dataNode = randomDatanodeDetails();
    try (EndpointStateMachine rpcEndPoint = createEndpoint(SCMTestUtils.getConf(), serverAddress, 1000)) {
        // Add some scmCommands for heartbeat response
        addScmCommands();
        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);
        assertNotNull(responseProto);
        assertEquals(3, responseProto.getCommandsCount());
        assertEquals(0, scmServerImpl.getCommandStatusReportCount());
        // Send heartbeat again from heartbeat endpoint task
        final StateContext stateContext = heartbeatTaskHelper(serverAddress, 3000);
        Map<Long, CommandStatus> map = stateContext.getCommandStatusMap();
        assertNotNull(map);
        assertEquals("Should have 1 objects", 1, map.size());
        assertTrue(map.containsKey(3L));
        assertEquals(Type.deleteBlocksCommand, map.get(3L).getType());
        assertEquals(Status.PENDING, map.get(3L).getStatus());
        scmServerImpl.clearScmCommandRequests();
    }
}
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) StateContext(org.apache.hadoop.ozone.container.common.statemachine.StateContext) CommandStatus(org.apache.hadoop.ozone.protocol.commands.CommandStatus) Test(org.junit.Test)

Aggregations

SCMHeartbeatRequestProto (org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMHeartbeatRequestProto)3 SCMHeartbeatResponseProto (org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMHeartbeatResponseProto)3 DatanodeDetails (org.apache.hadoop.hdds.protocol.DatanodeDetails)2 MockDatanodeDetails.randomDatanodeDetails (org.apache.hadoop.hdds.protocol.MockDatanodeDetails.randomDatanodeDetails)2 EndpointStateMachine (org.apache.hadoop.ozone.container.common.statemachine.EndpointStateMachine)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 LayoutVersionProto (org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.LayoutVersionProto)1 StateContext (org.apache.hadoop.ozone.container.common.statemachine.StateContext)1 UpgradeUtils.toLayoutVersionProto (org.apache.hadoop.ozone.container.upgrade.UpgradeUtils.toLayoutVersionProto)1 CommandStatus (org.apache.hadoop.ozone.protocol.commands.CommandStatus)1