cmccabe commented on code in PR #15876:
URL: https://github.com/apache/kafka/pull/15876#discussion_r1599223700


##########
metadata/src/main/java/org/apache/kafka/controller/ReplicationControlManager.java:
##########
@@ -1513,14 +1518,18 @@ ApiError electLeader(String topic, int partitionId, 
ElectionType electionType,
                 "No such partition as " + topic + "-" + partitionId);
         }
         if ((electionType == ElectionType.PREFERRED && 
partition.hasPreferredLeader())
-            || (electionType == ElectionType.UNCLEAN && 
partition.hasLeader())) {
+            || (electionType == ElectionType.UNCLEAN && partition.hasLeader())
+            || (electionType == ElectionType.DESIGNATED && 
partition.getLeader() == desiredLeader)) {
             return new ApiError(Errors.ELECTION_NOT_NEEDED);
         }
 
         PartitionChangeBuilder.Election election = 
PartitionChangeBuilder.Election.PREFERRED;
         if (electionType == ElectionType.UNCLEAN) {
             election = PartitionChangeBuilder.Election.UNCLEAN;
         }
+        if (electionType == ElectionType.DESIGNATED) {

Review Comment:
   It seems like this should be a `switch` statement that handles all the cases.



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