AndrewJSchofield commented on code in PR #16963:
URL: https://github.com/apache/kafka/pull/16963#discussion_r1728822928


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerHeartbeatRequestManager.java:
##########
@@ -0,0 +1,286 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.clients.consumer.internals;
+
+import org.apache.kafka.clients.consumer.ConsumerConfig;
+import 
org.apache.kafka.clients.consumer.internals.events.BackgroundEventHandler;
+import 
org.apache.kafka.clients.consumer.internals.metrics.HeartbeatMetricsManager;
+import org.apache.kafka.common.Uuid;
+import org.apache.kafka.common.message.ConsumerGroupHeartbeatRequestData;
+import org.apache.kafka.common.message.ConsumerGroupHeartbeatResponseData;
+import org.apache.kafka.common.metrics.Metrics;
+import org.apache.kafka.common.protocol.Errors;
+import org.apache.kafka.common.requests.ConsumerGroupHeartbeatRequest;
+import org.apache.kafka.common.requests.ConsumerGroupHeartbeatResponse;
+import org.apache.kafka.common.utils.LogContext;
+import org.apache.kafka.common.utils.Time;
+import org.apache.kafka.common.utils.Timer;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.stream.Collectors;
+
+/**
+ * <p>Manages the request creation and response handling for the heartbeat of 
a consumer group. The module creates a
+ * {@link ConsumerGroupHeartbeatRequest} using the state stored in the {@link 
ConsumerMembershipManager} and enqueue it to
+ * the network queue to be sent out. Once the response is received, it updates 
the state in the
+ * {@link ConsumerMembershipManager} and handles any errors.</p>
+ *
+ * <p>The manager will try to send a heartbeat when the member is in {@link 
MemberState#STABLE},
+ * {@link MemberState#JOINING}, or {@link MemberState#RECONCILING}, which 
means the member is either in a stable
+ * group, is trying to join a group, or is in the process of reconciling the 
assignment changes.</p>
+ *
+ * <p>If the member got kicked out of a group, it will try to give up the 
current assignment by invoking {@code
+ * OnPartitionsLost} before attempting to join again with a zero epoch.</p>
+ *
+ * <p>If the member does not have groupId configured or encountering fatal 
exceptions, a heartbeat will not be sent.</p>
+ *
+ * <p>If the coordinator not is not found, we will skip sending the heartbeat 
and try to find a coordinator first.</p>
+ *
+ * <p>If the heartbeat failed due to retriable errors, such as 
TimeoutException, the subsequent attempt will be
+ * backed off exponentially.</p>
+ *
+ * <p>When the member completes the assignment reconciliation, the {@link 
HeartbeatRequestState} will be reset so
+ * that a heartbeat will be sent in the next event loop.</p>
+ *
+ * <p>See {@link AbstractHeartbeatRequestManager.HeartbeatRequestState} for 
more details.</p>

Review Comment:
   I agree. Redundant text removed.



-- 
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]

Reply via email to