Search in sources :

Example 21 with ClusterHealthResponse

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

the class ClusterHealthIT method testHealthOnIndexCreation.

public void testHealthOnIndexCreation() throws Exception {
    final AtomicBoolean finished = new AtomicBoolean(false);
    Thread clusterHealthThread = new Thread() {

        @Override
        public void run() {
            while (finished.get() == false) {
                ClusterHealthResponse health = client().admin().cluster().prepareHealth().get();
                assertThat(health.getStatus(), not(equalTo(ClusterHealthStatus.RED)));
            }
        }
    };
    clusterHealthThread.start();
    for (int i = 0; i < 10; i++) {
        createIndex("test" + i);
    }
    finished.set(true);
    clusterHealthThread.join();
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ClusterHealthResponse(org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse)

Example 22 with ClusterHealthResponse

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

the class ClusterHealthIT method testSimpleLocalHealth.

public void testSimpleLocalHealth() {
    createIndex("test");
    // master should thing it's green now.
    ensureGreen();
    for (String node : internalCluster().getNodeNames()) {
        // a very high time out, which should never fire due to the local flag
        ClusterHealthResponse health = client(node).admin().cluster().prepareHealth().setLocal(true).setWaitForEvents(Priority.LANGUID).setTimeout("30s").get("10s");
        assertThat(health.getStatus(), equalTo(ClusterHealthStatus.GREEN));
        assertThat(health.isTimedOut(), equalTo(false));
    }
}
Also used : ClusterHealthResponse(org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse)

Example 23 with ClusterHealthResponse

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

the class TribeIT method ensureGreen.

private void ensureGreen(Client client) throws Exception {
    assertBusy(() -> {
        ClusterHealthResponse clusterHealthResponse = client.admin().cluster().prepareHealth().setWaitForActiveShards(0).setWaitForEvents(Priority.LANGUID).setWaitForNoRelocatingShards(true).get();
        assertThat(clusterHealthResponse.getStatus(), equalTo(ClusterHealthStatus.GREEN));
        assertFalse(clusterHealthResponse.isTimedOut());
    });
}
Also used : ClusterHealthResponse(org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse)

Example 24 with ClusterHealthResponse

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

the class Netty4TransportMultiPortIntegrationIT method testThatTransportClientCanConnect.

public void testThatTransportClientCanConnect() throws Exception {
    Settings settings = Settings.builder().put("cluster.name", internalCluster().getClusterName()).put(NetworkModule.TRANSPORT_TYPE_KEY, Netty4Plugin.NETTY_TRANSPORT_NAME).put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).build();
    try (TransportClient transportClient = new MockTransportClient(settings, Netty4Plugin.class)) {
        transportClient.addTransportAddress(new TransportAddress(InetAddress.getByName("127.0.0.1"), randomPort));
        ClusterHealthResponse response = transportClient.admin().cluster().prepareHealth().get();
        assertThat(response.getStatus(), is(ClusterHealthStatus.GREEN));
    }
}
Also used : TransportClient(org.elasticsearch.client.transport.TransportClient) MockTransportClient(org.elasticsearch.transport.MockTransportClient) ClusterHealthResponse(org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse) BoundTransportAddress(org.elasticsearch.common.transport.BoundTransportAddress) TransportAddress(org.elasticsearch.common.transport.TransportAddress) MockTransportClient(org.elasticsearch.transport.MockTransportClient) Settings(org.elasticsearch.common.settings.Settings)

Example 25 with ClusterHealthResponse

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

the class ZenDiscoveryIT method testNoShardRelocationsOccurWhenElectedMasterNodeFails.

public void testNoShardRelocationsOccurWhenElectedMasterNodeFails() throws Exception {
    Settings defaultSettings = Settings.builder().put(FaultDetection.PING_TIMEOUT_SETTING.getKey(), "1s").put(FaultDetection.PING_RETRIES_SETTING.getKey(), "1").build();
    Settings masterNodeSettings = Settings.builder().put(Node.NODE_DATA_SETTING.getKey(), false).put(defaultSettings).build();
    internalCluster().startNodes(2, masterNodeSettings);
    Settings dateNodeSettings = Settings.builder().put(Node.NODE_MASTER_SETTING.getKey(), false).put(defaultSettings).build();
    internalCluster().startNodes(2, dateNodeSettings);
    ClusterHealthResponse clusterHealthResponse = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForNodes("4").setWaitForNoRelocatingShards(true).get();
    assertThat(clusterHealthResponse.isTimedOut(), is(false));
    createIndex("test");
    ensureSearchable("test");
    RecoveryResponse r = client().admin().indices().prepareRecoveries("test").get();
    int numRecoveriesBeforeNewMaster = r.shardRecoveryStates().get("test").size();
    final String oldMaster = internalCluster().getMasterName();
    internalCluster().stopCurrentMasterNode();
    assertBusy(() -> {
        String current = internalCluster().getMasterName();
        assertThat(current, notNullValue());
        assertThat(current, not(equalTo(oldMaster)));
    });
    ensureSearchable("test");
    r = client().admin().indices().prepareRecoveries("test").get();
    int numRecoveriesAfterNewMaster = r.shardRecoveryStates().get("test").size();
    assertThat(numRecoveriesAfterNewMaster, equalTo(numRecoveriesBeforeNewMaster));
}
Also used : ClusterHealthResponse(org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse) Matchers.containsString(org.hamcrest.Matchers.containsString) Settings(org.elasticsearch.common.settings.Settings) RecoveryResponse(org.elasticsearch.action.admin.indices.recovery.RecoveryResponse)

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