use of org.apache.kafka.clients.admin.DeleteTopicsResult in project ksql by confluentinc.
the class KafkaTopicClientImplTest method getDeleteInternalTopicsResult.
private DeleteTopicsResult getDeleteInternalTopicsResult() {
DeleteTopicsResult deleteTopicsResult = mock(DeleteTopicsResult.class);
Map<String, KafkaFuture<Void>> deletedTopics = new HashMap<>();
deletedTopics.put(internalTopic1, KafkaFuture.allOf());
deletedTopics.put(internalTopic2, KafkaFuture.allOf());
expect(deleteTopicsResult.values()).andReturn(deletedTopics);
replay(deleteTopicsResult);
return deleteTopicsResult;
}
use of org.apache.kafka.clients.admin.DeleteTopicsResult in project Microservice-Benchmark by OpenHFT.
the class KafkaBenchmarkDriver method init.
@Override
public void init() {
Driver.super.init();
Properties commonProperties = new Properties();
commonProperties.putAll(commonConfig);
producerConfig.putAll(commonConfig);
producerConfig.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
producerConfig.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, ByteArraySerializer.class.getName());
consumerConfig.putAll(commonConfig);
consumerConfig.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
consumerConfig.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, ByteArrayDeserializer.class.getName());
admin = AdminClient.create(commonProperties);
if (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) {
LoggerFactory.getLogger(getClass()).warn("Error on reset", e);
throw new IORuntimeException(e);
}
}
}
use of org.apache.kafka.clients.admin.DeleteTopicsResult in project strimzi by strimzi.
the class KafkaImplTest method mockDeleteTopics.
private void mockDeleteTopics(Admin admin, Map<String, Either<Void, Exception>> result) {
DeleteTopicsResult deleteTopicsResult = mock(DeleteTopicsResult.class);
when(deleteTopicsResult.topicNameValues()).thenReturn(result.entrySet().stream().collect(toMap(Map.Entry::getKey, entry -> {
KafkaFutureImpl<Void> kafkaFuture = new KafkaFutureImpl<>();
if (entry.getValue().isLeft()) {
kafkaFuture.complete(null);
} else {
kafkaFuture.completeExceptionally(entry.getValue().right());
}
return kafkaFuture;
})));
when(admin.deleteTopics(result.keySet())).thenReturn(deleteTopicsResult);
}
use of org.apache.kafka.clients.admin.DeleteTopicsResult in project strimzi-kafka-operator by strimzi.
the class TopicOperatorBaseIT method deleteTopicInKafka.
protected void deleteTopicInKafka(String topicName, String resourceName) throws InterruptedException, ExecutionException {
LOGGER.info("Deleting topic {} (KafkaTopic {})", topicName, resourceName);
// Now we can delete the topic
DeleteTopicsResult dlt = adminClient.deleteTopics(singletonList(topicName));
dlt.all().get();
LOGGER.info("Deleted topic {}", topicName);
}
use of org.apache.kafka.clients.admin.DeleteTopicsResult in project strimzi-kafka-operator by strimzi.
the class KafkaImplTest method mockDeleteTopics.
private void mockDeleteTopics(Admin admin, Map<String, Either<Void, Exception>> result) {
DeleteTopicsResult deleteTopicsResult = mock(DeleteTopicsResult.class);
when(deleteTopicsResult.topicNameValues()).thenReturn(result.entrySet().stream().collect(toMap(Map.Entry::getKey, entry -> {
KafkaFutureImpl<Void> kafkaFuture = new KafkaFutureImpl<>();
if (entry.getValue().isLeft()) {
kafkaFuture.complete(null);
} else {
kafkaFuture.completeExceptionally(entry.getValue().right());
}
return kafkaFuture;
})));
when(admin.deleteTopics(result.keySet())).thenReturn(deleteTopicsResult);
}
Aggregations