mumrah commented on a change in pull request #10913:
URL: https://github.com/apache/kafka/pull/10913#discussion_r660029217



##########
File path: raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java
##########
@@ -2250,7 +2249,40 @@ private Long append(int epoch, List<T> records, boolean 
isAtomic) {
 
     @Override
     public void resign(int epoch) {
-        throw new UnsupportedOperationException();
+        if (epoch < 0) {
+            throw new IllegalArgumentException("Attempt to resign from an 
invalid negative epoch " + epoch);
+        }
+
+        if (!quorum.isVoter()) {
+            throw new IllegalArgumentException("Attempt to resign by a 
non-voter");
+        }
+
+        LeaderAndEpoch leaderAndEpoch = leaderAndEpoch();
+        int currentEpoch = leaderAndEpoch.epoch();
+
+        if (epoch > currentEpoch) {
+            throw new IllegalArgumentException("Attempt to resign from epoch " 
+ epoch +
+                " which is larger than the current epoch " + currentEpoch);
+        } else if (epoch < currentEpoch) {
+            // If the passed epoch is smaller than the current epoch, then it 
might mean
+            // that the listener has not been notified about a leader change 
that already
+            // took place. In this case, we consider the call as already 
fulfilled and
+            // take no further action.
+            return;
+        } else if (!leaderAndEpoch.isLeader(quorum.localIdOrThrow())) {

Review comment:
       I see what you mean, and yea that is a fair point 👍 




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