org.elasticsearch.Version.minimumIndexCompatibilityVersion()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(14.7k)|赞(0)|评价(0)|浏览(86)

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

Version.minimumIndexCompatibilityVersion介绍

[英]Returns the minimum created index version that this version supports. Indices created with lower versions can't be used with this version. This should also be used for file based serialization backwards compatibility ie. on serialization code that is used to read / write file formats like transaction logs, cluster state, and index metadata.
[中]返回此版本支持的最低创建索引版本。使用较低版本创建的索引不能用于此版本。这还应用于基于文件的序列化向后兼容性,即用于读/写事务日志、集群状态和索引元数据等文件格式的序列化代码。

代码示例

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

/**
 * The minimal version of the recipient this custom object can be sent to
 */
default Version getMinimalSupportedVersion() {
  return Version.CURRENT.minimumIndexCompatibilityVersion();
}

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

private void ensureNoPre019ShardState(NodeEnvironment nodeEnv) throws IOException {
  for (Path dataLocation : nodeEnv.nodeDataPaths()) {
    final Path stateLocation = dataLocation.resolve(MetaDataStateFormat.STATE_DIR_NAME);
    if (Files.exists(stateLocation)) {
      try (DirectoryStream<Path> stream = Files.newDirectoryStream(stateLocation, "shards-*")) {
        for (Path stateFile : stream) {
          throw new IllegalStateException("Detected pre 0.19 shard state file please upgrade to a version before "
              + Version.CURRENT.minimumIndexCompatibilityVersion()
              + " first to upgrade state structures - shard state found: [" + stateFile.getParent().toAbsolutePath());
        }
      }
    }
  }
}

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

/**
 * Throws an IAE if a pre 0.19 state is detected
 */
private void ensureNoPre019State() throws IOException {
  for (Path dataLocation : nodeEnv.nodeDataPaths()) {
    final Path stateLocation = dataLocation.resolve(MetaDataStateFormat.STATE_DIR_NAME);
    if (!Files.exists(stateLocation)) {
      continue;
    }
    try (DirectoryStream<Path> stream = Files.newDirectoryStream(stateLocation)) {
      for (Path stateFile : stream) {
        if (logger.isTraceEnabled()) {
          logger.trace("[upgrade]: processing [{}]", stateFile.getFileName());
        }
        final String name = stateFile.getFileName().toString();
        if (name.startsWith("metadata-")) {
          throw new IllegalStateException("Detected pre 0.19 metadata file please upgrade to a version before "
            + Version.CURRENT.minimumIndexCompatibilityVersion()
            + " first to upgrade state structures - metadata found: [" + stateFile.getParent().toAbsolutePath());
        }
      }
    }
  }
}

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

maxVersion = org.elasticsearch.Version.CURRENT.minimumIndexCompatibilityVersion().luceneVersion;

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

/**
 * The minimal version of the recipient this custom object can be sent to
 */
default Version getMinimalSupportedVersion() {
  return Version.CURRENT.minimumIndexCompatibilityVersion();
}

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

/**
 * The minimal version of the recipient this custom object can be sent to
 */
default Version getMinimalSupportedVersion() {
  return Version.CURRENT.minimumIndexCompatibilityVersion();
}

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

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
  builder.startObject();
  builder.field("name", nodeName);
  builder.field("cluster_name", clusterName.value());
  builder.field("cluster_uuid", clusterUuid);
  builder.startObject("version")
    .field("number", version.toString())
    .field("build_flavor", build.flavor().displayName())
    .field("build_type", build.type().displayName())
    .field("build_hash", build.shortHash())
    .field("build_date", build.date())
    .field("build_snapshot", build.isSnapshot())
    .field("lucene_version", version.luceneVersion.toString())
    .field("minimum_wire_compatibility_version", version.minimumCompatibilityVersion().toString())
    .field("minimum_index_compatibility_version", version.minimumIndexCompatibilityVersion().toString())
    .endObject();
  builder.field("tagline", "You Know, for Search");
  builder.endObject();
  return builder;
}

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

