當前位置: 首頁>>代碼示例>>Java>>正文


Java ClusterHealthResponse.isTimedOut方法代碼示例

本文整理匯總了Java中org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse.isTimedOut方法的典型用法代碼示例。如果您正苦於以下問題:Java ClusterHealthResponse.isTimedOut方法的具體用法?Java ClusterHealthResponse.isTimedOut怎麽用?Java ClusterHealthResponse.isTimedOut使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse的用法示例。


在下文中一共展示了ClusterHealthResponse.isTimedOut方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createIndex

import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; //導入方法依賴的package包/類
@SuppressWarnings("unused")
protected void createIndex(String indexName) throws IOException {
    CreateIndexResponse createResponse = client.admin().indices().prepareCreate(indexName)
            .setSettings(Settings.builder()
                    .put("number_of_shards", getConfig().getNumberOfShards())
                    .put("number_of_replicas", getConfig().getNumberOfReplicas())
            )
            .execute().actionGet();

    ClusterHealthResponse health = client.admin().cluster().prepareHealth(indexName)
            .setWaitForGreenStatus()
            .execute().actionGet();
    LOGGER.debug("Index status: %s", health.toString());
    if (health.isTimedOut()) {
        LOGGER.warn("timed out waiting for yellow/green index status, for index: %s", indexName);
    }
}
 
開發者ID:mware-solutions,項目名稱:memory-graph,代碼行數:18,代碼來源:Elasticsearch5SearchIndex.java

示例2: waitForRelocation

import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; //導入方法依賴的package包/類
/**
 * Waits for all relocating shards to become active and the cluster has reached the given health status
 * using the cluster health API.
 */
public ClusterHealthStatus waitForRelocation(ClusterHealthStatus status) {
    ClusterHealthRequest request = Requests.clusterHealthRequest().waitForNoRelocatingShards(true);
    if (status != null) {
        request.waitForStatus(status);
    }
    ClusterHealthResponse actionGet = client().admin().cluster()
        .health(request).actionGet();
    if (actionGet.isTimedOut()) {
        logger.info("waitForRelocation timed out (status={}), cluster state:\n{}\n{}", status,
            client().admin().cluster().prepareState().get().getState(), client().admin().cluster().preparePendingClusterTasks().get());
        assertThat("timed out waiting for relocation", actionGet.isTimedOut(), equalTo(false));
    }
    if (status != null) {
        assertThat(actionGet.getStatus(), equalTo(status));
    }
    return actionGet.getStatus();
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:22,代碼來源:ESIntegTestCase.java

示例3: ensureStableCluster

import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; //導入方法依賴的package包/類
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();
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:21,代碼來源:ESIntegTestCase.java

示例4: getClient

import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; //導入方法依賴的package包/類
public Client getClient() {
    if (!staticValue.isNeedEs()) {
        LOG.info("已在配置文件中聲明不需要ES,如需要ES,請在配置文件中進行配置");
        return null;
    }
    if (client != null) return client;
    try {
        LOG.info("正在初始化ElasticSearch客戶端," + staticValue.getEsHost());
        Settings settings = Settings.builder()
                .put("cluster.name", staticValue.getEsClusterName()).build();
        client = new PreBuiltTransportClient(settings)
                .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(staticValue.getEsHost()), 9300));
        final ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth()
                .setTimeout(TimeValue.timeValueMinutes(1)).execute().actionGet();
        if (healthResponse.isTimedOut()) {
            LOG.error("ES客戶端初始化失敗");
        } else {
            LOG.info("ES客戶端初始化成功");
        }
    } catch (IOException e) {
        LOG.fatal("構建ElasticSearch客戶端失敗!");
    }
    return client;
}
 
開發者ID:bruceq,項目名稱:Gather-Platform,代碼行數:25,代碼來源:ESClient.java

示例5: checkStatus

import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; //導入方法依賴的package包/類
@Override
public String checkStatus() throws Exception {

  final ClusterHealthResponse healthResponse = esClient
      .admin().cluster().prepareHealth().execute().actionGet();

  if (healthResponse.isTimedOut()) {
    return EsStatus.TIMEOUT.toString();

  } else if (ClusterHealthStatus.RED.equals(healthResponse.getStatus())) {
    logger.warn("Elastic search health status is reported RED");
    return EsStatus.ERROR.toString();

  } else if (ClusterHealthStatus.GREEN.equals(healthResponse.getStatus())) {
    return EsStatus.SUCCESS.toString();

  } else {
    logger.warn("Elastic search health status is unknown");
    return EsStatus.UNKNOWN.toString();
  }
}
 
