org.elasticsearch.Version类的使用及代码示例

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

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

Version介绍

暂无

代码示例

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

/**
 * BWC serialization for nested {@link InnerHitBuilder}.
 * Should only be used to send nested inner hits to nodes pre 5.5.
 */
protected void writeToNestedBWC(StreamOutput out, QueryBuilder query, String nestedPath) throws IOException {
  assert out.getVersion().before(Version.V_5_5_0) :
    "invalid output version, must be < " + Version.V_5_5_0.toString();
  writeToBWC(out, query, nestedPath, null);
}

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

FailedShardEntry(StreamInput in) throws IOException {
  super(in);
  shardId = ShardId.readShardId(in);
  allocationId = in.readString();
  primaryTerm = in.readVLong();
  message = in.readString();
  failure = in.readException();
  if (in.getVersion().onOrAfter(Version.V_6_3_0)) {
    markAsStale = in.readBoolean();
  } else {
    markAsStale = true;
  }
}

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

/**
 * Returns <code>true</code> iff both version are compatible. Otherwise <code>false</code>
 */
public boolean isCompatible(Version version) {
  boolean compatible = onOrAfter(version.minimumCompatibilityVersion())
    && version.onOrAfter(minimumCompatibilityVersion());
  assert compatible == false || Math.max(major, version.major) - Math.min(major, version.major) <= 1;
  return compatible;
}

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

private static void issueWarnings(Client tc) {
    NodesInfoResponse nir = tc.admin().cluster().nodesInfo(new NodesInfoRequest()).actionGet();
    Version maxVersion = nir.getNodes().stream().max((n1,n2) -> n1.getVersion().compareTo(n2.getVersion())).get().getVersion();
    Version minVersion = nir.getNodes().stream().min((n1,n2) -> n1.getVersion().compareTo(n2.getVersion())).get().getVersion();
    
    if(!maxVersion.equals(minVersion)) {
      System.out.println("WARNING: Your cluster consists of different node versions. It is not recommended to run sgadmin against a mixed cluster. This may fail.");
      System.out.println("         Minimum node version is "+minVersion.toString());
      System.out.println("         Maximum node version is "+maxVersion.toString());
    } else {
      System.out.println("Elasticsearch Version: "+minVersion.toString());
    }
    
    if(nir.getNodes().size() > 0) {
      List<PluginInfo> pluginInfos = nir.getNodes().get(0).getPlugins().getPluginInfos();
      String sgVersion = pluginInfos.stream().filter(p->p.getClassname().equals("com.floragunn.searchguard.SearchGuardPlugin")).map(p->p.getVersion()).findFirst().orElse("<unknown>");
      System.out.println("Search Guard Version: "+sgVersion);
    }
  }
}

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

private static boolean supportsAbortedFlag(Version version) {
  // The "aborted" flag was added for 5.5.3 and 5.6.0, but was not in 6.0.0-beta2
  return version.after(Version.V_6_0_0_beta2) || (version.major == 5 && version.onOrAfter(Version.V_5_5_3));
}

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

/**
 * 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.
 */
public Version minimumIndexCompatibilityVersion() {
  final int bwcMajor;
  if (major == 5) {
    bwcMajor = 2; // we jumped from 2 to 5
  } else {
    bwcMajor = major - 1;
  }
  final int bwcMinor = 0;
  return Version.min(this, fromId(bwcMajor * 1000000 + bwcMinor * 10000 + 99));
}

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

public MapperService(IndexSettings indexSettings, IndexAnalyzers indexAnalyzers, NamedXContentRegistry xContentRegistry,
           SimilarityService similarityService, MapperRegistry mapperRegistry,
           Supplier<QueryShardContext> queryShardContextSupplier) {
  super(indexSettings);
  this.indexAnalyzers = indexAnalyzers;
  this.fieldTypes = new FieldTypeLookup();
  this.documentParser = new DocumentMapperParser(indexSettings, this, indexAnalyzers, xContentRegistry, similarityService,
      mapperRegistry, queryShardContextSupplier);
  this.indexAnalyzer = new MapperAnalyzerWrapper(indexAnalyzers.getDefaultIndexAnalyzer(), p -> p.indexAnalyzer());
  this.searchAnalyzer = new MapperAnalyzerWrapper(indexAnalyzers.getDefaultSearchAnalyzer(), p -> p.searchAnalyzer());
  this.searchQuoteAnalyzer = new MapperAnalyzerWrapper(indexAnalyzers.getDefaultSearchQuoteAnalyzer(), p -> p.searchQuoteAnalyzer());
  this.mapperRegistry = mapperRegistry;
  if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_6_0_0_rc1)) {
    if (INDEX_MAPPER_DYNAMIC_SETTING.exists(indexSettings.getSettings())) {
      DEPRECATION_LOGGER.deprecated("Setting " + INDEX_MAPPER_DYNAMIC_SETTING.getKey()
        + " is deprecated since indices may not have more than one type anymore.");
    }
    this.dynamic = INDEX_MAPPER_DYNAMIC_DEFAULT;
  } else {
    this.dynamic = this.indexSettings.getValue(INDEX_MAPPER_DYNAMIC_SETTING);
  }
  defaultMappingSource = "{\"_default_\":{}}";
  if (logger.isTraceEnabled()) {
    logger.trace("using dynamic[{}], default mapping source[{}]", dynamic, defaultMappingSource);
  } else if (logger.isDebugEnabled()) {
    logger.debug("using dynamic[{}]", dynamic);
  }
}

