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));
}
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();
}
}
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);
}
}
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();
}
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));
}
Aggregations