本文整理了Java中org.elasticsearch.action.admin.cluster.health.ClusterHealthRequestBuilder.setWaitForStatus()
方法的一些代码示例,展示了ClusterHealthRequestBuilder.setWaitForStatus()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ClusterHealthRequestBuilder.setWaitForStatus()
方法的具体详情如下:
包路径:org.elasticsearch.action.admin.cluster.health.ClusterHealthRequestBuilder
类名称:ClusterHealthRequestBuilder
方法名:setWaitForStatus
暂无
代码示例来源:origin: loklak/loklak_server
public boolean wait_ready(long maxtimemillis, ClusterHealthStatus status) {
// wait for yellow status
long start = System.currentTimeMillis();
boolean is_ready;
do {
// wait for yellow status
ClusterHealthResponse health = elasticsearchClient.admin().cluster().prepareHealth().setWaitForStatus(status).execute().actionGet();
is_ready = !health.isTimedOut();
if (!is_ready && System.currentTimeMillis() - start > maxtimemillis) return false;
} while (!is_ready);
return is_ready;
}
代码示例来源:origin: SonarSource/sonarqube
public void waitForStatus(ClusterHealthStatus status) {
prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForStatus(status).get();
}
代码示例来源:origin: SonarSource/sonarqube
throw new IllegalStateException("Failed to create index " + index.getName());
SHARED_NODE.client().admin().cluster().prepareHealth(index.getName()).setWaitForStatus(ClusterHealthStatus.YELLOW).get();
SHARED_NODE.client().admin().cluster().prepareHealth(index.getName()).setWaitForStatus(ClusterHealthStatus.YELLOW).get();
result.add(index);
代码示例来源:origin: floragunncom/search-guard
log.debug("waiting for cluster state {} and {} nodes", status.name(), expectedNodeCount);
final ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth()
.setWaitForStatus(status).setTimeout(timeout).setMasterNodeTimeout(timeout).setWaitForNodes("" + expectedNodeCount).execute()
.actionGet();
if (healthResponse.isTimedOut()) {
代码示例来源:origin: yacy/yacy_grid_mcp
public boolean wait_ready(long maxtimemillis, ClusterHealthStatus status) {
// wait for yellow status
long start = System.currentTimeMillis();
boolean is_ready;
do {
// wait for yellow status
ClusterHealthResponse health = elasticsearchClient.admin().cluster().prepareHealth().setWaitForStatus(status).execute().actionGet();
is_ready = !health.isTimedOut();
if (!is_ready && System.currentTimeMillis() - start > maxtimemillis) return false;
} while (!is_ready);
return is_ready;
}
代码示例来源:origin: org.sonarsource.sonarqube/sonar-server
public void waitForStatus(ClusterHealthStatus status) {
prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForStatus(status).get();
}
代码示例来源:origin: salyh/elasticsearch-imap
private void waitForCluster(final ClusterHealthStatus status, final TimeValue timeout) throws IOException {
try {
logger.debug("waiting for cluster state {}", status.name());
final ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForStatus(status)
.setTimeout(timeout).execute().actionGet();
if (healthResponse.isTimedOut()) {
throw new IOException("cluster state is " + healthResponse.getStatus().name() + " and not " + status.name()
+ ", cowardly refusing to continue with operations");
} else {
logger.debug("... cluster state ok");
}
} catch (final ElasticsearchTimeoutException e) {
throw new IOException("timeout, cluster does not respond to health request, cowardly refusing to continue with operations");
}
}
代码示例来源:origin: salyh/elasticsearch-imap
public static void waitForYellowCluster(Client client) throws IOException {
ClusterHealthStatus status = ClusterHealthStatus.YELLOW;
try {
logger.debug("waiting for cluster state {}", status.name());
final ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForStatus(status)
.setTimeout(TimeValue.timeValueSeconds(30)).execute().actionGet();
if (healthResponse.isTimedOut()) {
logger.error("Timeout while waiting for cluster state: {}, current cluster state is: {}", status.name(), healthResponse.getStatus().name());
throw new IOException("cluster state is " + healthResponse.getStatus().name() + " and not " + status.name()
+ ", cowardly refusing to continue with operations");
} else {
logger.debug("... cluster state ok");
}
} catch (final Exception e) {
logger.error("Exception while waiting for cluster state: {} due to ", e, status.name(), e.toString());
throw new IOException("timeout, cluster does not respond to health request, cowardly refusing to continue with operations", e);
}
}
}
代码示例来源:origin: floragunncom/search-guard-ssl
protected void waitForCluster(final ClusterHealthStatus status, final TimeValue timeout, final Client client) throws IOException {
try {
log.debug("waiting for cluster state {}", status.name());
final ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForStatus(status)
.setTimeout(timeout).setWaitForNodes("3").execute().actionGet();
if (healthResponse.isTimedOut()) {
throw new IOException("cluster state is " + healthResponse.getStatus().name() + " with "
+ healthResponse.getNumberOfNodes() + " nodes");
} else {
log.debug("... cluster state ok " + healthResponse.getStatus().name() + " with " + healthResponse.getNumberOfNodes()
+ " nodes");
}
final NodesInfoResponse res = esNode1.client().admin().cluster().nodesInfo(new NodesInfoRequest()).actionGet();
final List<NodeInfo> nodes = res.getNodes();
for (NodeInfo nodeInfo: nodes) {
if (nodeInfo.getHttp() != null && nodeInfo.getHttp().address() != null) {
final TransportAddress is = nodeInfo.getHttp().address().publishAddress();
httpPort = is.getPort();
httpHost = is.getAddress();
}
final TransportAddress is = nodeInfo.getTransport().getAddress().publishAddress();
nodePort = is.getPort();
nodeHost = is.getAddress();
}
} catch (final ElasticsearchTimeoutException e) {
throw new IOException("timeout, cluster does not respond to health request, cowardly refusing to continue with operations");
}
}
内容来源于网络,如有侵权,请联系作者删除!