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

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

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

IndexMetaData.getCreationVersion介绍

[英]Return the Version on which this index has been created. This information is typically useful for backward compatibility.
[中]返回创建此索引的版本。此信息对于向后兼容性通常很有用。

代码示例

代码示例来源:origin: floragunncom/search-guard

private static boolean clusterHas5xIndices(ClusterState state) {
    final Iterator<IndexMetaData> indices = state.metaData().indices().valuesIt();
    for(;indices.hasNext();) {
      final IndexMetaData indexMetaData = indices.next();
      if(indexMetaData.getCreationVersion().before(Version.V_6_0_0_alpha1)) {
        return true;
      }
    }
    return false;
  }
}

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

ShardSplittingQuery(IndexMetaData indexMetaData, int shardId, boolean hasNested) {
  if (indexMetaData.getCreationVersion().before(Version.V_6_0_0_rc2)) {
    throw new IllegalArgumentException("Splitting query can only be executed on an index created with version "
      + Version.V_6_0_0_rc2 + " or higher");
  }
  this.indexMetaData = indexMetaData;
  this.shardId = shardId;
  this.nestedParentBitSetProducer =  hasNested ? newParentDocBitSetProducer(indexMetaData.getCreationVersion()) : null;
}
@Override

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

private static boolean isSupportedVersion(IndexMetaData indexMetaData, Version minimumIndexCompatibilityVersion) {
  return indexMetaData.getCreationVersion().onOrAfter(minimumIndexCompatibilityVersion);
}

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

/**
 * Ensures that all indices are compatible with the given node version. This will ensure that all indices in the given metadata
 * will not be created with a newer version of elasticsearch as well as that all indices are newer or equal to the minimum index
 * compatibility version.
 * @see Version#minimumIndexCompatibilityVersion()
 * @throws IllegalStateException if any index is incompatible with the given version
 */
static void ensureIndexCompatibility(final Version nodeVersion, MetaData metaData) {
  Version supportedIndexVersion = nodeVersion.minimumIndexCompatibilityVersion();
  // we ensure that all indices in the cluster we join are compatible with us no matter if they are
  // closed or not we can't read mappings of these indices so we need to reject the join...
  for (IndexMetaData idxMetaData : metaData) {
    if (idxMetaData.getCreationVersion().after(nodeVersion)) {
      throw new IllegalStateException("index " + idxMetaData.getIndex() + " version not supported: "
        + idxMetaData.getCreationVersion() + " the node version is: " + nodeVersion);
    }
    if (idxMetaData.getCreationVersion().before(supportedIndexVersion)) {
      throw new IllegalStateException("index " + idxMetaData.getIndex() + " version not supported: "
        + idxMetaData.getCreationVersion() + " minimum compatible index version is: " + supportedIndexVersion);
    }
  }
}

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

/**
 * Elasticsearch v6.0 no longer supports indices created pre v5.0. All indices
 * that were created before Elasticsearch v5.0 should be re-indexed in Elasticsearch 5.x
 * before they can be opened by this version of elasticsearch.
 */
private void checkSupportedVersion(IndexMetaData indexMetaData, Version minimumIndexCompatibilityVersion) {
  if (indexMetaData.getState() == IndexMetaData.State.OPEN && isSupportedVersion(indexMetaData,
    minimumIndexCompatibilityVersion) == false) {
    throw new IllegalStateException("The index [" + indexMetaData.getIndex() + "] was created with version ["
      + indexMetaData.getCreationVersion() + "] but the minimum compatible version is ["
      + minimumIndexCompatibilityVersion + "]. It should be re-indexed in Elasticsearch " + minimumIndexCompatibilityVersion.major
      + ".x before upgrading to " + Version.CURRENT + ".");
  }
}

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

final boolean hasNested = indexShard.mapperService().hasNested();
final boolean isSplit = sourceMetaData.getNumberOfShards() < indexShard.indexSettings().getNumberOfShards();
assert isSplit == false || sourceMetaData.getCreationVersion().onOrAfter(Version.V_6_0_0_alpha1) : "for split we require a " +
  "single type but the index is created before 6.0.0";
return executeRecovery(indexShard, () -> {

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

@Override
  public ClusterState execute(ClusterState currentState) {
    MetaData.Builder metaDataBuilder = MetaData.builder(currentState.metaData());
    for (Map.Entry<String, Tuple<Version, String>> entry : request.versions().entrySet()) {
      String index = entry.getKey();
      IndexMetaData indexMetaData = metaDataBuilder.get(index);
      if (indexMetaData != null) {
        if (Version.CURRENT.equals(indexMetaData.getCreationVersion()) == false) {
          // no reason to pollute the settings, we didn't really upgrade anything
          metaDataBuilder.put(
              IndexMetaData
                  .builder(indexMetaData)
                  .settings(
                      Settings
                          .builder()
                          .put(indexMetaData.getSettings())
                          .put(IndexMetaData.SETTING_VERSION_UPGRADED, entry.getValue().v1()))
                  .settingsVersion(1 + indexMetaData.getSettingsVersion()));
        }
      }
    }
    return ClusterState.builder(currentState).metaData(metaDataBuilder).build();
  }
});

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

