本文整理了Java中org.elasticsearch.action.admin.cluster.health.ClusterHealthRequestBuilder.setWaitForNodes()
方法的一些代码示例,展示了ClusterHealthRequestBuilder.setWaitForNodes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ClusterHealthRequestBuilder.setWaitForNodes()
方法的具体详情如下:
包路径:org.elasticsearch.action.admin.cluster.health.ClusterHealthRequestBuilder
类名称:ClusterHealthRequestBuilder
方法名:setWaitForNodes
[英]Waits for N number of nodes. Use "12" for exact mapping, ">12" and "<12" for range.
[中]等待N个节点。使用“12”表示精确映射,“>12”和“<12”表示范围。
代码示例来源: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: com.strapdata.elasticsearch.test/framework
protected void ensureNodeCount(InternalTestCluster cluster) {
assertFalse("cluster failed to form after disruption was healed", cluster.client().admin().cluster().prepareHealth()
.setWaitForNodes(String.valueOf(cluster.size()))
.setWaitForNoRelocatingShards(true)
.get().isTimedOut());
}
代码示例来源:origin: com.strapdata.elasticsearch.test/framework
protected void ensureNodeCount(InternalTestCluster cluster) {
assertFalse("cluster failed to form after disruption was healed", cluster.client().admin().cluster().prepareHealth()
.setWaitForNodes(String.valueOf(cluster.size()))
.setWaitForNoRelocatingShards(true)
.get().isTimedOut());
}
}
代码示例来源:origin: com.strapdata.elasticsearch.test/framework
protected void ensureClusterSizeConsistency() {
if (cluster() != null && cluster().size() > 0) { // if static init fails the cluster can be null
logger.trace("Check consistency for [{}] nodes", cluster().size());
assertNoTimeout(client().admin().cluster().prepareHealth().setWaitForNodes(Integer.toString(cluster().size())).get());
}
}
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-sail-elasticsearch
healthReqBuilder.setWaitForNodes(waitForNodes);
代码示例来源:origin: com.strapdata.elasticsearch.test/framework
protected void ensureStableCluster(int nodeCount, TimeValue timeValue, boolean local, @Nullable String viaNode) {
if (viaNode == null) {
viaNode = randomFrom(internalCluster().getNodeNames());
}
logger.debug("ensuring cluster is stable with [{}] nodes. access node: [{}]. timeout: [{}]", nodeCount, viaNode, timeValue);
ClusterHealthResponse clusterHealthResponse = client(viaNode).admin().cluster().prepareHealth()
.setWaitForEvents(Priority.LANGUID)
.setWaitForNodes(Integer.toString(nodeCount))
.setTimeout(timeValue)
.setLocal(local)
.setWaitForNoRelocatingShards(true)
.get();
if (clusterHealthResponse.isTimedOut()) {
ClusterStateResponse stateResponse = client(viaNode).admin().cluster().prepareState().get();
fail("failed to reach a stable cluster of [" + nodeCount + "] nodes. Tried via [" + viaNode + "]. last cluster state:\n"
+ stateResponse.getState());
}
assertThat(clusterHealthResponse.isTimedOut(), is(false));
ensureFullyConnectedCluster();
}
代码示例来源: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");
}
}
内容来源于网络,如有侵权,请联系作者删除!