brandboat commented on code in PR #20318:
URL: https://github.com/apache/kafka/pull/20318#discussion_r2300625921


##########
raft/src/main/java/org/apache/kafka/raft/LeaderState.java:
##########
@@ -188,6 +189,22 @@ public void resetBeginQuorumEpochTimer(long currentTimeMs) 
{
         beginQuorumEpochTimer.reset(beginQuorumEpochTimeoutMs);
     }
 
+    public void updateLastReceivedFetchRequest(ReplicaKey replicaKey, long 
currentTimeMs) {
+        beginQuorumEpochTimer.update(currentTimeMs);
+        lastFetchRequestMs.put(replicaKey, 
beginQuorumEpochTimer.currentTimeMs());
+    }
+
+    public Set<ReplicaKey> needSendBeginQuorumRequestNodes(long currentTimeMs) 
{
+        Set<ReplicaKey> replicaKeys = new HashSet<>();
+        beginQuorumEpochTimer.update(currentTimeMs);
+        for (Map.Entry<ReplicaKey, Long> entry : 
lastFetchRequestMs.entrySet()) {
+            if (beginQuorumEpochTimer.currentTimeMs() - entry.getValue() >= 
beginQuorumEpochTimeoutMs) {

Review Comment:
   Just curious—since we already have ReplicaState#hasAcknowledgedLeader, which 
indicates whether the follower has acknowledged the current leader, would it 
make sense to use this field instead of relying on a timeout here?



##########
raft/src/main/java/org/apache/kafka/raft/ReplicaKey.java:
##########
@@ -52,6 +52,26 @@ public int compareTo(ReplicaKey that) {
         }
     }
 
+    /**
+     * Determines whether this {@code ReplicaKey} is considered equivalent to 
the given one,
+     * based on the following rules:
+     * <ul>
+     *   <li>The {@code id} fields must be equal.</li>
+     *   <li>If both instances have a {@code directoryId} present, those must 
also be equal.</li>
+     *   <li>If either instance does not have a {@code directoryId}, the 
comparison
+     *       ignores {@code directoryId} and considers them equivalent.</li>
+     * </ul>
+     */
+    public boolean equivalentTo(ReplicaKey that) {

Review Comment:
   Why not use `equals`?



##########
raft/src/main/java/org/apache/kafka/raft/ReplicaKey.java:
##########
@@ -52,6 +52,26 @@ public int compareTo(ReplicaKey that) {
         }
     }
 
+    /**
+     * Determines whether this {@code ReplicaKey} is considered equivalent to 
the given one,
+     * based on the following rules:
+     * <ul>
+     *   <li>The {@code id} fields must be equal.</li>
+     *   <li>If both instances have a {@code directoryId} present, those must 
also be equal.</li>
+     *   <li>If either instance does not have a {@code directoryId}, the 
comparison
+     *       ignores {@code directoryId} and considers them equivalent.</li>
+     * </ul>
+     */
+    public boolean equivalentTo(ReplicaKey that) {

Review Comment:
   Why not use `equals`?



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to