org.elasticsearch.cluster.metadata.IndexMetaData.selectShrinkShards()方法的使用及代码示例

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

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

IndexMetaData.selectShrinkShards介绍

[英]Returns the source shard ids to shrink into the given shard id.
[中]返回要收缩为给定碎片id的源碎片id。

代码示例

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

/**
 * Selects the source shards for a local shard recovery. This might either be a split or a shrink operation.
 * @param shardId the target shard ID to select the source shards for
 * @param sourceIndexMetadata the source metadata
 * @param numTargetShards the number of target shards
 */
public static Set<ShardId> selectRecoverFromShards(int shardId, IndexMetaData sourceIndexMetadata, int numTargetShards) {
  if (sourceIndexMetadata.getNumberOfShards() > numTargetShards) {
    return selectShrinkShards(shardId, sourceIndexMetadata, numTargetShards);
  } else if (sourceIndexMetadata.getNumberOfShards() < numTargetShards) {
    return Collections.singleton(selectSplitShard(shardId, sourceIndexMetadata, numTargetShards));
  }
  throw new IllegalArgumentException("can't select recover from shards if both indices have the same number of shards");
}

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

IndexMetaData sourceMetaData = validateResize(state, sourceIndex, targetIndexMappingsTypes, targetIndexName, targetIndexSettings);
assert IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.exists(targetIndexSettings);
IndexMetaData.selectShrinkShards(0, sourceMetaData, IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.get(targetIndexSettings));

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

Set<ShardId> shardIds = IndexMetaData.selectShrinkShards(i, metaData, numShards);
long count = 0;
for (ShardId id : shardIds) {

代码示例来源:origin: apache/servicemix-bundles

/**
 * Selects the source shards for a local shard recovery. This might either be a split or a shrink operation.
 * @param shardId the target shard ID to select the source shards for
 * @param sourceIndexMetadata the source metadata
 * @param numTargetShards the number of target shards
 */
public static Set<ShardId> selectRecoverFromShards(int shardId, IndexMetaData sourceIndexMetadata, int numTargetShards) {
  if (sourceIndexMetadata.getNumberOfShards() > numTargetShards) {
    return selectShrinkShards(shardId, sourceIndexMetadata, numTargetShards);
  } else if (sourceIndexMetadata.getNumberOfShards() < numTargetShards) {
    return Collections.singleton(selectSplitShard(shardId, sourceIndexMetadata, numTargetShards));
  }
  throw new IllegalArgumentException("can't select recover from shards if both indices have the same number of shards");
}

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

/**
 * Selects the source shards for a local shard recovery. This might either be a split or a shrink operation.
 * @param shardId the target shard ID to select the source shards for
 * @param sourceIndexMetadata the source metadata
 * @param numTargetShards the number of target shards
 */
public static Set<ShardId> selectRecoverFromShards(int shardId, IndexMetaData sourceIndexMetadata, int numTargetShards) {
  if (sourceIndexMetadata.getNumberOfShards() > numTargetShards) {
    return selectShrinkShards(shardId, sourceIndexMetadata, numTargetShards);
  } else if (sourceIndexMetadata.getNumberOfShards() < numTargetShards) {
    return Collections.singleton(selectSplitShard(shardId, sourceIndexMetadata, numTargetShards));
  }
  throw new IllegalArgumentException("can't select recover from shards if both indices have the same number of shards");
}

代码示例来源:origin: apache/servicemix-bundles

IndexMetaData sourceMetaData = validateResize(state, sourceIndex, targetIndexMappingsTypes, targetIndexName, targetIndexSettings);
assert IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.exists(targetIndexSettings);
IndexMetaData.selectShrinkShards(0, sourceMetaData, IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.get(targetIndexSettings));

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

IndexMetaData sourceMetaData = validateResize(state, sourceIndex, targetIndexMappingsTypes, targetIndexName, targetIndexSettings);
assert IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.exists(targetIndexSettings);
IndexMetaData.selectShrinkShards(0, sourceMetaData, IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.get(targetIndexSettings));

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

threadPool.generic().execute(() -> {
  try {
    final Set<ShardId> shards = IndexMetaData.selectShrinkShards(shardId().id(), sourceIndexService.getMetaData(),
      +indexMetaData.getNumberOfShards());
    if (recoverFromLocalShards(mappingUpdateConsumer, startedShards.stream()

代码示例来源:origin: apache/servicemix-bundles

Set<ShardId> shardIds = IndexMetaData.selectShrinkShards(i, metaData, numShards);
long count = 0;
for (ShardId id : shardIds) {

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

Set<ShardId> shardIds = IndexMetaData.selectShrinkShards(i, metaData, numShards);
long count = 0;
for (ShardId id : shardIds) {

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

Set<ShardId> shardIds = IndexMetaData.selectShrinkShards(i, metaData, numShards);
long count = 0;
for (ShardId id : shardIds) {

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

/**
   * Returns the expected shard size for the given shard or the default value provided if not enough information are available
   * to estimate the shards size.
   */
  public static long getExpectedShardSize(ShardRouting shard, RoutingAllocation allocation, long defaultValue) {
    final IndexMetaData metaData = allocation.metaData().getIndexSafe(shard.index());
    final ClusterInfo info = allocation.clusterInfo();
    if (metaData.getMergeSourceIndex() != null && shard.active() == false &&
      shard.recoverySource().getType() == RecoverySource.Type.LOCAL_SHARDS) {
      // in the shrink index case we sum up the source index shards since we basically make a copy of the shard in
      // the worst case
      long targetShardSize = 0;
      final Index mergeSourceIndex = metaData.getMergeSourceIndex();
      final IndexMetaData sourceIndexMeta = allocation.metaData().getIndexSafe(mergeSourceIndex);
      final Set<ShardId> shardIds = IndexMetaData.selectShrinkShards(shard.id(), sourceIndexMeta, metaData.getNumberOfShards());
      for (IndexShardRoutingTable shardRoutingTable : allocation.routingTable().index(mergeSourceIndex.getName())) {
        if (shardIds.contains(shardRoutingTable.shardId())) {
          targetShardSize += info.getShardSize(shardRoutingTable.primaryShard(), 0);
        }
      }
      return targetShardSize == 0 ? defaultValue : targetShardSize;
    } else {
      return info.getShardSize(shard, defaultValue);
    }

  }
}

相关文章

微信公众号

最新文章

更多

IndexMetaData类方法