use of org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMHeartbeatRequestProto 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();
}
}
use of org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMHeartbeatRequestProto in project ozone by apache.
the class TestSCMDatanodeHeartbeatDispatcher method testNodeReportDispatcher.
@Test
public void testNodeReportDispatcher() throws IOException {
AtomicInteger eventReceived = new AtomicInteger();
NodeReportProto nodeReport = NodeReportProto.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.assertEquals(event, NODE_REPORT);
eventReceived.incrementAndGet();
Assert.assertEquals(nodeReport, ((NodeReportFromDatanode) payload).getReport());
}
});
DatanodeDetails datanodeDetails = randomDatanodeDetails();
SCMHeartbeatRequestProto heartbeat = SCMHeartbeatRequestProto.newBuilder().setDatanodeDetails(datanodeDetails.getProtoBufMessage()).setNodeReport(nodeReport).build();
dispatcher.dispatch(heartbeat);
Assert.assertEquals(1, eventReceived.get());
}
use of org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMHeartbeatRequestProto in project ozone by apache.
the class TestEndpoints method waitAndCheckConditionAfterHeartbeat.
private void waitAndCheckConditionAfterHeartbeat(Callable<Boolean> check) throws Exception {
// if container report is processed first, and pipeline does not exist
// then container is not added until the next container report is processed
SCMHeartbeatRequestProto heartbeatRequestProto = SCMHeartbeatRequestProto.newBuilder().setContainerReport(containerReportsProto).setDatanodeDetails(extendedDatanodeDetailsProto.getDatanodeDetails()).setDataNodeLayoutVersion(defaultLayoutVersionProto()).build();
reconScm.getDatanodeProtocolServer().sendHeartbeat(heartbeatRequestProto);
LambdaTestUtils.await(30000, 1000, check);
}
use of org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMHeartbeatRequestProto in project ozone by apache.
the class TestOpenContainerCount method waitAndCheckConditionAfterHeartbeat.
private void waitAndCheckConditionAfterHeartbeat(Callable<Boolean> check) throws Exception {
// if container report is processed first, and pipeline does not exist
// then container is not added until the next container report is processed
SCMHeartbeatRequestProto heartbeatRequestProto = SCMHeartbeatRequestProto.newBuilder().setContainerReport(containerReportsProto).setDatanodeDetails(extendedDatanodeDetailsProto.getDatanodeDetails()).build();
reconScm.getDatanodeProtocolServer().sendHeartbeat(heartbeatRequestProto);
LambdaTestUtils.await(30000, 1000, check);
}
Aggregations