Search in sources :

Example 16 with AcknowledgedResponse

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.support.master.AcknowledgedResponse in project crate by crate.

the class TransportCreatePartitionsActionTest method testCreateBulkIndicesSimple.

@Test
public void testCreateBulkIndicesSimple() throws Exception {
    List<String> indices = Arrays.asList("index1", "index2", "index3", "index4");
    AcknowledgedResponse response = action.execute(new CreatePartitionsRequest(indices, UUID.randomUUID())).get();
    assertThat(response.isAcknowledged(), is(true));
    Metadata indexMetadata = internalCluster().clusterService().state().metadata();
    for (String index : indices) {
        assertThat(indexMetadata.hasIndex(index), is(true));
    }
}
Also used : AcknowledgedResponse(org.elasticsearch.action.support.master.AcknowledgedResponse) Metadata(org.elasticsearch.cluster.metadata.Metadata) Test(org.junit.Test)

Example 17 with AcknowledgedResponse

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.support.master.AcknowledgedResponse in project crate by crate.

the class TransportCreatePartitionsActionTest method testEmpty.

@Test
public void testEmpty() throws Exception {
    AcknowledgedResponse response = action.execute(new CreatePartitionsRequest(List.of(), UUID.randomUUID())).get();
    assertThat(response.isAcknowledged(), is(true));
}
Also used : AcknowledgedResponse(org.elasticsearch.action.support.master.AcknowledgedResponse) Test(org.junit.Test)

Example 18 with AcknowledgedResponse

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.support.master.AcknowledgedResponse in project graylog2-server by Graylog2.

the class IndicesAdapterES7 method deleteIndexTemplate.

@Override
public boolean deleteIndexTemplate(String templateName) {
    final DeleteIndexTemplateRequest request = new DeleteIndexTemplateRequest(templateName);
    final AcknowledgedResponse result = client.execute((c, requestOptions) -> c.indices().deleteTemplate(request, requestOptions), "Unable to delete index template " + templateName);
    return result.isAcknowledged();
}
Also used : AcknowledgedResponse(org.graylog.shaded.elasticsearch7.org.elasticsearch.action.support.master.AcknowledgedResponse) DeleteIndexTemplateRequest(org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest)

Example 19 with AcknowledgedResponse

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.support.master.AcknowledgedResponse in project graylog2-server by Graylog2.

the class IndicesAdapterES7 method ensureIndexTemplate.

@Override
public boolean ensureIndexTemplate(String templateName, Map<String, Object> template) {
    final PutIndexTemplateRequest request = new PutIndexTemplateRequest(templateName).source(template);
    final AcknowledgedResponse result = client.execute((c, requestOptions) -> c.indices().putTemplate(request, requestOptions), "Unable to create index template " + templateName);
    return result.isAcknowledged();
}
Also used : AcknowledgedResponse(org.graylog.shaded.elasticsearch7.org.elasticsearch.action.support.master.AcknowledgedResponse) PutIndexTemplateRequest(org.graylog.shaded.elasticsearch7.org.elasticsearch.client.indices.PutIndexTemplateRequest)

Example 20 with AcknowledgedResponse

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.support.master.AcknowledgedResponse in project sonarqube by SonarSource.

the class EsTester method deleteIndexIfExists.

private static void deleteIndexIfExists(String name) {
    try {
        AcknowledgedResponse response = ES_REST_CLIENT.nativeClient().indices().delete(new DeleteIndexRequest(name), RequestOptions.DEFAULT);
        checkState(response.isAcknowledged(), "Fail to drop the index " + name);
    } catch (ElasticsearchStatusException e) {
        if (e.status().getStatus() == 404) {
        // ignore, index not found
        } else {
            throw e;
        }
    } catch (IOException e) {
        throw new IllegalStateException("Could not delete index", e);
    }
}
Also used : AcknowledgedResponse(org.elasticsearch.action.support.master.AcknowledgedResponse) DeleteIndexRequest(org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest) IOException(java.io.IOException) ElasticsearchStatusException(org.elasticsearch.ElasticsearchStatusException)

Aggregations

AcknowledgedResponse (org.elasticsearch.action.support.master.AcknowledgedResponse)37 IOException (java.io.IOException)11 FutureActionListener (io.crate.action.FutureActionListener)9 ClusterState (org.elasticsearch.cluster.ClusterState)7 Row1 (io.crate.data.Row1)6 Map (java.util.Map)6 DeleteIndexRequest (org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest)6 ClusterBlockException (org.elasticsearch.cluster.block.ClusterBlockException)6 Metadata (org.elasticsearch.cluster.metadata.Metadata)6 Row (io.crate.data.Row)5 RelationName (io.crate.metadata.RelationName)5 Arrays (java.util.Arrays)5 HashMap (java.util.HashMap)5 List (java.util.List)5 Reference (io.crate.metadata.Reference)4 DataType (io.crate.types.DataType)4 ArrayList (java.util.ArrayList)4 CompletableFuture (java.util.concurrent.CompletableFuture)4 StreamSupport (java.util.stream.StreamSupport)4 ClusterService (org.elasticsearch.cluster.service.ClusterService)4