代码示例来源:origin: dadoonet/fscrawler

public void createIndices() throws Exception {
  String elasticsearchVersion;
  Path jobMappingDir = config.resolve(settings.getName()).resolve("_mappings");
  // Let's read the current version of elasticsearch cluster
  Version version = client.info(RequestOptions.DEFAULT).getVersion();
  logger.debug("FS crawler connected to an elasticsearch [{}] node.", version.toString());
  elasticsearchVersion = Byte.toString(version.major);
  // If needed, we create the new settings for this files index
  if (!settings.getFs().isAddAsInnerObject() || (!settings.getFs().isJsonSupport() && !settings.getFs().isXmlSupport())) {
    createIndex(jobMappingDir, elasticsearchVersion, INDEX_SETTINGS_FILE, settings.getElasticsearch().getIndex());
  } else {
    createIndex(settings.getElasticsearch().getIndex(), true, null);
  }
  // If needed, we create the new settings for this folder index
  if (settings.getFs().isIndexFolders()) {
    createIndex(jobMappingDir, elasticsearchVersion, INDEX_SETTINGS_FOLDER_FILE, settings.getElasticsearch().getIndexFolder());
  } else {
    createIndex(settings.getElasticsearch().getIndexFolder(), true, null);
  }
}

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

TransportClientNodesService(Settings settings, TransportService transportService,
                  ThreadPool threadPool, TransportClient.HostFailureListener hostFailureListener) {
  this.clusterName = ClusterName.CLUSTER_NAME_SETTING.get(settings);
  this.transportService = transportService;
  this.threadPool = threadPool;
  this.minCompatibilityVersion = Version.CURRENT.minimumCompatibilityVersion();
  this.nodesSamplerInterval = TransportClient.CLIENT_TRANSPORT_NODES_SAMPLER_INTERVAL.get(settings);
  this.pingTimeout = TransportClient.CLIENT_TRANSPORT_PING_TIMEOUT.get(settings).millis();
  this.ignoreClusterName = TransportClient.CLIENT_TRANSPORT_IGNORE_CLUSTER_NAME.get(settings);
  if (logger.isDebugEnabled()) {
    logger.debug("node_sampler_interval[{}]", nodesSamplerInterval);
  }
  if (TransportClient.CLIENT_TRANSPORT_SNIFF.get(settings)) {
    this.nodesSampler = new SniffNodesSampler();
  } else {
    this.nodesSampler = new SimpleNodeSampler();
  }
  this.hostFailureListener = hostFailureListener;
  this.nodesSamplerFuture = threadPool.schedule(nodesSamplerInterval, ThreadPool.Names.GENERIC, new ScheduledNodeSampler());
}

