Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
[branch-2.7.2] Fix unused getList call to create missed partitions (#626
Browse files Browse the repository at this point in the history
)

Fixes #619

See #619 (comment) for details.
  • Loading branch information
BewareMyPower committed Jul 26, 2021
1 parent 96f454a commit 5da3a66
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

import lombok.extern.slf4j.Slf4j;

Expand Down Expand Up @@ -150,18 +149,10 @@ public static void createKafkaMetadataIfMissing(PulsarAdmin pulsarAdmin, KafkaSe
log.info("Successfully created group metadata topic {} with {} partitions.",
offsetsTopic, conf.getOffsetsTopicNumPartitions());
} else {
// Check to see if the partitions all exist
offsetPartitionSet.removeAll(
topics.getList(kafkaMetadataNamespace).stream()
.filter((topic) -> {
return topic.startsWith(offsetsTopic + PARTITIONED_TOPIC_SUFFIX);
}).collect(Collectors.toList()));

if (!offsetPartitionSet.isEmpty()) {
log.info("Identified missing offset topic partitions: {}", offsetPartitionSet);
for (String offsetPartition : offsetPartitionSet) {
topics.createNonPartitionedTopic(offsetPartition);
}
try {
// Ensure all partitions are created
pulsarAdmin.topics().createMissedPartitions(offsetsTopic);
} catch (PulsarAdminException ignored) {
}
}
offsetsTopicExists = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,6 @@ public void testCreateKafkaMetadataIfMissing() throws Exception {
verify(mockTenants, times(1)).updateTenant(eq(conf.getKafkaMetadataTenant()), any(TenantInfo.class));
verify(mockNamespaces, times(1)).setNamespaceReplicationClusters(eq(conf.getKafkaMetadataTenant()
+ "/" + conf.getKafkaMetadataNamespace()), any(Set.class));
verify(mockTopics, times(2)).createNonPartitionedTopic(any(String.class));
verify(mockTopics, times(1)).createMissedPartitions(any(String.class));
}
}

0 comments on commit 5da3a66

Please sign in to comment.