当前位置: 首页>>代码示例>>Java>>正文


Java ClusterHealthAction类代码示例

本文整理汇总了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));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:TasksIT.java

示例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);
    }
}
 
开发者ID:jprante,项目名称:elasticsearch-client-http,代码行数:22,代码来源:NodeTestUtils.java

示例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");
  }
}
 
开发者ID:apache,项目名称:metron,代码行数:18,代码来源:ElasticSearchComponent.java

示例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);
    }
}
 
开发者ID:jprante,项目名称:elasticsearch-analysis-reference,代码行数:21,代码来源:NodeTestUtils.java

示例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");
    }
}
 
开发者ID:jprante,项目名称:elasticsearch-helper,代码行数:18,代码来源:BaseClient.java

示例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");
    }
}
 
开发者ID:cestella,项目名称:streaming_outliers,代码行数:14,代码来源:ElasticSearchComponent.java

示例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;
}
 
开发者ID:flaxsearch,项目名称:BioSolr,代码行数:10,代码来源:ElasticSearchEngine.java

示例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;
}
 
开发者ID:jprante,项目名称:elasticsearch-helper,代码行数:13,代码来源:BaseClient.java

示例9: health

import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction; //导入依赖的package包/类
@Override
public ActionFuture<ClusterHealthResponse> health(final ClusterHealthRequest request) {
    return execute(ClusterHealthAction.INSTANCE, request);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AbstractClient.java

示例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);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AbstractClient.java

示例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();
}
 
开发者ID:egovernments,项目名称:egov-search,代码行数:7,代码来源:AbstractNodeIntegrationTest.java

示例12: getAction

import org.elasticsearch.action.admin.cluster.health.ClusterHealthAction; //导入依赖的package包/类
public ClusterHealthAction getAction() {
    return ClusterHealthAction.INSTANCE;
}
 
开发者ID:obourgain,项目名称:elasticsearch-http,代码行数:4,代码来源:ClusterHealthActionHandler.java


注:本文中的org.elasticsearch.action.admin.cluster.health.ClusterHealthAction类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。