use of org.apache.kafka.clients.admin.DeleteTopicsResult in project ksql by confluentinc.
the class KafkaTopicClientImpl method deleteTopics.
@Override
public void deleteTopics(final List<String> topicsToDelete) {
if (!isDeleteTopicEnabled) {
log.info("Cannot delete topics since 'delete.topic.enable' is false. ");
return;
}
final DeleteTopicsResult deleteTopicsResult = adminClient.deleteTopics(topicsToDelete);
final Map<String, KafkaFuture<Void>> results = deleteTopicsResult.values();
List<String> failList = Lists.newArrayList();
for (final Map.Entry<String, KafkaFuture<Void>> entry : results.entrySet()) {
try {
entry.getValue().get(30, TimeUnit.SECONDS);
} catch (Exception e) {
failList.add(entry.getKey());
}
}
if (!failList.isEmpty()) {
throw new KsqlException("Failed to clean up topics: " + failList.stream().collect(Collectors.joining(",")));
}
}
use of org.apache.kafka.clients.admin.DeleteTopicsResult in project ksql by confluentinc.
the class KafkaTopicClientImplTest method getDeleteTopicsResult.
private DeleteTopicsResult getDeleteTopicsResult() {
DeleteTopicsResult deleteTopicsResult = mock(DeleteTopicsResult.class);
expect(deleteTopicsResult.values()).andReturn(Collections.singletonMap(topicName1, KafkaFuture.allOf()));
replay(deleteTopicsResult);
return deleteTopicsResult;
}
use of org.apache.kafka.clients.admin.DeleteTopicsResult in project strimzi by strimzi.
the class ControllerIT method deleteTopic.
private void deleteTopic(TestContext context, String topicName, String configMapName) throws InterruptedException, ExecutionException {
LOGGER.info("Deleting topic {} (ConfigMap {})", topicName, configMapName);
// Now we can delete the topic
DeleteTopicsResult dlt = adminClient.deleteTopics(singletonList(topicName));
dlt.all().get();
LOGGER.info("Deleted topic {}", topicName);
// Wait for the configmap to be deleted
waitFor(context, () -> {
ConfigMap cm = kubeClient.configMaps().inNamespace(NAMESPACE).withName(configMapName).get();
LOGGER.info("Polled configmap {}, got {}, waiting for deletion", configMapName, cm);
return cm == null;
}, timeout, "Expected the configmap to have been deleted by now");
}
use of org.apache.kafka.clients.admin.DeleteTopicsResult in project samza by apache.
the class KafkaSystemAdmin method clearStream.
@Override
public boolean clearStream(StreamSpec streamSpec) {
LOG.info("Creating Kafka topic: {} on system: {}", streamSpec.getPhysicalName(), streamSpec.getSystemName());
String topicName = streamSpec.getPhysicalName();
try {
DeleteTopicsResult deleteTopicsResult = adminClient.deleteTopics(ImmutableSet.of(topicName));
deleteTopicsResult.all().get(KAFKA_ADMIN_OPS_TIMEOUT_MS, TimeUnit.MILLISECONDS);
} catch (Exception e) {
LOG.error("Failed to delete topic {} with exception {}.", topicName, e);
return false;
}
return true;
}
use of org.apache.kafka.clients.admin.DeleteTopicsResult in project flink by apache.
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);
}
Aggregations