You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "akhileshchg (via GitHub)" <gi...@apache.org> on 2023/05/22 21:56:08 UTC
[GitHub] [kafka] akhileshchg commented on a diff in pull request #13735: KAFKA-15003: When partitions are partition assignments change we do n…
akhileshchg commented on code in PR #13735:
URL: https://github.com/apache/kafka/pull/13735#discussion_r1201206830
##########
metadata/src/main/java/org/apache/kafka/metadata/migration/KRaftMigrationZkWriter.java:
##########
@@ -184,11 +232,36 @@ void handleTopicsDelta(Function<Uuid, String> deletedTopicNameResolver, TopicsDe
topicDelta.partitionChanges(),
migrationState));
} else {
- operationConsumer.accept(
- "Updating Partitions for Topic " + topicDelta.name() + ", ID " + topicId,
- migrationState -> migrationClient.topicClient().updateTopicPartitions(
- Collections.singletonMap(topicDelta.name(), topicDelta.partitionChanges()),
- migrationState));
+ if (topicDelta.hasPartitionsWithAssignmentChanges())
+ operationConsumer.accept(
+ "Updating Topic " + topicDelta.name() + ", ID " + topicId,
+ migrationState -> migrationClient.topicClient().updateTopic(
+ topicDelta.name(),
+ topicId,
+ topicsImage.getTopic(topicId).partitions(),
+ migrationState));
+ Map<Integer, PartitionRegistration> newPartitions = topicDelta.newPartitions();
+ Map<Integer, PartitionRegistration> changedPartitions = topicDelta.partitionChanges();
+ if (!newPartitions.isEmpty()) {
+ operationConsumer.accept(
+ "Create new partitions for Topic " + topicDelta.name() + ", ID " + topicId,
+ migrationState -> migrationClient.topicClient().createTopicPartitions(
+ Collections.singletonMap(topicDelta.name(), topicDelta.partitionChanges()),
+ migrationState));
+ changedPartitions = changedPartitions
+ .entrySet()
+ .stream()
+ .filter(entry -> !newPartitions.containsKey(entry.getKey()))
+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
+ }
+ if (!changedPartitions.isEmpty()) {
+ Map<Integer, PartitionRegistration> finalChangedPartitions = changedPartitions;
Review Comment:
Yeah. We should have effectively final variable when we pass it to lambda.
--
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-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org