開發者ID:pinterest,項目名稱:soundwave,代碼行數:22,代碼來源:EsInstanceStore.java

示例6: getClient

import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; //導入方法依賴的package包/類
public Client getClient() {
	if(!sValue.isNeedES()) {
		LOG.info("配置文件已聲明不需要ES, 如需要ES, 請更改配置文件");
		return null;
	}
	if(client!=null)
		return client;
	LOG.info("正在初始化客戶端, Host:{},Port:{}", sValue.getEsHost(), sValue.getEsPort());
	Settings settings = Settings.builder()
	        .put("cluster.name", sValue.getEsClusterName()).build();
	try {
		client = new PreBuiltTransportClient(settings)
		        .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(sValue.getEsHost()), sValue.getEsPort()));
	    final ClusterHealthResponse healthResponse = client.admin().cluster()
	    		.prepareHealth().setTimeout(TimeValue.timeValueMinutes(1)).get();
	    if(healthResponse.isTimedOut()) 
	    	LOG.info("ES客戶端初始化失敗,響應超時");
	    else
	    	LOG.info("ES客戶端初始化成功");
	} catch(IOException e) {
		LOG.fatal("ES客戶端構建失敗,由於 " + e.getLocalizedMessage());
	}
	return client;
}
 
開發者ID:TransientBuckwheat,項目名稱:nest-spider,代碼行數:25,代碼來源:ESClient.java

示例7: getClient

import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; //導入方法依賴的package包/類
public Client getClient() {
    if (!staticValue.isNeedEs()) {
        LOG.info("已在配置文件中聲明不需要ES,如需要ES,請在配置文件中進行配置");
        return null;
    }
    if (client != null) return client;
    LOG.info("正在初始化ElasticSearch客戶端," + staticValue.getEsHost());
    
    Settings settings = Settings.builder()
    		.put("cluster.name", staticValue.getEsClusterName()).build();
    try {
    	client = new PreBuiltTransportClient(settings)
    			.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(staticValue.getEsHost()), staticValue.getEsPort()));
        final ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth()
                .setTimeout(TimeValue.timeValueMinutes(1)).execute().actionGet();
        if (healthResponse.isTimedOut()) {
            LOG.error("ES客戶端初始化失敗");
        } else {
            LOG.info("ES客戶端初始化成功");
        }
    } catch (IOException e) {
        LOG.fatal("構建ElasticSearch客戶端失敗!");
    }
    return client;
}
 
開發者ID:gsh199449,項目名稱:spider,代碼行數:26,代碼來源:ESClient.java

示例8: startNodes

import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; //導入方法依賴的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

示例9: createIndex

import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; //導入方法依賴的package包/類
@SuppressWarnings("unused")
protected void createIndex(String indexName) {
    CreateIndexResponse createResponse = client.admin().indices().prepareCreate(indexName)
            .setSettings(Settings.builder()
                    .put("number_of_shards", getConfig().getNumberOfShards())
                    .put("number_of_replicas", getConfig().getNumberOfReplicas())
                    .put("index.mapping.total_fields.limit", getConfig().getIndexMappingTotalFieldsLimit())
            )
            .execute().actionGet();

    ClusterHealthResponse health = client.admin().cluster().prepareHealth(indexName)
            .setWaitForGreenStatus()
            .execute().actionGet();
    LOGGER.debug("Index status: %s", health.toString());
    if (health.isTimedOut()) {
        LOGGER.warn("timed out waiting for yellow/green index status, for index: %s", indexName);
    }
}
 
開發者ID:visallo,項目名稱:vertexium,代碼行數:19,代碼來源:Elasticsearch5SearchIndex.java

示例10: ensureGreen

import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; //導入方法依賴的package包/類
/**
 * Ensures the cluster has a green state via the cluster health API. This method will also wait for relocations.
 * It is useful to ensure that all action on the cluster have finished and all shards that were currently relocating
 * are now allocated and started.
 *
 * @param timeout
 *            time out value to set on {@link org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest}
 */
