org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateResponse Java Examples

The following examples show how to use org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateResponse. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultElasticSearchAdminService.java    From vertx-elasticsearch-service with Apache License 2.0 6 votes vote down vote up
@Override
public void deleteTemplate(String name, TemplateOptions options, Handler<AsyncResult<Void>> resultHandler) {

    final DeleteIndexTemplateRequestBuilder builder = DeleteIndexTemplateAction.INSTANCE.newRequestBuilder(service.getClient()).setName(name);

    builder.execute(new ActionListener<DeleteIndexTemplateResponse>() {
        @Override
        public void onResponse(DeleteIndexTemplateResponse deleteIndexTemplateResponse) {
            JsonObject json = new JsonObject()
                    .put("acknowledged", deleteIndexTemplateResponse.isAcknowledged());
            resultHandler.handle(Future.succeededFuture());
        }

        @Override
        public void onFailure(Exception e) {
            resultHandler.handle(Future.failedFuture(e));
        }
    });
}
 
Example #2
Source File: DropTableTask.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
protected void doStart(List<TaskResult> upstreamResults) {
    if (tableInfo.isPartitioned()) {
        String templateName = PartitionName.templateName(tableInfo.ident().schema(), tableInfo.ident().name());
        DeleteIndexTemplateRequest deleteIndexTemplateRequest = new DeleteIndexTemplateRequest(templateName);
        deleteIndexTemplateRequest.putHeader(LoginUserContext.USER_INFO_KEY, this.getParamContext().getLoginUserContext());
        deleteTemplateAction.execute(deleteIndexTemplateRequest, new ActionListener<DeleteIndexTemplateResponse>() {
            @Override
            public void onResponse(DeleteIndexTemplateResponse response) {
                if (!response.isAcknowledged()) {
                    warnNotAcknowledged(String.format(Locale.ENGLISH, "dropping table '%s'", tableInfo.ident().fqn()));
                }
                if (!tableInfo.partitions().isEmpty()) {
                    deleteESIndex(tableInfo.ident().indexName());
                } else {
                    result.set(SUCCESS_RESULT);
                }
            }

            @Override
            public void onFailure(Throwable e) {
                e = ExceptionsHelper.unwrapCause(e);
                if (e instanceof IndexTemplateMissingException && !tableInfo.partitions().isEmpty()) {
                    logger.warn(e.getMessage());
                    deleteESIndex(tableInfo.ident().indexName());
                } else {
                    result.setException(e);
                }
            }
        });
    } else {
        deleteESIndex(tableInfo.ident().indexName());
    }

}
 
Example #3
Source File: DeleteIndexTemplateRequestBuilder.java    From elasticshell with Apache License 2.0 5 votes vote down vote up
@Override
protected XContentBuilder toXContent(DeleteIndexTemplateRequest request, DeleteIndexTemplateResponse response, XContentBuilder builder) throws IOException {
    builder.startObject()
            .field(Fields.OK, true)
            .field(Fields.ACKNOWLEDGED, response.isAcknowledged())
            .endObject();
    return builder;
}
 
Example #4
Source File: AbstractClient.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public ActionFuture<DeleteIndexTemplateResponse> deleteTemplate(final DeleteIndexTemplateRequest request) {
    return execute(DeleteIndexTemplateAction.INSTANCE, request);
}
 
Example #5
Source File: AbstractClient.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public void deleteTemplate(final DeleteIndexTemplateRequest request, final ActionListener<DeleteIndexTemplateResponse> listener) {
    execute(DeleteIndexTemplateAction.INSTANCE, request, listener);
}
 
Example #6
Source File: RestDeleteIndexTemplateAction.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
    DeleteIndexTemplateRequest deleteIndexTemplateRequest = new DeleteIndexTemplateRequest(request.param("name"));
    deleteIndexTemplateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", deleteIndexTemplateRequest.masterNodeTimeout()));
    client.admin().indices().deleteTemplate(deleteIndexTemplateRequest, new AcknowledgedRestListener<DeleteIndexTemplateResponse>(channel));
}
 
Example #7
Source File: DeleteIndexTemplateRequestBuilder.java    From elasticshell with Apache License 2.0 4 votes vote down vote up
@Override
protected ActionFuture<DeleteIndexTemplateResponse> doExecute(DeleteIndexTemplateRequest request) {
    return client.admin().indices().deleteTemplate(request);
}
 
Example #8
Source File: IndicesAdminClient.java    From Elasticsearch with Apache License 2.0 2 votes vote down vote up
/**
 * Deletes index template.
 */
ActionFuture<DeleteIndexTemplateResponse> deleteTemplate(DeleteIndexTemplateRequest request);
 
Example #9
Source File: IndicesAdminClient.java    From Elasticsearch with Apache License 2.0 2 votes vote down vote up
/**
 * Deletes an index template.
 */
void deleteTemplate(DeleteIndexTemplateRequest request, ActionListener<DeleteIndexTemplateResponse> listener);