abbccdda commented on a change in pull request #9871:
URL: https://github.com/apache/kafka/pull/9871#discussion_r557722131



##########
File path: raft/src/test/java/org/apache/kafka/raft/KafkaRaftClientTest.java
##########
@@ -2182,6 +2182,46 @@ public void 
testHandleCommitCallbackFiresInCandidateState() throws Exception {
         assertEquals(OptionalInt.empty(), 
secondListener.currentClaimedEpoch());
     }
 
+    @Test
+    public void testObserverFetchWithNoLocalId() throws Exception {
+        // When no `localId` is defined, the client will behave as an observer.

Review comment:
       Wondering whether we could copy this comment to the raft client localId 
field.

##########
File path: raft/src/main/java/org/apache/kafka/raft/QuorumState.java
##########
@@ -125,9 +125,16 @@ public void initialize(OffsetAndEpoch 
logEndOffsetAndEpoch) throws IOException,
         final EpochState initialState;
         if (!election.voters().isEmpty() && !voters.equals(election.voters())) 
{
             throw new IllegalStateException("Configured voter set: " + voters
-                + " is different from the voter set read from the state file: 
" + election.voters() +
-                ". Check if the quorum configuration is up to date, " +
-                "or wipe out the local state file if necessary");
+                + " is different from the voter set read from the state file: 
" + election.voters()
+                + ". Check if the quorum configuration is up to date, "
+                + "or wipe out the local state file if necessary");
+        } else if (election.hasVoted() && !isVoter()) {
+            String localIdDescription = localId.isPresent() ?
+                localId.getAsInt() + " is not a voter" :
+                "is undefined";
+            throw new IllegalStateException("Initialized quorum state " + 
election

Review comment:
       So a node could not transit from follower to observer though restarts?




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

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


Reply via email to