Skip to content

Commit

Permalink
Remove redundant logic to calculate the minimum number of partition b…
Browse files Browse the repository at this point in the history
…efore creating new KMF topics (#341)
  • Loading branch information
Lincong Li authored Feb 11, 2021
1 parent 06178e6 commit 7f99c09
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public static int createTopicIfNotExists(String topic, short replicationFactor,
throws ExecutionException, InterruptedException {
try {
if (adminClient.listTopics().names().get().contains(topic)) {
LOG.info("AdminClient indicates that {} already exists in the cluster. Topic config: {}", topic, topicConfig);
LOG.info("AdminClient indicates that topic {} already exists in the cluster. Topic config: {}", topic, topicConfig);
return getPartitionNumForTopic(adminClient, topic);
}
int brokerCount = Utils.getBrokerCount(adminClient);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,7 @@ void maybeCreateTopic() throws Exception {
"Refer to config: {}", _topic, _zkConnect, TopicManagementServiceConfig.TOPIC_CREATION_ENABLED_CONFIG);
return;
}
int brokerCount = _adminClient.describeCluster().nodes().get().size();
int numPartitions = Math.max((int) Math.ceil(brokerCount * _minPartitionsToBrokersRatio), minPartitionNum());
NewTopic newTopic = new NewTopic(_topic, numPartitions, (short) _replicationFactor);
NewTopic newTopic = new NewTopic(_topic, minPartitionNum(), (short) _replicationFactor);
newTopic.configs((Map) _topicProperties);
_topicFactory.createTopicIfNotExist(_topic, (short) _replicationFactor, _minPartitionsToBrokersRatio,
_topicProperties, _adminClient);
Expand Down

0 comments on commit 7f99c09

Please sign in to comment.