Search in sources :

Example 86 with ClusterHealthResponse

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse in project elasticsearch by elastic.

the class OpenCloseIndexIT method testCloseOpenAliasMultipleIndices.

public void testCloseOpenAliasMultipleIndices() {
    Client client = client();
    createIndex("test1", "test2");
    ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
    assertThat(healthResponse.isTimedOut(), equalTo(false));
    IndicesAliasesResponse aliasesResponse1 = client.admin().indices().prepareAliases().addAlias("test1", "test-alias").execute().actionGet();
    assertThat(aliasesResponse1.isAcknowledged(), equalTo(true));
    IndicesAliasesResponse aliasesResponse2 = client.admin().indices().prepareAliases().addAlias("test2", "test-alias").execute().actionGet();
    assertThat(aliasesResponse2.isAcknowledged(), equalTo(true));
    CloseIndexResponse closeIndexResponse = client.admin().indices().prepareClose("test-alias").execute().actionGet();
    assertThat(closeIndexResponse.isAcknowledged(), equalTo(true));
    assertIndexIsClosed("test1", "test2");
    OpenIndexResponse openIndexResponse = client.admin().indices().prepareOpen("test-alias").execute().actionGet();
    assertThat(openIndexResponse.isAcknowledged(), equalTo(true));
    assertIndexIsOpened("test1", "test2");
}
Also used : ClusterHealthResponse(org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse) CloseIndexResponse(org.elasticsearch.action.admin.indices.close.CloseIndexResponse) OpenIndexResponse(org.elasticsearch.action.admin.indices.open.OpenIndexResponse) Client(org.elasticsearch.client.Client) IndicesAliasesResponse(org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse)

Example 87 with ClusterHealthResponse

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse in project elasticsearch by elastic.

the class OpenCloseIndexIT method testSimpleCloseOpenAlias.

public void testSimpleCloseOpenAlias() {
    Client client = client();
    createIndex("test1");
    ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
    assertThat(healthResponse.isTimedOut(), equalTo(false));
    IndicesAliasesResponse aliasesResponse = client.admin().indices().prepareAliases().addAlias("test1", "test1-alias").execute().actionGet();
    assertThat(aliasesResponse.isAcknowledged(), equalTo(true));
    CloseIndexResponse closeIndexResponse = client.admin().indices().prepareClose("test1-alias").execute().actionGet();
    assertThat(closeIndexResponse.isAcknowledged(), equalTo(true));
    assertIndexIsClosed("test1");
    OpenIndexResponse openIndexResponse = client.admin().indices().prepareOpen("test1-alias").execute().actionGet();
    assertThat(openIndexResponse.isAcknowledged(), equalTo(true));
    assertIndexIsOpened("test1");
}
Also used : ClusterHealthResponse(org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse) CloseIndexResponse(org.elasticsearch.action.admin.indices.close.CloseIndexResponse) OpenIndexResponse(org.elasticsearch.action.admin.indices.open.OpenIndexResponse) Client(org.elasticsearch.client.Client) IndicesAliasesResponse(org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse)

Example 88 with ClusterHealthResponse

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse in project elasticsearch by elastic.

the class OpenCloseIndexIT method testCloseOpenAll.

public void testCloseOpenAll() {
    Client client = client();
    createIndex("test1", "test2", "test3");
    ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
    assertThat(healthResponse.isTimedOut(), equalTo(false));
    CloseIndexResponse closeIndexResponse = client.admin().indices().prepareClose("_all").execute().actionGet();
    assertThat(closeIndexResponse.isAcknowledged(), equalTo(true));
    assertIndexIsClosed("test1", "test2", "test3");
    OpenIndexResponse openIndexResponse = client.admin().indices().prepareOpen("_all").execute().actionGet();
    assertThat(openIndexResponse.isAcknowledged(), equalTo(true));
    assertIndexIsOpened("test1", "test2", "test3");
}
Also used : ClusterHealthResponse(org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse) CloseIndexResponse(org.elasticsearch.action.admin.indices.close.CloseIndexResponse) OpenIndexResponse(org.elasticsearch.action.admin.indices.open.OpenIndexResponse) Client(org.elasticsearch.client.Client)

Example 89 with ClusterHealthResponse

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse in project elasticsearch by elastic.

the class OpenCloseIndexIT method testOpenOneMissingIndexIgnoreMissing.

public void testOpenOneMissingIndexIgnoreMissing() {
    Client client = client();
    createIndex("test1");
    ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
    assertThat(healthResponse.isTimedOut(), equalTo(false));
    OpenIndexResponse openIndexResponse = client.admin().indices().prepareOpen("test1", "test2").setIndicesOptions(IndicesOptions.lenientExpandOpen()).execute().actionGet();
    assertThat(openIndexResponse.isAcknowledged(), equalTo(true));
    assertIndexIsOpened("test1");
}
Also used : ClusterHealthResponse(org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse) OpenIndexResponse(org.elasticsearch.action.admin.indices.open.OpenIndexResponse) Client(org.elasticsearch.client.Client)

Example 90 with ClusterHealthResponse

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse in project elasticsearch by elastic.

the class OpenCloseIndexIT method testOpenOneMissingIndex.

public void testOpenOneMissingIndex() {
    Client client = client();
    createIndex("test1");
    ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
    assertThat(healthResponse.isTimedOut(), equalTo(false));
    Exception e = expectThrows(IndexNotFoundException.class, () -> client.admin().indices().prepareOpen("test1", "test2").execute().actionGet());
    assertThat(e.getMessage(), is("no such index"));
}
Also used : ClusterHealthResponse(org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse) Client(org.elasticsearch.client.Client) IndexNotFoundException(org.elasticsearch.index.IndexNotFoundException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) ActionRequestValidationException(org.elasticsearch.action.ActionRequestValidationException)

Aggregations

ClusterHealthResponse (org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse)123 Settings (org.elasticsearch.common.settings.Settings)29 Client (org.elasticsearch.client.Client)24 ClusterState (org.elasticsearch.cluster.ClusterState)16 ClusterHealthRequest (org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest)15 Test (org.junit.Test)15 IOException (java.io.IOException)13 ClusterStateResponse (org.elasticsearch.action.admin.cluster.state.ClusterStateResponse)12 SearchResponse (org.elasticsearch.action.search.SearchResponse)11 MoveAllocationCommand (org.elasticsearch.cluster.routing.allocation.command.MoveAllocationCommand)10 CloseIndexResponse (org.elasticsearch.action.admin.indices.close.CloseIndexResponse)9 OpenIndexResponse (org.elasticsearch.action.admin.indices.open.OpenIndexResponse)9 CountDownLatch (java.util.concurrent.CountDownLatch)7 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)7 IndexRequestBuilder (org.elasticsearch.action.index.IndexRequestBuilder)7 ShardRouting (org.elasticsearch.cluster.routing.ShardRouting)7 Index (org.elasticsearch.index.Index)7 MockTransportService (org.elasticsearch.test.transport.MockTransportService)6 TransportService (org.elasticsearch.transport.TransportService)6 Path (java.nio.file.Path)5