本文整理汇总了Java中org.elasticsearch.action.admin.cluster.health.ClusterHealthAction类的典型用法代码示例。如果您正苦于以下问题:Java ClusterHealthAction类的具体用法?Java ClusterHealthAction怎么用?Java ClusterHealthAction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClusterHealthAction类属于org.elasticsearch.action.admin.cluster.health包,在下文中一共展示了ClusterHealthAction类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testMasterNodeOperationTasks
import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction; //导入依赖的package包/类
public void testMasterNodeOperationTasks() {
registerTaskManageListeners(ClusterHealthAction.NAME);
// First run the health on the master node - should produce only one task on the master node
internalCluster().masterClient().admin().cluster().prepareHealth().get();
assertEquals(1, numberOfEvents(ClusterHealthAction.NAME, Tuple::v1)); // counting only registration events
assertEquals(1, numberOfEvents(ClusterHealthAction.NAME, event -> event.v1() == false)); // counting only unregistration events
resetTaskManageListeners(ClusterHealthAction.NAME);
// Now run the health on a non-master node - should produce one task on master and one task on another node
internalCluster().nonMasterClient().admin().cluster().prepareHealth().get();
assertEquals(2, numberOfEvents(ClusterHealthAction.NAME, Tuple::v1)); // counting only registration events
assertEquals(2, numberOfEvents(ClusterHealthAction.NAME, event -> event.v1() == false)); // counting only unregistration events
List<TaskInfo> tasks = findEvents(ClusterHealthAction.NAME, Tuple::v1);
// Verify that one of these tasks is a parent of another task
if (tasks.get(0).getParentTaskId().isSet()) {
assertParentTask(Collections.singletonList(tasks.get(0)), tasks.get(1));
} else {
assertParentTask(Collections.singletonList(tasks.get(1)), tasks.get(0));
}
}
示例2: startNodes
import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction; //导入依赖的package包/类
@Before
public void startNodes() {
try {
logger.info("starting");
setClusterName();
startNode("1");
findNodeAddress();
try {
ClusterHealthResponse healthResponse = client("1").execute(ClusterHealthAction.INSTANCE,
new ClusterHealthRequest().waitForStatus(ClusterHealthStatus.GREEN).timeout(TimeValue.timeValueSeconds(30))).actionGet();
if (healthResponse != null && healthResponse.isTimedOut()) {
throw new IOException("cluster state is " + healthResponse.getStatus().name()
+ ", from here on, everything will fail!");
}
} catch (ElasticsearchTimeoutException e) {
throw new IOException("timeout, cluster does not respond to health request, cowardly refusing to continue with operations");
}
} catch (Throwable t) {
logger.error("startNodes failed", t);
}
}
示例3: waitForCluster
import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction; //导入依赖的package包/类
public static void waitForCluster(Client client, ClusterHealthStatus statusThreshold,
String timeout) throws UnableToStartException {
try {
ClusterHealthResponse healthResponse = (ClusterHealthResponse) client
.execute(ClusterHealthAction.INSTANCE,
new ClusterHealthRequest().waitForStatus(statusThreshold).timeout(timeout))
.actionGet();
if (healthResponse != null && healthResponse.isTimedOut()) {
throw new UnableToStartException("cluster state is " + healthResponse.getStatus().name()
+ " and not " + statusThreshold.name()
+ ", from here on, everything will fail!");
}
} catch (ElasticsearchTimeoutException e) {
throw new UnableToStartException(
"timeout, cluster does not respond to health request, cowardly refusing to continue with operations");
}
}
示例4: startCluster
import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction; //导入依赖的package包/类
public void startCluster() {
try {
logger.info("settings cluster name");
setClusterName();
logger.info("starting nodes");
this.node = startNode();
this.client = node.client();
findNodeAddress();
ClusterHealthResponse healthResponse = client.execute(ClusterHealthAction.INSTANCE,
new ClusterHealthRequest().waitForStatus(ClusterHealthStatus.YELLOW)
.timeout(TimeValue.timeValueSeconds(30))).actionGet();
if (healthResponse != null && healthResponse.isTimedOut()) {
throw new IOException("cluster state is " + healthResponse.getStatus().name()
+ ", from here on, everything will fail!");
}
logger.info("nodes are started");
} catch (Throwable t) {
logger.error("start of nodes failed", t);
}
}
示例5: waitForCluster
import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction; //导入依赖的package包/类
public void waitForCluster(String statusString, TimeValue timeout) throws IOException {
if (client() == null) {
return;
}
try {
ClusterHealthStatus status = ClusterHealthStatus.fromString(statusString);
ClusterHealthResponse healthResponse =
client().execute(ClusterHealthAction.INSTANCE, new ClusterHealthRequest().waitForStatus(status).timeout(timeout)).actionGet();
if (healthResponse != null && healthResponse.isTimedOut()) {
throw new IOException("cluster state is " + healthResponse.getStatus().name()
+ " and not " + status.name()
+ ", from here on, everything will fail!");
}
} catch (ElasticsearchTimeoutException e) {
throw new IOException("timeout, cluster does not respond to health request, cowardly refusing to continue with operations");
}
}
示例6: waitForCluster
import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction; //导入依赖的package包/类
public static void waitForCluster(ElasticsearchClient client, ClusterHealthStatus status, TimeValue timeout) throws UnableToStartException {
try {
ClusterHealthResponse healthResponse =
(ClusterHealthResponse)client.execute(ClusterHealthAction.INSTANCE, new ClusterHealthRequest().waitForStatus(status).timeout(timeout)).actionGet();
if (healthResponse != null && healthResponse.isTimedOut()) {
throw new UnableToStartException("cluster state is " + healthResponse.getStatus().name()
+ " and not " + status.name()
+ ", from here on, everything will fail!");
}
} catch (ElasticsearchTimeoutException e) {
throw new UnableToStartException("timeout, cluster does not respond to health request, cowardly refusing to continue with operations");
}
}
示例7: isSearchEngineReady
import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction; //导入依赖的package包/类
@Override
public boolean isSearchEngineReady() {
ClusterHealthStatus status = new ClusterHealthRequestBuilder(client, ClusterHealthAction.INSTANCE)
.setIndices(configuration.getIndexName())
.setTimeout(new TimeValue(configuration.getTimeoutMillis(), TimeUnit.MILLISECONDS))
.request()
.waitForStatus();
return status != ClusterHealthStatus.RED;
}
示例8: waitForRecovery
import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction; //导入依赖的package包/类
public int waitForRecovery(String index) throws IOException {
if (client() == null) {
return -1;
}
if (index == null) {
throw new IOException("unable to waitfor recovery, index not set");
}
RecoveryResponse response = client().execute(RecoveryAction.INSTANCE, new RecoveryRequest(index)).actionGet();
int shards = response.getTotalShards();
client().execute(ClusterHealthAction.INSTANCE, new ClusterHealthRequest(index).waitForActiveShards(shards)).actionGet();
return shards;
}
示例9: health
import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction; //导入依赖的package包/类
@Override
public ActionFuture<ClusterHealthResponse> health(final ClusterHealthRequest request) {
return execute(ClusterHealthAction.INSTANCE, request);
}
示例10: prepareHealth
import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction; //导入依赖的package包/类
@Override
public ClusterHealthRequestBuilder prepareHealth(String... indices) {
return new ClusterHealthRequestBuilder(this, ClusterHealthAction.INSTANCE).setIndices(indices);
}
示例11: waitForGreenClusterState
import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction; //导入依赖的package包/类
private ClusterHealthResponse waitForGreenClusterState(String index) {
ClusterAdminClient clusterAdminClient = node.client().admin().cluster();
ClusterHealthRequest request = (new ClusterHealthRequestBuilder(clusterAdminClient, ClusterHealthAction.INSTANCE))
.setIndices(index).setWaitForGreenStatus().request();
return clusterAdminClient.health(request).actionGet();
}
示例12: getAction
import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction; //导入依赖的package包/类
public ClusterHealthAction getAction() {
return ClusterHealthAction.INSTANCE;
}