diff --git a/distribution/tools/launchers/src/main/java/org/elasticsearch/tools/launchers/MachineDependentHeap.java b/distribution/tools/launchers/src/main/java/org/elasticsearch/tools/launchers/MachineDependentHeap.java index df025de60fb50..a8a0694deb0df 100644 --- a/distribution/tools/launchers/src/main/java/org/elasticsearch/tools/launchers/MachineDependentHeap.java +++ b/distribution/tools/launchers/src/main/java/org/elasticsearch/tools/launchers/MachineDependentHeap.java @@ -22,7 +22,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.function.Function; import static java.lang.Math.max; @@ -90,15 +89,6 @@ private static List options(int heapSize) { * Parses role information from elasticsearch.yml and determines machine node role. */ static class NodeRoleParser { - private static final Set LEGACY_ROLE_SETTINGS = Set.of( - "node.master", - "node.ingest", - "node.data", - "node.voting_only", - "node.ml", - "node.transform", - "node.remote_cluster_client" - ); @SuppressWarnings("unchecked") public static MachineNodeRole parse(InputStream config) { @@ -113,30 +103,24 @@ public static MachineNodeRole parse(InputStream config) { if (root != null) { Map map = flatten(root, null); - - if (hasLegacySettings(map.keySet())) { - // We don't attempt to auto-determine heap if legacy role settings are used - return MachineNodeRole.UNKNOWN; - } else { - List roles = null; - try { - if (map.containsKey("node.roles")) { - roles = (List) map.get("node.roles"); - } - } catch (ClassCastException ex) { - return MachineNodeRole.UNKNOWN; + List roles = null; + try { + if (map.containsKey("node.roles")) { + roles = (List) map.get("node.roles"); } + } catch (ClassCastException ex) { + return MachineNodeRole.UNKNOWN; + } - if (roles == null || roles.isEmpty()) { - // If roles are missing or empty (coordinating node) assume defaults and consider this a data node - return MachineNodeRole.DATA; - } else if (containsOnly(roles, "master")) { - return MachineNodeRole.MASTER_ONLY; - } else if (roles.contains("ml") && containsOnly(roles, "ml", "remote_cluster_client")) { - return MachineNodeRole.ML_ONLY; - } else { - return MachineNodeRole.DATA; - } + if (roles == null || roles.isEmpty()) { + // If roles are missing or empty (coordinating node) assume defaults and consider this a data node + return MachineNodeRole.DATA; + } else if (containsOnly(roles, "master")) { + return MachineNodeRole.MASTER_ONLY; + } else if (roles.contains("ml") && containsOnly(roles, "ml", "remote_cluster_client")) { + return MachineNodeRole.ML_ONLY; + } else { + return MachineNodeRole.DATA; } } else { // if the config is completely empty, then assume defaults and consider this a data node return MachineNodeRole.DATA; @@ -174,10 +158,6 @@ private static Map flatten(Map config, String pa private static boolean containsOnly(Collection collection, T... items) { return Arrays.asList(items).containsAll(collection); } - - private static boolean hasLegacySettings(Set keys) { - return LEGACY_ROLE_SETTINGS.stream().anyMatch(keys::contains); - } } enum MachineNodeRole { diff --git a/distribution/tools/launchers/src/test/java/org/elasticsearch/tools/launchers/NodeRoleParserTests.java b/distribution/tools/launchers/src/test/java/org/elasticsearch/tools/launchers/NodeRoleParserTests.java index 8e1950fb92f29..b27b2432c3458 100644 --- a/distribution/tools/launchers/src/test/java/org/elasticsearch/tools/launchers/NodeRoleParserTests.java +++ b/distribution/tools/launchers/src/test/java/org/elasticsearch/tools/launchers/NodeRoleParserTests.java @@ -66,20 +66,6 @@ public void testDataNode() throws IOException { assertThat(nodeRole, equalTo(DATA)); } - public void testLegacySettings() throws IOException { - MachineDependentHeap.MachineNodeRole nodeRole = parseConfig(sb -> sb.append("node.ml: true")); - assertThat(nodeRole, equalTo(UNKNOWN)); - - nodeRole = parseConfig(sb -> sb.append("node.master: true")); - assertThat(nodeRole, equalTo(UNKNOWN)); - - nodeRole = parseConfig(sb -> sb.append("node.data: false")); - assertThat(nodeRole, equalTo(UNKNOWN)); - - nodeRole = parseConfig(sb -> sb.append("node.ingest: false")); - assertThat(nodeRole, equalTo(UNKNOWN)); - } - public void testYamlSyntax() throws IOException { MachineDependentHeap.MachineNodeRole nodeRole = parseConfig(sb -> sb.append(""" node: