use of io.confluent.ksql.exception.KafkaTopicException in project ksql by confluentinc.
the class KafkaTopicClientImpl method validateTopicProperties.
private void validateTopicProperties(final String topic, final int numPartitions, final short replicationFactor) {
Map<String, TopicDescription> topicDescriptions = describeTopics(Collections.singletonList(topic));
TopicDescription topicDescription = topicDescriptions.get(topic);
if (topicDescription.partitions().size() != numPartitions || topicDescription.partitions().get(0).replicas().size() < replicationFactor) {
throw new KafkaTopicException(String.format("Topic '%s' does not conform to the requirements Partitions:%d v %d. Replication: %d " + "v %d", topic, topicDescription.partitions().size(), numPartitions, topicDescription.partitions().get(0).replicas().size(), replicationFactor));
}
// Topic with the partitions and replicas exists, reuse it!
log.debug("Did not create topic {} with {} partitions and replication-factor {} since it already " + "exists", topic, numPartitions, replicationFactor);
}
use of io.confluent.ksql.exception.KafkaTopicException in project ksql by confluentinc.
the class KsqlRestApplicationTest method shouldNotFailIfTopicExistsOnCreation.
@Test
public void shouldNotFailIfTopicExistsOnCreation() {
topicClient.createTopic(COMMAND_TOPIC, 1, (short) 1, commandTopicConfig);
EasyMock.expectLastCall().andThrow(new KafkaTopicException("blah"));
EasyMock.replay(topicClient);
KsqlRestApplication.ensureCommandTopic(restConfig, topicClient, COMMAND_TOPIC);
EasyMock.verify(topicClient);
}
Aggregations