use of org.graylog.shaded.elasticsearch7.org.elasticsearch.cluster.health.ClusterHealthStatus in project snow-owl by b2ihealthcare.
the class EsClientBase method status.
@Override
public final EsClusterStatus status(String... indices) {
final String clusterDiagnosis = clusterAvailable.get();
final boolean available = Strings.isNullOrEmpty(clusterDiagnosis);
if (available) {
final List<EsIndexStatus> indexStatuses = newArrayList();
for (String index : indices == null || indices.length == 0 ? clusterHealth.get().getIndices().keySet() : Arrays.asList(indices)) {
// ignore health check of system / hidden indices
if (index.startsWith(".")) {
continue;
}
ClusterHealthStatus indexHealth = getIndexHealth(index);
String diagnosis = null;
// if not in red health state, check the read only flag
if (indexHealth != ClusterHealthStatus.RED && isIndexReadOnly(index)) {
indexHealth = ClusterHealthStatus.RED;
diagnosis = String.format("Index is read-only. Check/Fix source of the error (eg. run out of disk space), then run `curl -XPUT \"%s/%s/_settings\" -d '{ \"index.blocks.read_only_allow_delete\": null }'` to remove read-only flag.", host.toURI(), index);
}
indexStatuses.add(new EsIndexStatus(index, indexHealth, diagnosis));
}
return new EsClusterStatus(available, clusterDiagnosis, indexStatuses);
} else {
return new EsClusterStatus(available, clusterDiagnosis, Collections.emptyList());
}
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.cluster.health.ClusterHealthStatus in project elasticsearch by elastic.
the class AllocationService method logClusterHealthStateChange.
private void logClusterHealthStateChange(ClusterStateHealth previousStateHealth, ClusterStateHealth newStateHealth, String reason) {
ClusterHealthStatus previousHealth = previousStateHealth.getStatus();
ClusterHealthStatus currentHealth = newStateHealth.getStatus();
if (!previousHealth.equals(currentHealth)) {
logger.info("Cluster health status changed from [{}] to [{}] (reason: [{}]).", previousHealth, currentHealth, reason);
}
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.cluster.health.ClusterHealthStatus in project elasticsearch by elastic.
the class SearchWhileCreatingIndexIT method searchWhileCreatingIndex.
private void searchWhileCreatingIndex(boolean createIndex, int numberOfReplicas) throws Exception {
// TODO: randomize the wait for active shards value on index creation and ensure the appropriate
// number of data nodes are started for the randomized active shard count value
String id = randomAsciiOfLength(5);
// we will go the primary or the replica, but in a
// randomized re-creatable manner
int counter = 0;
String preference = randomAsciiOfLength(5);
logger.info("running iteration for id {}, preference {}", id, preference);
if (createIndex) {
createIndex("test");
}
client().prepareIndex("test", "type1", id).setSource("field", "test").execute().actionGet();
RefreshResponse refreshResponse = client().admin().indices().prepareRefresh("test").execute().actionGet();
// at least one shard should be successful when refreshing
assertThat(refreshResponse.getSuccessfulShards(), greaterThanOrEqualTo(1));
logger.info("using preference {}", preference);
// we want to make sure that while recovery happens, and a replica gets recovered, its properly refreshed
ClusterHealthStatus status = ClusterHealthStatus.RED;
while (status != ClusterHealthStatus.GREEN) {
// first, verify that search on the primary search works
SearchResponse searchResponse = client().prepareSearch("test").setPreference("_primary").setQuery(QueryBuilders.termQuery("field", "test")).execute().actionGet();
assertHitCount(searchResponse, 1);
Client client = client();
searchResponse = client.prepareSearch("test").setPreference(preference + Integer.toString(counter++)).setQuery(QueryBuilders.termQuery("field", "test")).execute().actionGet();
if (searchResponse.getHits().getTotalHits() != 1) {
refresh();
SearchResponse searchResponseAfterRefresh = client.prepareSearch("test").setPreference(preference).setQuery(QueryBuilders.termQuery("field", "test")).execute().actionGet();
logger.info("hits count mismatch on any shard search failed, post explicit refresh hits are {}", searchResponseAfterRefresh.getHits().getTotalHits());
ensureGreen();
SearchResponse searchResponseAfterGreen = client.prepareSearch("test").setPreference(preference).setQuery(QueryBuilders.termQuery("field", "test")).execute().actionGet();
logger.info("hits count mismatch on any shard search failed, post explicit wait for green hits are {}", searchResponseAfterGreen.getHits().getTotalHits());
assertHitCount(searchResponse, 1);
}
assertHitCount(searchResponse, 1);
status = client().admin().cluster().prepareHealth("test").get().getStatus();
internalCluster().ensureAtLeastNumDataNodes(numberOfReplicas + 1);
}
cluster().wipeIndices("test");
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.cluster.health.ClusterHealthStatus in project crate by crate.
the class AllocationService method logClusterHealthStateChange.
private void logClusterHealthStateChange(ClusterStateHealth previousStateHealth, ClusterStateHealth newStateHealth, String reason) {
ClusterHealthStatus previousHealth = previousStateHealth.getStatus();
ClusterHealthStatus currentHealth = newStateHealth.getStatus();
if (!previousHealth.equals(currentHealth)) {
LOGGER.info("Cluster health status changed from [{}] to [{}] (reason: [{}]).", previousHealth, currentHealth, reason);
}
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.cluster.health.ClusterHealthStatus in project graylog2-server by Graylog2.
the class ClientES7 method waitForStatus.
private void waitForStatus(ClusterHealthStatus status, String... indices) {
final ClusterHealthRequest clusterHealthRequest = new ClusterHealthRequest(indices);
clusterHealthRequest.waitForStatus(status);
client.execute((c, requestOptions) -> c.cluster().health(clusterHealthRequest, requestOptions));
}
Aggregations