@Override public void createTopic(String topicName, int partitionCount, int replicationFactor, Map<String, String> topicConfig, Handler<AsyncResult<Void>> completionHandler) { Properties topicConfigProperties = new Properties(); topicConfigProperties.putAll(topicConfig); vertx.executeBlocking(future -> { try { kafka.admin.AdminUtils.createTopic(initZkClientAndGetZkUtils(), topicName, partitionCount, replicationFactor, topicConfigProperties, kafka.admin.AdminUtils.createTopic$default$6()); // Note $default$6() retrieves the default parameter 6 from the Scala method createTopic -- RackAwareMode // As of Kafka 0.10.1.1, this is equivalent to RackAwareMode.Disabled$.MODULE$ completionHandler.handle(Future.succeededFuture()); } catch(Exception e) { completionHandler.handle(Future.failedFuture(e.getLocalizedMessage())); } finally { if(autoClose) { zkUtils.close(); } } }, r -> { }); }
.createTopic(zookeeperUtils, topic, Client.partitions, Client.replicationFactor, AdminUtils.createTopic$default$5(), AdminUtils.createTopic$default$6()); log.info("Created topic " + topic + "."); } catch (Exception e) {
public String createUniqueTopic(String prefix, int partitions, Properties topicConfig) throws InterruptedException { checkReady(); String topic = (prefix + UUID.randomUUID().toString().substring(0, 5)).replaceAll("[^a-zA-Z0-9._-]", "_"); AdminUtils.createTopic(kafkaServer.zkUtils(), topic, partitions, 1, topicConfig, AdminUtils.createTopic$default$6()); waitForPassing(Duration.ofSeconds(5), () -> { assertTrue(AdminUtils.fetchTopicMetadataFromZk(topic, kafkaServer.zkUtils()) .partitionMetadata().stream() .allMatch(pm -> !pm.leader().isEmpty())); }); return topic; }