Search in sources :

Example 1 with IndicesExistsResponse

use of org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse in project crate by crate.

the class TransportBulkCreateIndicesActionTest method testCreateBulkIndicesSimple.

@Test
public void testCreateBulkIndicesSimple() throws Exception {
    BulkCreateIndicesResponse response = action.execute(new BulkCreateIndicesRequest(Arrays.asList("index1", "index2", "index3", "index4"), UUID.randomUUID())).actionGet();
    assertThat(response.isAcknowledged(), is(true));
    ensureYellow();
    IndicesExistsResponse indicesExistsResponse = cluster().client().admin().indices().prepareExists("index1", "index2", "index3", "index4").execute().actionGet();
    assertThat(indicesExistsResponse.isExists(), is(true));
}
Also used : IndicesExistsResponse(org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse) Test(org.junit.Test) SQLTransportIntegrationTest(io.crate.integrationtests.SQLTransportIntegrationTest)

Example 2 with IndicesExistsResponse

use of org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse in project elasticsearch by elastic.

the class SimpleBlocksIT method canIndexExists.

private void canIndexExists(String index) {
    try {
        IndicesExistsResponse r = client().admin().indices().prepareExists(index).execute().actionGet();
        assertThat(r, notNullValue());
    } catch (ClusterBlockException e) {
        fail();
    }
}
Also used : IndicesExistsResponse(org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse) ClusterBlockException(org.elasticsearch.cluster.block.ClusterBlockException)

Example 3 with IndicesExistsResponse

use of org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse in project titan by thinkaurelius.

the class ElasticSearchIndex method checkForOrCreateIndex.

/**
     * If ES already contains this instance's target index, then do nothing.
     * Otherwise, create the index, then wait {@link #CREATE_SLEEP}.
     * <p>
     * The {@code client} field must point to a live, connected client.
     * The {@code indexName} field must be non-null and point to the name
     * of the index to check for existence or create.
     *
     * @param config the config for this ElasticSearchIndex
     * @throws java.lang.IllegalArgumentException if the index could not be created
     */
private void checkForOrCreateIndex(Configuration config) {
    Preconditions.checkState(null != client);
    //Create index if it does not already exist
    IndicesExistsResponse response = client.admin().indices().exists(new IndicesExistsRequest(indexName)).actionGet();
    if (!response.isExists()) {
        ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder();
        ElasticSearchSetup.applySettingsFromTitanConf(settings, config, ES_CREATE_EXTRAS_NS);
        CreateIndexResponse create = client.admin().indices().prepareCreate(indexName).setSettings(settings.build()).execute().actionGet();
        try {
            final long sleep = config.get(CREATE_SLEEP);
            log.debug("Sleeping {} ms after {} index creation returned from actionGet()", sleep, indexName);
            Thread.sleep(sleep);
        } catch (InterruptedException e) {
            throw new TitanException("Interrupted while waiting for index to settle in", e);
        }
        if (!create.isAcknowledged())
            throw new IllegalArgumentException("Could not create index: " + indexName);
    }
}
Also used : IndicesExistsResponse(org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse) TitanException(com.thinkaurelius.titan.core.TitanException) CreateIndexResponse(org.elasticsearch.action.admin.indices.create.CreateIndexResponse) ImmutableSettings(org.elasticsearch.common.settings.ImmutableSettings) IndicesExistsRequest(org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest)

Example 4 with IndicesExistsResponse

use of org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse in project graylog2-server by Graylog2.

the class IndicesTest method testDelete.

@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void testDelete() throws Exception {
    final IndicesExistsRequest beforeRequest = client.admin().indices().prepareExists(INDEX_NAME).request();
    final IndicesExistsResponse beforeResponse = client.admin().indices().exists(beforeRequest).actionGet(ES_TIMEOUT);
    assertThat(beforeResponse.isExists()).isTrue();
    indices.delete(INDEX_NAME);
    final IndicesExistsRequest request = client.admin().indices().prepareExists(INDEX_NAME).request();
    final IndicesExistsResponse response = client.admin().indices().exists(request).actionGet(ES_TIMEOUT);
    assertThat(response.isExists()).isFalse();
}
Also used : IndicesExistsResponse(org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse) IndicesExistsRequest(org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest) UsingDataSet(com.lordofthejars.nosqlunit.annotation.UsingDataSet) Test(org.junit.Test)

Example 5 with IndicesExistsResponse

use of org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse in project crate by crate.

the class TransportBulkCreateIndicesActionTest method testCreateBulkIndicesIgnoreExistingSame.

@Test
public void testCreateBulkIndicesIgnoreExistingSame() throws Exception {
    BulkCreateIndicesResponse response = action.execute(new BulkCreateIndicesRequest(Arrays.asList("index1", "index2", "index3", "index1"), UUID.randomUUID())).actionGet();
    assertThat(response.isAcknowledged(), is(true));
    IndicesExistsResponse indicesExistsResponse = cluster().client().admin().indices().prepareExists("index1", "index2", "index3").execute().actionGet();
    assertThat(indicesExistsResponse.isExists(), is(true));
    BulkCreateIndicesResponse response2 = action.execute(new BulkCreateIndicesRequest(Arrays.asList("index1", "index2", "index3", "index1"), UUID.randomUUID())).actionGet();
    assertThat(response2.isAcknowledged(), is(true));
}
Also used : IndicesExistsResponse(org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse) Test(org.junit.Test) SQLTransportIntegrationTest(io.crate.integrationtests.SQLTransportIntegrationTest)

Aggregations

IndicesExistsResponse (org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse)10 IndicesExistsRequest (org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest)4 Test (org.junit.Test)4 IndicesAdminClient (org.elasticsearch.client.IndicesAdminClient)3 UsingDataSet (com.lordofthejars.nosqlunit.annotation.UsingDataSet)2 SQLTransportIntegrationTest (io.crate.integrationtests.SQLTransportIntegrationTest)2 MetricRegistry (com.codahale.metrics.MetricRegistry)1 TitanException (com.thinkaurelius.titan.core.TitanException)1 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 Set (java.util.Set)1 ResourceNotFoundRuntimeException (org.codelibs.core.exception.ResourceNotFoundRuntimeException)1 FessSystemException (org.codelibs.fess.exception.FessSystemException)1 InvalidQueryException (org.codelibs.fess.exception.InvalidQueryException)1 ResultOffsetExceededException (org.codelibs.fess.exception.ResultOffsetExceededException)1 SearchQueryException (org.codelibs.fess.exception.SearchQueryException)1 FessConfig (org.codelibs.fess.mylasta.direction.FessConfig)1 IllegalBehaviorStateException (org.dbflute.exception.IllegalBehaviorStateException)1 ElasticsearchException (org.elasticsearch.ElasticsearchException)1 CreateIndexResponse (org.elasticsearch.action.admin.indices.create.CreateIndexResponse)1