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

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

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

Version.minimumCompatibilityVersion介绍

[英]Returns the minimum compatible version based on the current version. Ie a node needs to have at least the return version in order to communicate with a node running the current version. The returned version is in most of the cases the smallest major version release unless the current version is a beta or RC release then the version itself is returned.
[中]返回基于当前版本的最低兼容版本。Ie节点需要至少有返回版本,才能与运行当前版本的节点通信。在大多数情况下,返回的版本是最小的主要版本,除非当前版本是beta版或RC版,否则返回的版本本身。

代码示例

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

@Override
public Version getMinimalSupportedVersion() {
  return Version.CURRENT.minimumCompatibilityVersion();
}

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

@Override
public Version getMinimalSupportedVersion() {
  return Version.CURRENT.minimumCompatibilityVersion();
}

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

@Override
public Version getMinimalSupportedVersion() {
  return Version.CURRENT.minimumCompatibilityVersion();
}

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

@Override
public Version getMinimalSupportedVersion() {
  return Version.CURRENT.minimumCompatibilityVersion();
}

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

@Override
public Version getMinimalSupportedVersion() {
  return Version.CURRENT.minimumCompatibilityVersion();
}

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

@Override
public Version getMinimalSupportedVersion() {
  return Version.CURRENT.minimumCompatibilityVersion();
}

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

static void ensureVersionCompatibility(Version version, Version currentVersion, boolean isHandshake) {
  // for handshakes we are compatible with N-2 since otherwise we can't figure out our initial version
  // since we are compatible with N-1 and N+1 so we always send our minCompatVersion as the initial version in the
  // handshake. This looks odd but it's required to establish the connection correctly we check for real compatibility
  // once the connection is established
  final Version compatibilityVersion = isHandshake ? currentVersion.minimumCompatibilityVersion() : currentVersion;
  if (version.isCompatible(compatibilityVersion) == false) {
    final Version minCompatibilityVersion = isHandshake ? compatibilityVersion : compatibilityVersion.minimumCompatibilityVersion();
    String msg = "Received " + (isHandshake ? "handshake " : "") + "message from unsupported version: [";
    throw new IllegalStateException(msg + version + "] minimal compatible version is: [" + minCompatibilityVersion + "]");
  }
}

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

@Override
public void handleResponse(HandshakeResponse response) {
  if (isDone.compareAndSet(false, true)) {
    Version version = response.responseVersion;
    if (currentVersion.isCompatible(version) == false) {
      listener.onFailure(new IllegalStateException("Received message from unsupported version: [" + version
        + "] minimal compatible version is: [" + currentVersion.minimumCompatibilityVersion() + "]"));
    } else {
      listener.onResponse(version);
    }
  }
}

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

static DiscoveryNode buildSeedNode(String clusterName, String address, boolean proxyMode) {
  if (proxyMode) {
    TransportAddress transportAddress = new TransportAddress(TransportAddress.META_ADDRESS, 0);
    String hostName = address.substring(0, indexOfPortSeparator(address));
    return new DiscoveryNode("", clusterName + "#" + address, UUIDs.randomBase64UUID(), hostName, address,
        transportAddress, Collections.singletonMap("server_name", hostName), EnumSet.allOf(DiscoveryNode.Role.class),
        Version.CURRENT.minimumCompatibilityVersion());
  } else {
    TransportAddress transportAddress = new TransportAddress(RemoteClusterAware.parseSeedAddress(address));
    return new DiscoveryNode(clusterName + "#" + transportAddress.toString(),
        transportAddress,
        Version.CURRENT.minimumCompatibilityVersion());
  }
}

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

