use of org.apache.kafka.clients.admin.DeleteTopicsResult in project flink by splunk.
the class KafkaSinkITCase method deleteTestTopic.
private void deleteTestTopic(String topic) throws ExecutionException, InterruptedException, TimeoutException {
final DeleteTopicsResult result = admin.deleteTopics(Collections.singletonList(topic));
result.all().get(1, TimeUnit.MINUTES);
}
use of org.apache.kafka.clients.admin.DeleteTopicsResult in project druid by druid-io.
the class KafkaAdminClient method deleteStream.
@Override
public void deleteStream(String streamName) throws Exception {
DeleteTopicsResult deleteTopicsResult = adminClient.deleteTopics(ImmutableList.of(streamName));
deleteTopicsResult.values().get(streamName).get();
}
use of org.apache.kafka.clients.admin.DeleteTopicsResult in project extension-kafka by AxonFramework.
the class KafkaAdminUtils method deleteTopics.
/**
* Method responsible for deleting the {@code topics} on the provided {@code bootstrapServer}.
*
* @param bootstrapServer the kafka address
* @param topics a list of topics to be deleted
*/
public static void deleteTopics(String bootstrapServer, String... topics) {
try (AdminClient adminClient = AdminClient.create(minimalAdminConfig(bootstrapServer))) {
DeleteTopicsResult topicsDeletionResult = adminClient.deleteTopics(Arrays.asList(topics));
topicsDeletionResult.values().values().forEach(KafkaAdminUtils::waitForCompletion);
Arrays.stream(topics).forEach(topic -> logger.info("Completed topic deletion: {}", topic));
}
}
use of org.apache.kafka.clients.admin.DeleteTopicsResult in project vertx-kafka-client by vert-x3.
the class KafkaAdminClientImpl method deleteTopics.
@Override
public Future<Void> deleteTopics(List<String> topicNames) {
ContextInternal ctx = (ContextInternal) vertx.getOrCreateContext();
Promise<Void> promise = ctx.promise();
DeleteTopicsResult deleteTopicsResult = this.adminClient.deleteTopics(topicNames);
deleteTopicsResult.all().whenComplete((v, ex) -> {
if (ex == null) {
promise.complete();
} else {
promise.fail(ex);
}
});
return promise.future();
}
use of org.apache.kafka.clients.admin.DeleteTopicsResult in project openmessaging-benchmark by redpanda-data.
the class RedpandaBenchmarkDriver method initialize.
@Override
public void initialize(File configurationFile, StatsLogger statsLogger) throws IOException {
config = mapper.readValue(configurationFile, Config.class);
Properties commonProperties = new Properties();
commonProperties.load(new StringReader(config.commonConfig));
producerProperties = new Properties();
commonProperties.forEach((key, value) -> producerProperties.put(key, value));
producerProperties.load(new StringReader(config.producerConfig));
producerProperties.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
producerProperties.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, ByteArraySerializer.class.getName());
consumerProperties = new Properties();
commonProperties.forEach((key, value) -> consumerProperties.put(key, value));
consumerProperties.load(new StringReader(config.consumerConfig));
consumerProperties.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
consumerProperties.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, ByteArrayDeserializer.class.getName());
topicProperties = new Properties();
topicProperties.load(new StringReader(config.topicConfig));
admin = AdminClient.create(commonProperties);
if (config.reset) {
// List existing topics
ListTopicsResult result = admin.listTopics();
try {
Set<String> topics = result.names().get();
// Delete all existing topics
DeleteTopicsResult deletes = admin.deleteTopics(topics);
deletes.all().get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
throw new IOException(e);
}
}
}
Aggregations