use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest in project graylog2-server by Graylog2.
the class IndicesAdapterES7 method waitForRecovery.
@Override
public HealthStatus waitForRecovery(String index, int timeout) {
final ClusterHealthRequest clusterHealthRequest = new ClusterHealthRequest(index).timeout(TimeValue.timeValueSeconds(timeout));
clusterHealthRequest.waitForGreenStatus();
final ClusterHealthResponse result = client.execute((c, requestOptions) -> c.cluster().health(clusterHealthRequest, requestOptions));
return HealthStatus.fromString(result.getStatus().toString());
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest in project snow-owl by b2ihealthcare.
the class EsClientBase method checkClusterHealth.
private ClusterHealthResponse checkClusterHealth(ClusterHealthResponse previousHealth) {
try {
log.info("Checking cluster health at '{}'...", host.toURI());
ClusterHealthRequest req = new ClusterHealthRequest();
req.level(Level.INDICES);
// The default indices options (IndicesOptions.lenientExpandHidden()) returns all indices including system or hidden.
// It is not possible to determine if a hidden index is read only or not.
// This leads to the isIndexReadOnly() method waiting 60 seconds for each hidden index, eventually causing requests to be stalled.
req.indicesOptions(IndicesOptions.lenientExpand());
return cluster().health(req);
} catch (IOException e) {
throw new IndexException("Failed to get cluster health", e);
}
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest in project sonarqube by SonarSource.
the class EsRequestDetailsTest method should_format_ClusterHealthRequest.
@Test
public void should_format_ClusterHealthRequest() {
ClusterHealthRequest request = new ClusterHealthRequest("index-1");
assertThat(EsRequestDetails.computeDetailsAsString(request)).isEqualTo("ES cluster health request on indices 'index-1'");
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest in project pancm_project by xuwujing.
the class EsHighLevelCluster method catHealth.
/**
* @return void
* @Author pancm
* @Description 设获取集群的健康情况
* @Date 2020/1/2
* @Param [index]
*/
public static void catHealth() throws IOException {
ClusterHealthRequest request = new ClusterHealthRequest();
ClusterHealthResponse response = client.cluster().health(request, RequestOptions.DEFAULT);
String clusterName = response.getClusterName();
ClusterHealthStatus status = response.getStatus();
boolean timedOut = response.isTimedOut();
RestStatus restStatus = response.status();
int numberOfNodes = response.getNumberOfNodes();
int numberOfDataNodes = response.getNumberOfDataNodes();
int activeShards = response.getActiveShards();
int activePrimaryShards = response.getActivePrimaryShards();
int relocatingShards = response.getRelocatingShards();
int initializingShards = response.getInitializingShards();
int unassignedShards = response.getUnassignedShards();
int delayedUnassignedShards = response.getDelayedUnassignedShards();
double activeShardsPercent = response.getActiveShardsPercent();
logger.info("clusterName:{},status:{},timedOut:{},restStatus:{}", clusterName, status, timedOut, restStatus.getStatus());
List<Map<String, Object>> mapList = new ArrayList<>();
response.getIndices().forEach((k, v) -> {
Map<String, Object> map = new HashMap<>();
String index = v.getIndex();
int replicas = v.getNumberOfReplicas();
int allShards = v.getActiveShards();
int shards = v.getActivePrimaryShards();
int status2 = v.getStatus().value();
map.put("index", index);
map.put("replicas", replicas);
map.put("shards", shards);
map.put("status", status2);
System.out.println(map);
});
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest in project elasticsearch by elastic.
the class TransportClientTests method testThatUsingAClosedClientThrowsAnException.
public void testThatUsingAClosedClientThrowsAnException() throws ExecutionException, InterruptedException {
final TransportClient client = new MockTransportClient(Settings.EMPTY);
client.close();
final IllegalStateException e = expectThrows(IllegalStateException.class, () -> client.admin().cluster().health(new ClusterHealthRequest()).get());
assertThat(e, hasToString(containsString("transport client is closed")));
}
Aggregations