.put(IndexMetaData.SETTING_INDEX_VERSION_CREATED.getKey(), sourceMetaData.getCreationVersion())
.put(IndexMetaData.SETTING_VERSION_UPGRADED, sourceMetaData.getUpgradedVersion())
.put(builder.build())

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

&& currentIndexMetaData.getCreationVersion().onOrAfter(Version.V_6_5_0)) {
final long currentSettingsVersion = currentIndexMetaData.getSettingsVersion();
final long newSettingsVersion = newIndexMetaData.getSettingsVersion();

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

StringBuilder sb = new StringBuilder();
for (IndexMetaData indexMetaData : request.indices) {
  if (indexMetaData.getCreationVersion().before(minIndexCompatibilityVersion)) {
    logger.warn("ignoring dangled index [{}] on node [{}]" +
      " since it's created version [{}] is not supported by at least one node in the cluster minVersion [{}]",
      indexMetaData.getIndex(), request.fromNode, indexMetaData.getCreationVersion(),
      minIndexCompatibilityVersion);
    continue;

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

if (Assertions.ENABLED
    && currentIndexMetaData != null
    && currentIndexMetaData.getCreationVersion().onOrAfter(Version.V_6_5_0)) {
  if (currentIndexMetaData.getMappingVersion() == newIndexMetaData.getMappingVersion()) {

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

final IndexMetaData indexMetaData = metaData.index(concreteIndex);
MappingMetaData mappingMd = indexMetaData.mappingOrDefault(indexRequest.type());
Version indexCreated = indexMetaData.getCreationVersion();
indexRequest.resolveRouting(metaData);
indexRequest.process(indexCreated, mappingMd, concreteIndex.getName());

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

ShardSplittingQuery(IndexMetaData indexMetaData, int shardId, boolean hasNested) {
  if (indexMetaData.getCreationVersion().before(Version.V_6_0_0_rc2)) {
    throw new IllegalArgumentException("Splitting query can only be executed on an index created with version "
      + Version.V_6_0_0_rc2 + " or higher");
  }
  this.indexMetaData = indexMetaData;
  this.shardId = shardId;
  this.nestedParentBitSetProducer =  hasNested ? newParentDocBitSetProducer(indexMetaData.getCreationVersion()) : null;
}
@Override

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

ShardSplittingQuery(IndexMetaData indexMetaData, int shardId, boolean hasNested) {
  if (indexMetaData.getCreationVersion().before(Version.V_6_0_0_rc2)) {
    throw new IllegalArgumentException("Splitting query can only be executed on an index created with version "
      + Version.V_6_0_0_rc2 + " or higher");
  }
  this.indexMetaData = indexMetaData;
  this.shardId = shardId;
  this.nestedParentBitSetProducer =  hasNested ? newParentDocBitSetProducer(indexMetaData.getCreationVersion()) : null;
}
@Override

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

private static boolean isSupportedVersion(IndexMetaData indexMetaData, Version minimumIndexCompatibilityVersion) {
  return indexMetaData.getCreationVersion().onOrAfter(minimumIndexCompatibilityVersion);
}

代码示例来源:origin: com.floragunn/search-guard-6

private static boolean clusterHas5xIndices(ClusterState state) {
    final Iterator<IndexMetaData> indices = state.metaData().indices().valuesIt();
    for(;indices.hasNext();) {
      final IndexMetaData indexMetaData = indices.next();
      if(indexMetaData.getCreationVersion().before(Version.V_6_0_0_alpha1)) {
        return true;
      }
    }
    return false;
  }
}

代码示例来源: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: harbby/presto-connectors

private static boolean isSupportedVersion(IndexMetaData indexMetaData) {
  if (indexMetaData.getCreationVersion().onOrAfter(Version.V_0_90_0_Beta1)) {
    // The index was created with elasticsearch that was using Lucene 4.0
    return true;
  }
  if (indexMetaData.getMinimumCompatibleVersion() != null &&
      indexMetaData.getMinimumCompatibleVersion().onOrAfter(org.apache.lucene.util.Version.LUCENE_4_0_0)) {
    //The index was upgraded we can work with it
    return true;
  }
  return false;
}

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

IndexMetaData metaData = context.getPrimary().indexSettings().getIndexMetaData();
MappingMetaData mappingMd = metaData.mappingOrDefault(indexRequest.type());
indexRequest.process(metaData.getCreationVersion(), mappingMd, updateRequest.concreteIndex());
context.setRequestToExecute(indexRequest);
break;

相关文章

微信公众号

最新文章

更多

IndexMetaData类方法