public ClusterHealthStatus ensureGreen(final TimeValue timeout, final String... indices) {
    final ClusterHealthResponse actionGet = client()
            .admin()
            .cluster()
            .health(Requests.clusterHealthRequest(indices).timeout(timeout).waitForGreenStatus().waitForEvents(Priority.LANGUID)
                    .waitForRelocatingShards(0)).actionGet();
    if (actionGet.isTimedOut()) {
        logger.info("ensureGreen timed out, cluster state:\n{}\n{}", client().admin().cluster().prepareState().get().getState()
                .prettyPrint(), client().admin().cluster().preparePendingClusterTasks().get().prettyPrint());
        assertThat("timed out waiting for green state", actionGet.isTimedOut(), equalTo(false));
    }
    assertThat(actionGet.getStatus(), equalTo(ClusterHealthStatus.GREEN));
    logger.debug("indices {} are green", indices.length == 0 ? "[_all]" : indices);
    return actionGet.getStatus();
}
 
開發者ID:salyh,項目名稱:elasticsearch-sample-plugin-audit,代碼行數:24,代碼來源:ElasticsearchIntegrationTest.java

示例11: waitForRelocation

import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; //導入方法依賴的package包/類
/**
 * Waits for all relocating shards to become active and the cluster has reached the given health status
 * using the cluster health API.
 */
public ClusterHealthStatus waitForRelocation(final ClusterHealthStatus status) {
    final ClusterHealthRequest request = Requests.clusterHealthRequest().waitForRelocatingShards(0);
    if (status != null) {
        request.waitForStatus(status);
    }
    final ClusterHealthResponse actionGet = client().admin().cluster().health(request).actionGet();
    if (actionGet.isTimedOut()) {
        logger.info("waitForRelocation timed out (status={}), cluster state:\n{}\n{}", status, client().admin().cluster()
                .prepareState().get().getState().prettyPrint(), client().admin().cluster().preparePendingClusterTasks().get()
                .prettyPrint());
        assertThat("timed out waiting for relocation", actionGet.isTimedOut(), equalTo(false));
    }
    if (status != null) {
        assertThat(actionGet.getStatus(), equalTo(status));
    }
    return actionGet.getStatus();
}
 
開發者ID:salyh,項目名稱:elasticsearch-sample-plugin-audit,代碼行數:22,代碼來源:ElasticsearchIntegrationTest.java

示例12: waitForCluster

import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; //導入方法依賴的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

示例13: startCluster

import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; //導入方法依賴的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

示例14: ensureGreen

import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; //導入方法依賴的package包/類
/**
 * Wait for green state of a cluster.
 *
 * @param indices
 * @return
 */
public ClusterHealthStatus ensureGreen(final String... indices) {
    final ClusterHealthResponse actionGet = client().admin().cluster()
            .health(Requests.clusterHealthRequest(indices)
                    .waitForGreenStatus().waitForEvents(Priority.LANGUID)
                    .waitForNoRelocatingShards(true))
            .actionGet();
    if (actionGet.isTimedOut()) {
        onFailure("ensureGreen timed out, cluster state:\n"
                + client().admin().cluster().prepareState().get().getState()
                + "\n" + client().admin().cluster()
                        .preparePendingClusterTasks().get(),
                actionGet);
    }
    return actionGet.getStatus();
}
 
開發者ID:codelibs,項目名稱:elasticsearch-cluster-runner,代碼行數:22,代碼來源:ElasticsearchClusterRunner.java

示例15: ensureYellow

import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; //導入方法依賴的package包/類
/**
 * Wait for yellow state of a cluster.
 *
 * @param indices
 * @return
 */
public ClusterHealthStatus ensureYellow(final String... indices) {
    final ClusterHealthResponse actionGet = client().admin().cluster()
            .health(Requests.clusterHealthRequest(indices)
                    .waitForNoRelocatingShards(true).waitForYellowStatus()
                    .waitForEvents(Priority.LANGUID))
            .actionGet();
    if (actionGet.isTimedOut()) {
        onFailure("ensureYellow timed out, cluster state:\n" + "\n"
                + client().admin().cluster().prepareState().get().getState()
                + "\n" + client().admin().cluster()
                        .preparePendingClusterTasks().get(),
                actionGet);
    }
    return actionGet.getStatus();
}
 
開發者ID:codelibs,項目名稱:elasticsearch-cluster-runner,代碼行數:22,代碼來源:ElasticsearchClusterRunner.java


注:本文中的org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse.isTimedOut方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。