lh0156 commented on code in PR #22203:
URL: https://github.com/apache/kafka/pull/22203#discussion_r3251589557


##########
raft/src/main/java/org/apache/kafka/raft/LeaderState.java:
##########
@@ -72,6 +72,7 @@ public class LeaderState<T> implements EpochState {
     // This field is non-empty if the voter set at epoch start came from a 
snapshot or log segment
     private final OptionalLong offsetOfVotersAtEpochStart;
     private final KRaftVersion kraftVersionAtEpochStart;
+    private final Optional<ReplicaKey> votedKey;

Review Comment:
   Done. I added a brief Javadoc explaining that this is the vote recorded in 
the epoch and retained after the candidate becomes leader.



##########
raft/src/main/java/org/apache/kafka/raft/LeaderState.java:
##########
@@ -72,6 +72,7 @@ public class LeaderState<T> implements EpochState {
     // This field is non-empty if the voter set at epoch start came from a 
snapshot or log segment
     private final OptionalLong offsetOfVotersAtEpochStart;
     private final KRaftVersion kraftVersionAtEpochStart;
+    private final Optional<ReplicaKey> votedKey;

Review Comment:
   Done. I added votedKey to LeaderState.toString() for consistency with the 
other raft states.



##########
raft/src/main/java/org/apache/kafka/raft/LeaderState.java:
##########
@@ -687,7 +690,7 @@ public Optional<LogOffsetMetadata> highWatermark() {
 
     @Override
     public ElectionState election() {
-        return ElectionState.withElectedLeader(epoch, 
localVoterNode.voterKey().id(), Optional.empty(), voterStates.keySet());
+        return ElectionState.withElectedLeader(epoch, 
localVoterNode.voterKey().id(), votedKey, voterStates.keySet());

Review Comment:
   Done. I added a direct assertion in QuorumStateTest#testCandidateToLeader to 
verify that LeaderState.election() returns the preserved votedKey.



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