代码示例来源: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, () -> {
  logger.debug("starting recovery from local shards {}", shards);
  try {
    final Directory directory = indexShard.store().directory(); // don't close this directory!!
        shards.stream().mapToLong(LocalShardSnapshot::maxUnsafeAutoIdTimestamp).max().getAsLong();
    addIndices(indexShard.recoveryState().getIndex(), directory, indexSort, sources, maxSeqNo, maxUnsafeAutoIdTimestamp,
      indexShard.indexSettings().getIndexMetaData(), indexShard.shardId().id(), isSplit, hasNested);
    internalRecoverFromStore(indexShard);

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

for (ObjectCursor<DiscoveryNode> cursor : masterAndDataNodes) {
  DiscoveryNode node = cursor.value;
  if (readOnly && node.getVersion().before(Version.V_6_6_0)) {
    continue;
final AtomicInteger counter = new AtomicInteger(nodes.size());
for (final DiscoveryNode node : nodes) {
  if (node.equals(localNode)) {
    try {
      doVerify(repository, verificationToken, localNode);
    } catch (Exception e) {
      logger.warn(() -> new ParameterizedMessage("[{}] failed to verify repository", repository), e);
      errors.add(new VerificationFailure(node.getId(), e));

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

/** Updates the shard snapshot status by sending a {@link UpdateIndexShardSnapshotStatusRequest} to the master node */
void sendSnapshotShardUpdate(final Snapshot snapshot,
               final ShardId shardId,
               final ShardSnapshotStatus status,
               final DiscoveryNode masterNode) {
  try {
    if (masterNode.getVersion().onOrAfter(Version.V_6_1_0)) {
      UpdateIndexShardSnapshotStatusRequest request = new UpdateIndexShardSnapshotStatusRequest(snapshot, shardId, status);
      transportService.sendRequest(transportService.getLocalNode(), UPDATE_SNAPSHOT_STATUS_ACTION_NAME, request, INSTANCE_SAME);
    } else {
      UpdateSnapshotStatusRequestV6 requestV6 = new UpdateSnapshotStatusRequestV6(snapshot, shardId, status);
      transportService.sendRequest(masterNode, UPDATE_SNAPSHOT_STATUS_ACTION_NAME_V6, requestV6, INSTANCE_SAME);
    }
  } catch (Exception e) {
    logger.warn(() -> new ParameterizedMessage("[{}] [{}] failed to update snapshot state", snapshot, status), e);
  }
}

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

&& currentIndexMetaData.getCreationVersion().onOrAfter(Version.V_6_5_0)) {
final long currentSettingsVersion = currentIndexMetaData.getSettingsVersion();
final long newSettingsVersion = newIndexMetaData.getSettingsVersion();
    shard.onSettingsChanged();
  } catch (Exception e) {
    logger.warn(
      () -> new ParameterizedMessage(
        "[{}] failed to notify shard about setting change", shard.shardId().id()), e);

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

for (ShardUpgradeResult result : shardUpgradeResults) {
  successfulShards++;
  String index = result.getShardId().getIndex().getName();
  if (result.primary()) {
    Integer count = successfulPrimaryShards.get(index);
    if (result.upgradeVersion().after(versionTuple.v1())) {
      version = result.upgradeVersion();
    updatedVersions.put(index, new Tuple<>(versionEntry.getValue().v1(), versionEntry.getValue().v2().toString()));
  } else {
    logger.warn("Not updating settings for the index [{}] because upgraded of some primary shards failed - " +
        "expected[{}], received[{}]", index, expectedPrimaryCount, primaryCount == null ? 0 : primaryCount);

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

StreamInput streamInput = message.streamInput();
try {
  final long requestId = streamInput.readLong();
  final byte status = streamInput.readByte();
  final boolean isRequest = TransportStatus.isRequest(status);
  final String type = isRequest ? "request" : "response";
  final String version = Version.fromId(streamInput.readInt()).toString();
  sb.append(" [length: ").append(messageLengthWithHeader);
  sb.append(", request id: ").append(requestId);
    if (streamInput.getVersion().onOrAfter(Version.V_6_3_0)) {
      streamInput.readStringArray();

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

@Override
  public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    out.writeLong(recoveryId);
    shardId.writeTo(out);
    out.writeVInt(totalTranslogOps);
    if (out.getVersion().before(Version.V_6_0_0_alpha1)) {
      out.writeLong(IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP); // maxUnsafeAutoIdTimestamp
    }
    if (out.getVersion().onOrAfter(Version.V_6_2_0)) {
      out.writeBoolean(fileBasedRecovery);
    }
  }
}

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

RecoveryPrepareForTranslogOperationsRequest(StreamInput in) throws IOException {
  super.readFrom(in);
  recoveryId = in.readLong();
  shardId = ShardId.readShardId(in);
  totalTranslogOps = in.readVInt();
  if (in.getVersion().before(Version.V_6_0_0_alpha1)) {
    in.readLong(); // maxUnsafeAutoIdTimestamp
  }
  if (in.getVersion().onOrAfter(Version.V_6_2_0)) {
    fileBasedRecovery = in.readBoolean();
  } else {
    fileBasedRecovery = true;
  }
}

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

@Override
public void readFrom(StreamInput in) throws IOException {
  super.readFrom(in);
  recoveryId = in.readLong();
  shardId = ShardId.readShardId(in);
  targetAllocationId = in.readString();
  sourceNode = new DiscoveryNode(in);
  targetNode = new DiscoveryNode(in);
  metadataSnapshot = new Store.MetadataSnapshot(in);
  primaryRelocation = in.readBoolean();
  if (in.getVersion().onOrAfter(Version.V_6_0_0_alpha1)) {
    startingSeqNo = in.readLong();
  } else {
    startingSeqNo = SequenceNumbers.UNASSIGNED_SEQ_NO;
  }
}

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

@Override
public void writeTo(StreamOutput out) throws IOException {
  super.writeTo(out);
  shardId.writeTo(out);
  out.writeString(allocationId);
  out.writeVLong(primaryTerm);
  out.writeString(message);
  out.writeException(failure);
  if (out.getVersion().onOrAfter(Version.V_6_3_0)) {
    out.writeBoolean(markAsStale);
  }
}

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

@Override
public void readFrom(StreamInput in) throws IOException {
  node = new DiscoveryNode(in);
  if (in.getVersion().before(Version.V_6_0_0_alpha1)) {
    // legacy version
    in.readLong();
  }
  allocationId = in.readOptionalString();
  allocationStatus = AllocationStatus.readFrom(in);
  if (in.readBoolean()) {
    storeException = in.readException();
  }
}

相关文章