/** ensures that the joining node has a version that's compatible with a given version range */ static void ensureNodesCompatibility(Version joiningNodeVersion, Version minClusterNodeVersion, Version maxClusterNodeVersion) { assert minClusterNodeVersion.onOrBefore(maxClusterNodeVersion) : minClusterNodeVersion + " > " + maxClusterNodeVersion; if (joiningNodeVersion.isCompatible(maxClusterNodeVersion) == false) { throw new IllegalStateException("node version [" + joiningNodeVersion + "] is not supported. " + "The cluster contains nodes with version [" + maxClusterNodeVersion + "], which is incompatible."); } if (joiningNodeVersion.isCompatible(minClusterNodeVersion) == false) { throw new IllegalStateException("node version [" + joiningNodeVersion + "] is not supported." + "The cluster contains nodes with version [" + minClusterNodeVersion + "], which is incompatible."); } }
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 + "]"); } }
@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); } } }
} else if (response.version.isCompatible(localNode.getVersion()) == false) { throw new IllegalStateException("handshake failed, incompatible version [" + response.version + "] - " + node);
/** ensures that the joining node has a version that's compatible with a given version range */ static void ensureNodesCompatibility(Version joiningNodeVersion, Version minClusterNodeVersion, Version maxClusterNodeVersion) { assert minClusterNodeVersion.onOrBefore(maxClusterNodeVersion) : minClusterNodeVersion + " > " + maxClusterNodeVersion; if (joiningNodeVersion.isCompatible(maxClusterNodeVersion) == false) { throw new IllegalStateException("node version [" + joiningNodeVersion + "] is not supported. " + "The cluster contains nodes with version [" + maxClusterNodeVersion + "], which is incompatible."); } if (joiningNodeVersion.isCompatible(minClusterNodeVersion) == false) { throw new IllegalStateException("node version [" + joiningNodeVersion + "] is not supported." + "The cluster contains nodes with version [" + minClusterNodeVersion + "], which is incompatible."); } }
/** returns the first future incompatible version */ public static Version incompatibleFutureVersion(Version version) { final Optional<Version> opt = ALL_VERSIONS.stream().filter(version::before).filter(v -> v.isCompatible(version) == false).findAny(); assert opt.isPresent() : "no future incompatible version for " + version; return opt.get(); }
/** ensures that the joining node has a version that's compatible with a given version range */ static void ensureNodesCompatibility(Version joiningNodeVersion, Version minClusterNodeVersion, Version maxClusterNodeVersion) { assert minClusterNodeVersion.onOrBefore(maxClusterNodeVersion) : minClusterNodeVersion + " > " + maxClusterNodeVersion; if (joiningNodeVersion.isCompatible(maxClusterNodeVersion) == false) { throw new IllegalStateException("node version [" + joiningNodeVersion + "] is not supported. " + "The cluster contains nodes with version [" + maxClusterNodeVersion + "], which is incompatible."); } if (joiningNodeVersion.isCompatible(minClusterNodeVersion) == false) { throw new IllegalStateException("node version [" + joiningNodeVersion + "] is not supported." + "The cluster contains nodes with version [" + minClusterNodeVersion + "], which is incompatible."); } }
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 + "]"); } }
} else { CountDown countDown = new CountDown(seeds.size()); Predicate<DiscoveryNode> nodePredicate = (node) -> Version.CURRENT.isCompatible(node.getVersion())
} else { Version version = versionRef.get(); if (getCurrentVersion().isCompatible(version) == false) { throw new IllegalStateException("Received message from unsupported version: [" + version + "] minimal compatible version is: [" + getCurrentVersion().minimumCompatibilityVersion() + "]");
} else { Version version = versionRef.get(); if (getCurrentVersion().isCompatible(version) == false) { throw new IllegalStateException("Received message from unsupported version: [" + version + "] minimal compatible version is: [" + getCurrentVersion().minimumCompatibilityVersion() + "]");
} else if (response.version.isCompatible(localNode.getVersion()) == false) { throw new IllegalStateException("handshake failed, incompatible version [" + response.version + "] - " + node);
} else if (response.version.isCompatible(localNode.getVersion()) == false) { throw new IllegalStateException("handshake failed, incompatible version [" + response.version + "] - " + node);
key -> boolSetting(key, false, Setting.Property.NodeScope, Setting.Property.Dynamic), REMOTE_CLUSTERS_SEEDS); private static final Predicate<DiscoveryNode> DEFAULT_NODE_PREDICATE = (node) -> Version.CURRENT.isCompatible(node.getVersion()) && (node.isMasterNode() == false || node.isDataNode() || node.isIngestNode());
} else if (response.version.isCompatible(localNode.getVersion()) == false) { throw new IllegalStateException("handshake failed, incompatible version [" + response.version + "] - " + node);