smengcl commented on code in PR #11423:
URL: https://github.com/apache/ozone/pull/11423#discussion_r4366234872


##########
hadoop-hdds/common/src/main/resources/ozone-default.xml:
##########
@@ -1864,6 +1864,15 @@
       single heartbeat.
     </description>
   </property>
+  <property>
+    <name>hdds.container.report.max.limit</name>
+    <value>10000</value>
+    <tag>DATANODE</tag>
+    <description>
+      Maximum number of reports a datanode includes in a single heartbeat to
+      an SCM endpoint.

Review Comment:
   nit: It also applies to the Recon endpoint, not only SCM.
   
   ```suggestion
         Maximum number of report messages (not containers) a datanode includes
         in a single heartbeat to an SCM or Recon endpoint. Reports beyond the
         limit stay queued and are sent in an immediate follow-up heartbeat.
         Values below 1 are treated as 1.
   ```



##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HddsConfigKeys.java:
##########
@@ -67,6 +67,11 @@ public final class HddsConfigKeys {
       "hdds.pipeline.action.max.limit";
   public static final int HDDS_PIPELINE_ACTION_MAX_LIMIT_DEFAULT =
       20;
+  // Maximum number of reports (full + incremental) a datanode includes in a 
single heartbeat.
+  public static final String HDDS_CONTAINER_REPORT_MAX_LIMIT =
+      "hdds.container.report.max.limit";

Review Comment:
   The name reads as a cap on container reports (or containers per report), but 
it caps every report message in the heartbeat: node, pipeline, command status, 
FCR and ICR. Rename it under the existing `hdds.heartbeat.*` keys before it 
ships, and update the constant names and `ozone-default.xml` to match.
   
   ```suggestion
         "hdds.heartbeat.report.max.limit";
   ```



##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/states/endpoint/TestHeartbeatEndpointTask.java:
##########
@@ -396,6 +402,88 @@ public void testheartbeatWithAllReports() throws Exception 
{
     }
   }
 
+  @Test
+  public void testHeartbeatCapsReportsAndSchedulesFollowup() throws Exception {
+    OzoneConfiguration conf = new OzoneConfiguration();
+    conf.setInt(HDDS_CONTAINER_REPORT_MAX_LIMIT, 2);
+    DatanodeStateMachine datanodeStateMachine = mockDatanodeStateMachine();
+    StateContext context = new StateContext(conf, DatanodeStates.RUNNING,
+        datanodeStateMachine, "");
+
+    when(datanodeStateMachine.getQueuedCommandCount())
+        .thenReturn(new EnumCounters<>(SCMCommandProto.Type.class));
+
+    StorageContainerDatanodeProtocolClientSideTranslatorPB scm =
+        mock(StorageContainerDatanodeProtocolClientSideTranslatorPB.class);
+    ArgumentCaptor<SCMHeartbeatRequestProto> argument = ArgumentCaptor
+        .forClass(SCMHeartbeatRequestProto.class);
+    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);
+    // Queue more ICRs than the per-heartbeat limit.
+    for (int i = 0; i < 5; i++) {
+      context.addIncrementalReport(
+          IncrementalContainerReportProto.getDefaultInstance());
+    }
+
+    endpointTask.call();
+
+    // Only the capped number of ICRs is sent in this heartbeat.
+    SCMHeartbeatRequestProto heartbeat = argument.getValue();
+    assertEquals(2, heartbeat.getIncrementalContainerReportCount());
+    // The remainder stays queued and a follow-up heartbeat is scheduled now.
+    assertTrue(context.hasPendingReports(TEST_SCM_ENDPOINT));
+    verify(datanodeStateMachine).setNextHB(anyLong());

Review Comment:
   Add the negative case: once the queue drains, no further follow-up is 
scheduled.
   
   ```suggestion
       verify(datanodeStateMachine).setNextHB(anyLong());
   
       // The follow-ups drain the rest; the last one sends 1 ICR and schedules 
nothing.
       endpointTask.call();
       endpointTask.call();
       assertEquals(1, 
argument.getValue().getIncrementalContainerReportCount());
       assertFalse(context.hasPendingReports(TEST_SCM_ENDPOINT));
       verify(datanodeStateMachine, times(2)).setNextHB(anyLong());
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to