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

The following examples show how to use org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest. 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: 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 #2
Source File: ElasticSearch7Client.java    From skywalking with Apache License 2.0 5 votes vote down vote up
public boolean deleteTemplate(String indexName) throws IOException {
    indexName = formatIndexName(indexName);

    DeleteIndexTemplateRequest deleteIndexTemplateRequest = new DeleteIndexTemplateRequest(indexName);
    AcknowledgedResponse acknowledgedResponse = client.indices()
                                                      .deleteTemplate(
                                                          deleteIndexTemplateRequest, RequestOptions.DEFAULT);

    return acknowledgedResponse.isAcknowledged();
}
 
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
public DeleteIndexTemplateRequestBuilder(Client client, JsonToString<JsonInput> jsonToString, StringToJson<JsonOutput> stringToJson, String name) {
    super(client, new DeleteIndexTemplateRequest(name), jsonToString, stringToJson);
}
 
Example #8
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 #9
Source File: AbstractClient.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public void deleteTemplate(final DeleteIndexTemplateRequest request, final ActionListener<AcknowledgedResponse> listener) {
    execute(DeleteIndexTemplateAction.INSTANCE, request, listener);
}
 
Example #10
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 #11
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);
 
Example #12
Source File: IndicesAdminClient.java    From crate with Apache License 2.0 2 votes vote down vote up
/**
 * Deletes an index template.
 */
void deleteTemplate(DeleteIndexTemplateRequest request, ActionListener<AcknowledgedResponse> listener);