protected void sendPings(final TimeValue timeout, final PingingRound pingingRound) {
  final ClusterState lastState = contextProvider.clusterState();
  final UnicastPingRequest pingRequest = new UnicastPingRequest(pingingRound.id(), timeout, createPingResponse(lastState));
  List<TransportAddress> temporalAddresses = temporalResponses.stream().map(pingResponse -> {
    assert clusterName.equals(pingResponse.clusterName()) :
      "got a ping request from a different cluster. expected " + clusterName + " got " + pingResponse.clusterName();
    return pingResponse.node().getAddress();
  }).collect(Collectors.toList());
  final Stream<TransportAddress> uniqueAddresses = Stream.concat(pingingRound.getSeedAddresses().stream(),
    temporalAddresses.stream()).distinct();
  // resolve what we can via the latest cluster state
  final Set<DiscoveryNode> nodesToPing = uniqueAddresses
    .map(address -> {
      DiscoveryNode foundNode = lastState.nodes().findByAddress(address);
      if (foundNode != null && transportService.nodeConnected(foundNode)) {
        return foundNode;
      } else {
        return new DiscoveryNode(
          address.toString(),
          address,
          emptyMap(),
          emptySet(),
          Version.CURRENT.minimumCompatibilityVersion());
      }
    }).collect(Collectors.toSet());
  nodesToPing.forEach(node -> sendPingRequestToNode(node, timeout, pingingRound, pingRequest));
}

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

void sendHandshake(long requestId, DiscoveryNode node, TcpChannel channel, TimeValue timeout, ActionListener<Version> listener) {
  numHandshakes.inc();
  final HandshakeResponseHandler handler = new HandshakeResponseHandler(requestId, version, listener);
  pendingHandshakes.put(requestId, handler);
  channel.addCloseListener(ActionListener.wrap(
    () -> handler.handleLocalException(new TransportException("handshake failed because connection reset"))));
  boolean success = false;
  try {
    // for the request we use the minCompatVersion since we don't know what's the version of the node we talk to
    // we also have no payload on the request but the response will contain the actual version of the node we talk
    // to as the payload.
    final Version minCompatVersion = version.minimumCompatibilityVersion();
    handshakeRequestSender.sendRequest(node, channel, requestId, minCompatVersion);
    threadPool.schedule(timeout, ThreadPool.Names.GENERIC,
      () -> handler.handleLocalException(new ConnectTransportException(node, "handshake_timeout[" + timeout + "]")));
    success = true;
  } catch (Exception e) {
    handler.handleLocalException(new ConnectTransportException(node, "failure to send " + HANDSHAKE_ACTION_NAME, e));
  } finally {
    if (success == false) {
      TransportResponseHandler<?> removed = pendingHandshakes.remove(requestId);
      assert removed == null : "Handshake should not be pending if exception was thrown";
    }
  }
}

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

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

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

static void ensureVersionCompatibility(Version version, Version currentVersion, boolean isHandshake) {
  // for handshakes we are compatible with N-2 since otherwise we can't figure out our initial version
  // since we are compatible with N-1 and N+1 so we always send our minCompatVersion as the initial version in the
  // handshake. This looks odd but it's required to establish the connection correctly we check for real compatibility
  // once the connection is established
  final Version compatibilityVersion = isHandshake ? currentVersion.minimumCompatibilityVersion() : currentVersion;
  if (version.isCompatible(compatibilityVersion) == false) {
    final Version minCompatibilityVersion = isHandshake ? compatibilityVersion : compatibilityVersion.minimumCompatibilityVersion();
    String msg = "Received " + (isHandshake ? "handshake " : "") + "message from unsupported version: [";
    throw new IllegalStateException(msg + version + "] minimal compatible version is: [" + minCompatibilityVersion + "]");
  }
}

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

void updateRemoteCluster(
    final String clusterAlias,
    final List<InetSocketAddress> addresses,
    final ActionListener<Void> connectionListener) {
  final List<DiscoveryNode> nodes = addresses.stream().map(address -> {
    final TransportAddress transportAddress = new InetSocketTransportAddress(address);
    final String id = clusterAlias + "#" + transportAddress.toString();
    final Version version = Version.CURRENT.minimumCompatibilityVersion();
    return new DiscoveryNode(id, transportAddress, version);
  }).collect(Collectors.toList());
  updateRemoteClusters(Collections.singletonMap(clusterAlias, nodes), connectionListener);
}

代码示例来源:origin: harbby/presto-connectors

@Inject
public ElectMasterService(Settings settings, Version version) {
  super(settings);
  this.minMasterVersion = version.minimumCompatibilityVersion();
  this.minimumMasterNodes = settings.getAsInt(DISCOVERY_ZEN_MINIMUM_MASTER_NODES, -1);
  logger.debug("using minimum_master_nodes [{}]", minimumMasterNodes);
}

相关文章