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

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

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

IndexMetaData.selectSplitShard介绍

[英]Returns the source shard ID to split the given target shard off
[中]返回用于分割给定目标碎片的源碎片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

static void validateSplitIndex(ClusterState state, String sourceIndex,
                Set<String> targetIndexMappingsTypes, String targetIndexName,
                Settings targetIndexSettings) {
  IndexMetaData sourceMetaData = validateResize(state, sourceIndex, targetIndexMappingsTypes, targetIndexName, targetIndexSettings);
  IndexMetaData.selectSplitShard(0, sourceMetaData, IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.get(targetIndexSettings));
  if (sourceMetaData.getCreationVersion().before(Version.V_6_0_0_alpha1)) {
    // ensure we have a single type since this would make the splitting code considerably more complex
    // and a 5.x index would not be splittable unless it has been shrunk before so rather opt out of the complexity
    // since in 5.x we don't have a setting to artificially set the number of routing shards
    throw new IllegalStateException("source index created version is too old to apply a split operation");
  }
}

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

Objects.requireNonNull(IndexMetaData.selectSplitShard(i, metaData, numShards));

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

static void validateSplitIndex(ClusterState state, String sourceIndex,
                Set<String> targetIndexMappingsTypes, String targetIndexName,
                Settings targetIndexSettings) {
  IndexMetaData sourceMetaData = validateResize(state, sourceIndex, targetIndexMappingsTypes, targetIndexName, targetIndexSettings);
  IndexMetaData.selectSplitShard(0, sourceMetaData, IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.get(targetIndexSettings));
  if (sourceMetaData.getCreationVersion().before(Version.V_6_0_0_alpha1)) {
    // ensure we have a single type since this would make the splitting code considerably more complex
    // and a 5.x index would not be splittable unless it has been shrunk before so rather opt out of the complexity
    // since in 5.x we don't have a setting to artificially set the number of routing shards
    throw new IllegalStateException("source index created version is too old to apply a split operation");
  }
}

代码示例来源: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.elasticsearch/elasticsearch

ShardId shardId = IndexMetaData.selectSplitShard(shardRouting.id(), sourceIndexMetaData, indexMetaData.getNumberOfShards());
ShardRouting sourceShardRouting = allocation.routingNodes().activePrimary(shardId);
if (sourceShardRouting == null) {

代码示例来源: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: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

static void validateSplitIndex(ClusterState state, String sourceIndex,
                Set<String> targetIndexMappingsTypes, String targetIndexName,
                Settings targetIndexSettings) {
  IndexMetaData sourceMetaData = validateResize(state, sourceIndex, targetIndexMappingsTypes, targetIndexName, targetIndexSettings);
  IndexMetaData.selectSplitShard(0, sourceMetaData, IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.get(targetIndexSettings));
  if (sourceMetaData.getCreationVersion().before(Version.V_6_0_0_alpha1)) {
    // ensure we have a single type since this would make the splitting code considerably more complex
    // and a 5.x index would not be splittable unless it has been shrunk before so rather opt out of the complexity
    // since in 5.x we don't have a setting to artificially set the number of routing shards
    throw new IllegalStateException("source index created version is too old to apply a split operation");
  }
}

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

Objects.requireNonNull(IndexMetaData.selectSplitShard(i, metaData, numShards));

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

Objects.requireNonNull(IndexMetaData.selectSplitShard(i, metaData, numShards));

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

ShardId shardId = IndexMetaData.selectSplitShard(shardRouting.id(), sourceIndexMetaData, indexMetaData.getNumberOfShards());
ShardRouting sourceShardRouting = allocation.routingNodes().activePrimary(shardId);
if (sourceShardRouting == null) {

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

ShardId shardId = IndexMetaData.selectSplitShard(shardRouting.id(), sourceIndexMetaData, indexMetaData.getNumberOfShards());
ShardRouting sourceShardRouting = allocation.routingNodes().activePrimary(shardId);
if (sourceShardRouting == null) {

相关文章

微信公众号

最新文章

更多

IndexMetaData类方法