Search in sources :

Example 6 with CloseIndexResponse

use of org.elasticsearch.action.admin.indices.close.CloseIndexResponse in project elasticsearch by elastic.

the class OpenCloseIndexIT method testCloseOneMissingIndexIgnoreMissing.

public void testCloseOneMissingIndexIgnoreMissing() {
    Client client = client();
    createIndex("test1");
    ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
    assertThat(healthResponse.isTimedOut(), equalTo(false));
    CloseIndexResponse closeIndexResponse = client.admin().indices().prepareClose("test1", "test2").setIndicesOptions(IndicesOptions.lenientExpandOpen()).execute().actionGet();
    assertThat(closeIndexResponse.isAcknowledged(), equalTo(true));
    assertIndexIsClosed("test1");
}
Also used : ClusterHealthResponse(org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse) CloseIndexResponse(org.elasticsearch.action.admin.indices.close.CloseIndexResponse) Client(org.elasticsearch.client.Client)

Example 7 with CloseIndexResponse

use of org.elasticsearch.action.admin.indices.close.CloseIndexResponse in project elasticsearch by elastic.

the class AckClusterUpdateSettingsIT method testOpenIndexNoAcknowledgement.

public void testOpenIndexNoAcknowledgement() {
    createIndex("test");
    ensureGreen();
    removePublishTimeout();
    CloseIndexResponse closeIndexResponse = client().admin().indices().prepareClose("test").execute().actionGet();
    assertThat(closeIndexResponse.isAcknowledged(), equalTo(true));
    OpenIndexResponse openIndexResponse = client().admin().indices().prepareOpen("test").setTimeout("0s").get();
    assertThat(openIndexResponse.isAcknowledged(), equalTo(false));
    // make sure that recovery from disk has completed, so that check index doesn't fail.
    ensureGreen("test");
}
Also used : CloseIndexResponse(org.elasticsearch.action.admin.indices.close.CloseIndexResponse) OpenIndexResponse(org.elasticsearch.action.admin.indices.open.OpenIndexResponse)

Example 8 with CloseIndexResponse

use of org.elasticsearch.action.admin.indices.close.CloseIndexResponse in project elasticsearch by elastic.

the class AckIT method testCloseIndexNoAcknowledgement.

public void testCloseIndexNoAcknowledgement() {
    createIndex("test");
    ensureGreen();
    CloseIndexResponse closeIndexResponse = client().admin().indices().prepareClose("test").setTimeout("0s").get();
    assertThat(closeIndexResponse.isAcknowledged(), equalTo(false));
}
Also used : CloseIndexResponse(org.elasticsearch.action.admin.indices.close.CloseIndexResponse)

Example 9 with CloseIndexResponse

use of org.elasticsearch.action.admin.indices.close.CloseIndexResponse in project elasticsearch by elastic.

the class OpenCloseIndexIT method testCloseOpenMultipleIndices.

public void testCloseOpenMultipleIndices() {
    Client client = client();
    createIndex("test1", "test2", "test3");
    ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
    assertThat(healthResponse.isTimedOut(), equalTo(false));
    CloseIndexResponse closeIndexResponse1 = client.admin().indices().prepareClose("test1").execute().actionGet();
    assertThat(closeIndexResponse1.isAcknowledged(), equalTo(true));
    CloseIndexResponse closeIndexResponse2 = client.admin().indices().prepareClose("test2").execute().actionGet();
    assertThat(closeIndexResponse2.isAcknowledged(), equalTo(true));
    assertIndexIsClosed("test1", "test2");
    assertIndexIsOpened("test3");
    OpenIndexResponse openIndexResponse1 = client.admin().indices().prepareOpen("test1").execute().actionGet();
    assertThat(openIndexResponse1.isAcknowledged(), equalTo(true));
    OpenIndexResponse openIndexResponse2 = client.admin().indices().prepareOpen("test2").execute().actionGet();
    assertThat(openIndexResponse2.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 10 with CloseIndexResponse

use of org.elasticsearch.action.admin.indices.close.CloseIndexResponse 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)

Aggregations

CloseIndexResponse (org.elasticsearch.action.admin.indices.close.CloseIndexResponse)13 OpenIndexResponse (org.elasticsearch.action.admin.indices.open.OpenIndexResponse)10 ClusterHealthResponse (org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse)9 Client (org.elasticsearch.client.Client)9 IndicesAliasesResponse (org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse)2 ClusterStateResponse (org.elasticsearch.action.admin.cluster.state.ClusterStateResponse)1 IndexClosedException (org.elasticsearch.indices.IndexClosedException)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1