sadanand48 commented on code in PR #11962:
URL: https://github.com/apache/ozone/pull/11962#discussion_r4657277844
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/StateContext.java:
##########
@@ -393,38 +395,66 @@ public int clearCommandStatusReports(HostAndPort
endpoint) {
*/
public List<Message> getAllAvailableReports(
HostAndPort endpoint) {
- return getAllAvailableReportsUpToLimit(endpoint, Integer.MAX_VALUE);
+ List<Message> reports = getFullReports(endpoint, Integer.MAX_VALUE);
+ reports.addAll(getIncrementalReports(endpoint, Integer.MAX_VALUE -
reports.size()));
+ return reports;
}
/**
- * Returns up to {@code maxLimit} available reports for the endpoint,
- * removing them from the queue. Any reports beyond the limit stay queued
- * and are returned by a later call; callers can use {@link
- * #hasPendingReports(HostAndPort)} to detect that case and schedule a
- * follow-up heartbeat.
- *
- * @return List of reports
+ * Returns available reports other than command status reports. Full reports
+ * are selected before incremental reports, and the total number returned is
+ * capped by {@code maxLimit}.
*/
- public List<Message> getAllAvailableReports(
+ public List<Message> getAvailableNonCommandStatusReports(
HostAndPort endpoint, int maxLimit) {
- return getAllAvailableReportsUpToLimit(endpoint, maxLimit);
+ List<Message> reports = getFullReports(endpoint, maxLimit);
+ reports.addAll(getIncrementalReportsExcludingCommandStatus(
+ endpoint, maxLimit - reports.size()));
+ return reports;
}
/**
- * Returns true if any reports are still queued for the endpoint.
+ * Selects command status reports within both the report count and serialized
+ * byte limits.
*/
- public boolean hasPendingReports(HostAndPort endpoint) {
+ public CommandStatusReportSelection getCommandStatusReports(
+ HostAndPort endpoint, int maxLimit, long maxBytes,
+ long oversizedThreshold) {
+ List<CommandStatusReportsProto> selected = new LinkedList<>();
+ long selectedBytes = 0;
+ long oversizedBytes = 0;
synchronized (incrementalReportsQueue) {
- List<Message> reportsForEndpoint = incrementalReportsQueue.get(endpoint);
- if (reportsForEndpoint != null && !reportsForEndpoint.isEmpty()) {
- return true;
+ List<Message> reportsForEndpoint =
+ incrementalReportsQueue.get(endpoint);
+ if (reportsForEndpoint != null) {
+ Iterator<Message> iterator = reportsForEndpoint.iterator();
+ while (iterator.hasNext() && selected.size() < maxLimit) {
+ Message message = iterator.next();
+ if (!(message instanceof CommandStatusReportsProto)) {
+ continue;
+ }
+
+ CommandStatusReportsProto report =
+ (CommandStatusReportsProto) message;
+ long remainingBytes = maxBytes - selectedBytes;
+ long reportBytes = getCommandStatusReportWireSize(report);
+ if (reportBytes <= remainingBytes) {
+ selected.add(report);
+ selectedBytes += reportBytes;
+ iterator.remove();
+ if (reportBytes > oversizedThreshold) {
+ oversizedBytes = reportBytes;
+ }
+ continue;
+ }
+ if (reportBytes > oversizedThreshold) {
+ oversizedBytes = reportBytes;
+ }
+ break;
Review Comment:
fixed. When command-status reports are pending, the heartbeat now reserves
up to 10% of maxReportsPerHB, capped by the actual pending command-status
count. With the default 10,000 limit, up to 1,000 slots are protected from ICR
saturation
--
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]