for (IndexMetaData indexMetaData : metaData) {
  IndexMetaData newMetaData = metaDataIndexUpgradeService.upgradeIndexMetaData(indexMetaData,
    Version.CURRENT.minimumIndexCompatibilityVersion());
  changed |= indexMetaData != newMetaData;
  upgradedMetaData.put(newMetaData, false);

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

RoutingTable.Builder routingTableBuilder = RoutingTable.builder(currentState.routingTable());
final Version minIndexCompatibilityVersion = currentState.getNodes().getMaxNodeVersion()
  .minimumIndexCompatibilityVersion();
boolean importNeeded = false;
StringBuilder sb = new StringBuilder();

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

private void ensureNoPre019ShardState(NodeEnvironment nodeEnv) throws IOException {
  for (Path dataLocation : nodeEnv.nodeDataPaths()) {
    final Path stateLocation = dataLocation.resolve(MetaDataStateFormat.STATE_DIR_NAME);
    if (Files.exists(stateLocation)) {
      try (DirectoryStream<Path> stream = Files.newDirectoryStream(stateLocation, "shards-*")) {
        for (Path stateFile : stream) {
          throw new IllegalStateException("Detected pre 0.19 shard state file please upgrade to a version before "
              + Version.CURRENT.minimumIndexCompatibilityVersion()
              + " first to upgrade state structures - shard state found: [" + stateFile.getParent().toAbsolutePath());
        }
      }
    }
  }
}

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

private void ensureNoPre019ShardState(NodeEnvironment nodeEnv) throws IOException {
  for (Path dataLocation : nodeEnv.nodeDataPaths()) {
    final Path stateLocation = dataLocation.resolve(MetaDataStateFormat.STATE_DIR_NAME);
    if (Files.exists(stateLocation)) {
      try (DirectoryStream<Path> stream = Files.newDirectoryStream(stateLocation, "shards-*")) {
        for (Path stateFile : stream) {
          throw new IllegalStateException("Detected pre 0.19 shard state file please upgrade to a version before "
              + Version.CURRENT.minimumIndexCompatibilityVersion()
              + " first to upgrade state structures - shard state found: [" + stateFile.getParent().toAbsolutePath());
        }
      }
    }
  }
}

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

.blocks(currentState.blocks());
final Version minIndexCompatibilityVersion = currentState.getNodes().getMaxNodeVersion()
  .minimumIndexCompatibilityVersion();
for (IndexMetaData closedMetaData : indicesToOpen) {
  final String indexName = closedMetaData.getIndex().getName();

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

.minimumIndexCompatibilityVersion();
for (Map.Entry<String, String> indexEntry : indices.entrySet()) {
  String index = indexEntry.getValue();

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

/**
 * Throws an IAE if a pre 0.19 state is detected
 */
private void ensureNoPre019State() throws IOException {
  for (Path dataLocation : nodeEnv.nodeDataPaths()) {
    final Path stateLocation = dataLocation.resolve(MetaDataStateFormat.STATE_DIR_NAME);
    if (!Files.exists(stateLocation)) {
      continue;
    }
    try (DirectoryStream<Path> stream = Files.newDirectoryStream(stateLocation)) {
      for (Path stateFile : stream) {
        if (logger.isTraceEnabled()) {
          logger.trace("[upgrade]: processing [{}]", stateFile.getFileName());
        }
        final String name = stateFile.getFileName().toString();
        if (name.startsWith("metadata-")) {
          throw new IllegalStateException("Detected pre 0.19 metadata file please upgrade to a version before "
            + Version.CURRENT.minimumIndexCompatibilityVersion()
            + " first to upgrade state structures - metadata found: [" + stateFile.getParent().toAbsolutePath());
        }
      }
    }
  }
}

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

/**
 * 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.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
  builder.startObject();
  builder.field("name", nodeName);
  builder.field("cluster_name", clusterName.value());
  builder.field("cluster_uuid", clusterUuid);
  builder.startObject("version")
    .field("number", version.toString())
    .field("build_flavor", build.flavor().displayName())
    .field("build_type", build.type().displayName())
    .field("build_hash", build.shortHash())
    .field("build_date", build.date())
    .field("build_snapshot", build.isSnapshot())
    .field("lucene_version", version.luceneVersion.toString())
    .field("minimum_wire_compatibility_version", version.minimumCompatibilityVersion().toString())
    .field("minimum_index_compatibility_version", version.minimumIndexCompatibilityVersion().toString())
    .endObject();
  builder.field("tagline", "You Know, for Search");
  builder.endObject();
  return builder;
}

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

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
  builder.startObject();
  builder.field("name", nodeName);
  builder.field("cluster_name", clusterName.value());
  builder.field("cluster_uuid", clusterUuid);
  builder.startObject("version")
    .field("number", version.toString())
    .field("build_flavor", build.flavor().displayName())
    .field("build_type", build.type().displayName())
    .field("build_hash", build.shortHash())
    .field("build_date", build.date())
    .field("build_snapshot", build.isSnapshot())
    .field("lucene_version", version.luceneVersion.toString())
    .field("minimum_wire_compatibility_version", version.minimumCompatibilityVersion().toString())
    .field("minimum_index_compatibility_version", version.minimumIndexCompatibilityVersion().toString())
    .endObject();
  builder.field("tagline", "You Know, for Search");
  builder.endObject();
  return builder;
}

相关文章