@Override public Version getMinimalSupportedVersion() { return Version.CURRENT.minimumCompatibilityVersion(); }
@Override public Version getMinimalSupportedVersion() { return Version.CURRENT.minimumCompatibilityVersion(); }
@Override public Version getMinimalSupportedVersion() { return Version.CURRENT.minimumCompatibilityVersion(); }
@Override public Version getMinimalSupportedVersion() { return Version.CURRENT.minimumCompatibilityVersion(); }
@Override public Version getMinimalSupportedVersion() { return Version.CURRENT.minimumCompatibilityVersion(); }
@Override public Version getMinimalSupportedVersion() { return Version.CURRENT.minimumCompatibilityVersion(); }
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 + "]"); } }
/** * 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; }
@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); } } }
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()); } }
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)); }
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()); }
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"; } } }
/** * The minimal version of the recipient this custom object can be sent to */ default Version getMinimalSupportedVersion() { return Version.CURRENT.minimumCompatibilityVersion(); } }
@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; }
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 + "]"); } }
/** * 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; }
/** * 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; }
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); }
@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); }