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