Search in sources :

Example 1 with DeleteIndexRequestBuilder

use of org.elasticsearch.action.admin.indices.delete.DeleteIndexRequestBuilder in project molgenis by molgenis.

the class ClientFacade method deleteIndexes.

private void deleteIndexes(List<Index> indexes) {
    if (LOG.isTraceEnabled()) {
        LOG.trace("Deleting index(es) '{}' ...", toString(indexes));
    }
    String[] indexNames = toIndexNames(indexes);
    DeleteIndexRequestBuilder deleteIndexRequest = client.admin().indices().prepareDelete(indexNames);
    DeleteIndexResponse deleteIndexResponse;
    try {
        deleteIndexResponse = deleteIndexRequest.get();
    } catch (ResourceNotFoundException e) {
        LOG.debug("", e);
        throw new UnknownIndexException(toString(indexes));
    } catch (ElasticsearchException e) {
        LOG.error("", e);
        throw new IndexException(format("Error deleting index(es) '%s'.", toString(indexes)));
    }
    if (!deleteIndexResponse.isAcknowledged()) {
        throw new IndexException(format("Error deleting index(es) '%s'.", toString(indexes)));
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("Deleted index(es) '{}'.", toString(indexes));
    }
}
Also used : DeleteIndexResponse(org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse) IndexException(org.molgenis.data.index.exception.IndexException) UnknownIndexException(org.molgenis.data.index.exception.UnknownIndexException) UnknownIndexException(org.molgenis.data.index.exception.UnknownIndexException) DeleteIndexRequestBuilder(org.elasticsearch.action.admin.indices.delete.DeleteIndexRequestBuilder) ElasticsearchException(org.elasticsearch.ElasticsearchException) ResourceNotFoundException(org.elasticsearch.ResourceNotFoundException)

Example 2 with DeleteIndexRequestBuilder

use of org.elasticsearch.action.admin.indices.delete.DeleteIndexRequestBuilder in project bw-calendar-engine by Bedework.

the class BwIndexEsImpl method deleteIndexes.

private void deleteIndexes(final List<String> names) throws CalFacadeException {
    try {
        final IndicesAdminClient idx = getAdminIdx();
        final DeleteIndexRequestBuilder dirb = getAdminIdx().prepareDelete(names.toArray(new String[names.size()]));
        final ActionFuture<DeleteIndexResponse> dr = idx.delete(dirb.request());
        /*DeleteIndexResponse dir = */
        dr.actionGet();
    } catch (final Throwable t) {
        throw new CalFacadeException(t);
    }
}
Also used : DeleteIndexResponse(org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse) IndicesAdminClient(org.elasticsearch.client.IndicesAdminClient) DeleteIndexRequestBuilder(org.elasticsearch.action.admin.indices.delete.DeleteIndexRequestBuilder) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Aggregations

DeleteIndexRequestBuilder (org.elasticsearch.action.admin.indices.delete.DeleteIndexRequestBuilder)2 DeleteIndexResponse (org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse)2 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)1 ElasticsearchException (org.elasticsearch.ElasticsearchException)1 ResourceNotFoundException (org.elasticsearch.ResourceNotFoundException)1 IndicesAdminClient (org.elasticsearch.client.IndicesAdminClient)1 IndexException (org.molgenis.data.index.exception.IndexException)1 UnknownIndexException (org.molgenis.data.index.exception.UnknownIndexException)1