showuon commented on code in PR #16284:
URL: https://github.com/apache/kafka/pull/16284#discussion_r1636432727


##########
metadata/src/main/java/org/apache/kafka/controller/ReplicationControlManager.java:
##########
@@ -2093,6 +2116,50 @@ Optional<ApiMessageAndVersion> 
changePartitionReassignment(TopicIdPartition tp,
         return builder.setDefaultDirProvider(clusterDescriber).build();
     }
 
+    /**
+     * Handle legacy configuration alterations.
+     */
+    ControllerResult<Map<ConfigResource, ApiError>> legacyAlterConfigs(
+            Map<ConfigResource, Map<String, String>> newConfigs) {
+        ControllerResult<Map<ConfigResource, ApiError>> result =
+                configurationControl.legacyAlterConfigs(newConfigs, false);
+        return maybeTriggerUncleanLeaderElection(result);
+    }
+
+    /**
+     * Handle incremental configuration alterations.
+     */
+    ControllerResult<Map<ConfigResource, ApiError>> incrementalAlterConfigs(
+            Map<ConfigResource, Map<String, Entry<OpType, String>>> 
configChanges) {
+        ControllerResult<Map<ConfigResource, ApiError>> result =
+                configurationControl.incrementalAlterConfigs(configChanges, 
false);
+        return maybeTriggerUncleanLeaderElection(result);
+    }
+
+    /**
+     * If "unclean.leader.election.enable" configurations was enabled 
dynamically, generating unclean leader election
+     * records for all the partitions in this topic if necessary.
+     */
+    ControllerResult<Map<ConfigResource, ApiError>> 
maybeTriggerUncleanLeaderElection(
+            ControllerResult<Map<ConfigResource, ApiError>> result) {
+        List<ApiMessageAndVersion> records = new ArrayList<>(result.records());
+        for (ApiMessageAndVersion messageAndVersion : result.records()) {
+            ConfigRecord record = (ConfigRecord) messageAndVersion.message();
+            if (record.name().equals(UNCLEAN_LEADER_ELECTION_ENABLE_CONFIG) && 
"true".equals(record.value())) {
+                String topicName = record.resourceName();

Review Comment:
   Good point! Added in 
https://github.com/apache/kafka/pull/16284/commits/a9df33af3657099fb33c7c97a31d20e12a9600b5
 . Also add tests.



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