use of org.apache.kafka.clients.admin.DeleteTopicsResult in project kafka by apache.
the class StreamsResetter method doDelete.
// visible for testing
public void doDelete(final List<String> topicsToDelete, final Admin adminClient) {
boolean hasDeleteErrors = false;
final DeleteTopicsResult deleteTopicsResult = adminClient.deleteTopics(topicsToDelete);
final Map<String, KafkaFuture<Void>> results = deleteTopicsResult.topicNameValues();
for (final Map.Entry<String, KafkaFuture<Void>> entry : results.entrySet()) {
try {
entry.getValue().get(30, TimeUnit.SECONDS);
} catch (final Exception e) {
System.err.println("ERROR: deleting topic " + entry.getKey());
e.printStackTrace(System.err);
hasDeleteErrors = true;
}
}
if (hasDeleteErrors) {
throw new RuntimeException("Encountered an error deleting one or more topics");
}
}
use of org.apache.kafka.clients.admin.DeleteTopicsResult in project samza by apache.
the class IntegrationTestHarness method deleteTopics.
protected boolean deleteTopics(Collection<String> topics) {
boolean deleteStatus = true;
try {
DeleteTopicsResult resultFutures = adminClient.deleteTopics(topics);
resultFutures.all().get(ADMIN_OPERATION_WAIT_DURATION_MS, TimeUnit.MILLISECONDS);
} catch (Exception e) {
LOG.error("Error deleting topics: {}", StringUtils.join(topics, ","), e);
deleteStatus = false;
}
return deleteStatus;
}
use of org.apache.kafka.clients.admin.DeleteTopicsResult in project stockstat by rroart.
the class Kafka method destroyTmp.
@Override
public void destroyTmp() {
// TODO Auto-generated method stub
Properties config = new Properties();
config.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, "192.168.122.219:9092");
AdminClient admin = AdminClient.create(config);
List<String> list = new ArrayList<>();
list.add(getReceiveService());
DeleteTopicsResult deleteTopicsResult = admin.deleteTopics(list);
}
Aggregations