use of org.apache.kafka.clients.admin.DeleteTopicsResult in project kop by streamnative.
the class KafkaAuthorizationTestBase method testDeleteTopicSuccess.
@Test(timeOut = 20000)
public void testDeleteTopicSuccess() throws PulsarAdminException, InterruptedException {
String newTopic = "testDeleteTopicSuccess";
String fullNewTopicName = "persistent://" + TENANT + "/" + NAMESPACE + "/" + newTopic;
admin.topics().createPartitionedTopic(fullNewTopicName, 1);
AdminClient adminClient = createAdminClient(TENANT + "/" + NAMESPACE, adminToken);
DeleteTopicsResult deleteTopicsResult = adminClient.deleteTopics(Collections.singletonList(newTopic));
try {
deleteTopicsResult.all().get();
} catch (ExecutionException ex) {
fail("Should success but have : " + ex.getMessage());
}
List<String> topicList = admin.topics().getList(TENANT + "/" + NAMESPACE);
topicList.forEach(topic -> {
if (topic.startsWith(fullNewTopicName)) {
fail("Delete topic failed!");
}
});
adminClient.close();
}
use of org.apache.kafka.clients.admin.DeleteTopicsResult in project strimzi 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 flink-mirror by flink-ci.
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 apache.
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 kafka-benchmark by AzulSystems.
the class KafkaE2EBenchmark method deleteTopic.
public void deleteTopic(boolean wait) {
log("Deleting topic '" + config.topic + "'...");
try {
DeleteTopicsResult result = adminClient.deleteTopics(Arrays.asList(config.topic));
result.all().get();
if (wait && config.waitAfterDeleteTopic > 0) {
sleep(config.waitAfterDeleteTopic, "waiting after topic deletion");
}
log("Topic deleted '" + config.topic + "'");
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} catch (Exception e) {
if (e instanceof UnknownTopicOrPartitionException) {
log("Cannot delete topic '" + config.topic + "' " + e);
return;
}
if (e.getCause() instanceof UnknownTopicOrPartitionException) {
log("Cannot delete topic '" + config.topic + "' " + e.getCause());
return;
}
throw new KafkaRuntimeException("Failed to delete topic '" + config.topic + "'", e);
}
}
Aggregations