org.elasticsearch.indices.IndicesService.checkShardLimit()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(4.8k)|赞(0)|评价(0)|浏览(66)

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

IndicesService.checkShardLimit介绍

[英]Checks to see if an operation can be performed without taking the cluster over the cluster-wide shard limit. Adds a deprecation warning or returns an error message as appropriate
[中]检查是否可以在不超过群集范围碎片限制的情况下执行操作。根据需要添加弃用警告或返回错误消息

代码示例

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

/**
 * Checks whether an index can be created without going over the cluster shard limit.
 *
 * @param settings The settings of the index to be created.
 * @param clusterState The current cluster state.
 * @param deprecationLogger The logger to use to emit a deprecation warning, if appropriate.
 * @return If present, an error message to be used to reject index creation. If empty, a signal that this operation may be carried out.
 */
static Optional<String> checkShardLimit(Settings settings, ClusterState clusterState, DeprecationLogger deprecationLogger) {
  int shardsToCreate = IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.get(settings)
    * (1 + IndexMetaData.INDEX_NUMBER_OF_REPLICAS_SETTING.get(settings));
  return IndicesService.checkShardLimit(shardsToCreate, clusterState, deprecationLogger);
}

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

/**
 * Validates whether a list of indices can be opened without going over the cluster shard limit.  Only counts indices which are
 * currently closed and will be opened, ignores indices which are already open.
 *
 * @param currentState The current cluster state.
 * @param indices The indices which are to be opened.
 * @param deprecationLogger The logger to use to emit a deprecation warning, if appropriate.
 * @throws ValidationException If this operation would take the cluster over the limit and enforcement is enabled.
 */
static void validateShardLimit(ClusterState currentState, Index[] indices, DeprecationLogger deprecationLogger) {
  int shardsToOpen = Arrays.stream(indices)
    .filter(index -> currentState.metaData().index(index).getState().equals(IndexMetaData.State.CLOSE))
    .mapToInt(index -> getTotalShardCount(currentState, index))
    .sum();
  Optional<String> error = IndicesService.checkShardLimit(shardsToOpen, currentState, deprecationLogger);
  if (error.isPresent()) {
    ValidationException ex = new ValidationException();
    ex.addValidationError(error.get());
    throw ex;
  }
}

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

.mapToInt(i -> getTotalNewShards(i, currentState, updatedNumberOfReplicas))
  .sum();
Optional<String> error = IndicesService.checkShardLimit(totalNewShards, currentState, deprecationLogger);
if (error.isPresent()) {
  ValidationException ex = new ValidationException();

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

/**
 * Checks whether an index can be created without going over the cluster shard limit.
 *
 * @param settings The settings of the index to be created.
 * @param clusterState The current cluster state.
 * @param deprecationLogger The logger to use to emit a deprecation warning, if appropriate.
 * @return If present, an error message to be used to reject index creation. If empty, a signal that this operation may be carried out.
 */
static Optional<String> checkShardLimit(Settings settings, ClusterState clusterState, DeprecationLogger deprecationLogger) {
  int shardsToCreate = IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.get(settings)
    * (1 + IndexMetaData.INDEX_NUMBER_OF_REPLICAS_SETTING.get(settings));
  return IndicesService.checkShardLimit(shardsToCreate, clusterState, deprecationLogger);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

/**
 * Validates whether a list of indices can be opened without going over the cluster shard limit.  Only counts indices which are
 * currently closed and will be opened, ignores indices which are already open.
 *
 * @param currentState The current cluster state.
 * @param indices The indices which are to be opened.
 * @param deprecationLogger The logger to use to emit a deprecation warning, if appropriate.
 * @throws ValidationException If this operation would take the cluster over the limit and enforcement is enabled.
 */
static void validateShardLimit(ClusterState currentState, Index[] indices, DeprecationLogger deprecationLogger) {
  int shardsToOpen = Arrays.stream(indices)
    .filter(index -> currentState.metaData().index(index).getState().equals(IndexMetaData.State.CLOSE))
    .mapToInt(index -> getTotalShardCount(currentState, index))
    .sum();
  Optional<String> error = IndicesService.checkShardLimit(shardsToOpen, currentState, deprecationLogger);
  if (error.isPresent()) {
    ValidationException ex = new ValidationException();
    ex.addValidationError(error.get());
    throw ex;
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

.mapToInt(i -> getTotalNewShards(i, currentState, updatedNumberOfReplicas))
  .sum();
Optional<String> error = IndicesService.checkShardLimit(totalNewShards, currentState, deprecationLogger);
if (error.isPresent()) {
  ValidationException ex = new ValidationException();

相关文章

微信公众号

最新文章

更多