org.elasticsearch.client.IndicesAdminClient.prepareForceMerge()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(3.5k)|赞(0)|评价(0)|浏览(101)

本文整理了Java中org.elasticsearch.client.IndicesAdminClient.prepareForceMerge()方法的一些代码示例,展示了IndicesAdminClient.prepareForceMerge()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IndicesAdminClient.prepareForceMerge()方法的具体详情如下:
包路径:org.elasticsearch.client.IndicesAdminClient
类名称:IndicesAdminClient
方法名:prepareForceMerge

IndicesAdminClient.prepareForceMerge介绍

[英]Explicitly force mergee one or more indices into a the number of segments.
[中]显式强制将一个或多个索引合并到一个包含段数的索引中。

代码示例

代码示例来源:origin: SonarSource/sonarqube

public ForceMergeRequestBuilder prepareForceMerge(String indexName) {
 // TODO add proxy for profiling
 return nativeClient().admin().indices().prepareForceMerge(indexName)
  .setMaxNumSegments(1);
}

代码示例来源:origin: org.nuxeo.elasticsearch/nuxeo-elasticsearch-core

@Override
public void optimize(String indexName) {
  client.admin().indices().prepareForceMerge(indexName).get();
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-server

public ForceMergeRequestBuilder prepareForceMerge(String indexName) {
 // TODO add proxy for profiling
 return nativeClient().admin().indices().prepareForceMerge(indexName)
  .setMaxNumSegments(1);
}

代码示例来源:origin: codelibs/elasticsearch-cluster-runner

public ForceMergeResponse forceMerge(
    final BuilderCallback<ForceMergeRequestBuilder> builder) {
  waitForRelocation();
  final ForceMergeResponse actionGet = builder
      .apply(client().admin().indices().prepareForceMerge()).execute()
      .actionGet();
  final ShardOperationFailedException[] shardFailures = actionGet
      .getShardFailures();
  if (shardFailures != null && shardFailures.length != 0) {
    final StringBuilder buf = new StringBuilder(100);
    for (final ShardOperationFailedException shardFailure : shardFailures) {
      buf.append(shardFailure.toString()).append('\n');
    }
    onFailure(buf.toString(), actionGet);
  }
  return actionGet;
}

代码示例来源:origin: com.strapdata.elasticsearch.test/framework

/**
 * Waits for all relocations and force merge all indices in the cluster to 1 segment.
 */
protected ForceMergeResponse forceMerge() {
  waitForRelocation();
  ForceMergeResponse actionGet = client().admin().indices().prepareForceMerge().setMaxNumSegments(1).execute().actionGet();
  assertNoFailures(actionGet);
  return actionGet;
}

代码示例来源:origin: com.strapdata.elasticsearch.test/framework

/**
 * Maybe refresh, force merge, or flush then always make sure there aren't too many in flight async operations.
 */
private void postIndexAsyncActions(String[] indices, List<CountDownLatch> inFlightAsyncOperations, boolean maybeFlush) throws InterruptedException {
  if (rarely()) {
    if (rarely()) {
      client().admin().indices().prepareRefresh(indices).setIndicesOptions(IndicesOptions.lenientExpandOpen()).execute(
        new LatchedActionListener<>(newLatch(inFlightAsyncOperations)));
    } else if (maybeFlush && rarely()) {
      if (randomBoolean()) {
        client().admin().indices().prepareFlush(indices).setIndicesOptions(IndicesOptions.lenientExpandOpen()).execute(
          new LatchedActionListener<>(newLatch(inFlightAsyncOperations)));
      } else {
        client().admin().indices().syncedFlush(syncedFlushRequest(indices).indicesOptions(IndicesOptions.lenientExpandOpen()),
          new LatchedActionListener<>(newLatch(inFlightAsyncOperations)));
      }
    } else if (rarely()) {
      client().admin().indices().prepareForceMerge(indices).setIndicesOptions(IndicesOptions.lenientExpandOpen()).setMaxNumSegments(between(1, 10)).setFlush(maybeFlush && randomBoolean()).execute(
        new LatchedActionListener<>(newLatch(inFlightAsyncOperations)));
    }
  }
  while (inFlightAsyncOperations.size() > MAX_IN_FLIGHT_ASYNC_INDEXES) {
    int waitFor = between(0, inFlightAsyncOperations.size() - 1);
    inFlightAsyncOperations.remove(waitFor).await();
  }
}

相关文章

微信公众号

最新文章

更多

IndicesAdminClient类方法