Add a new node role 'cluster_manager' as the alternative for 'master' role and deprecate 'master' role (#2424)
Add a new node role `cluster_manager`, as the replacement for `master` role, that used in setting `node.roles: [ master ]`. They have got the same functionality, but can NOT be assigned to `node.roles` together. * Add `CLUSTER_MANAGER_ROLE` in `DiscoveryNodeRole` class, and deprecate `MASTER_ROLE` * Remove `MASTER_ROLE` from the `DiscoveryNodeRole.BUILT_IN_ROLES`, and temporarily load the role by the existing method `DiscoveryNode.setAdditionalRoles` * Add a method `validateRole()` in `DiscoveryNodeRole` class, it's used to validate a specific role is compatible with the other roles to be assigned to a node together. * Add deprecation message when assigning `master` role in setting `node.roles` * Replace most `MASTER_ROLE` with `CLUSTER_MANAGER_ROLE` in current unit and integration tests * Add new unit and integration tests to validate `CLUSTER_MANAGER_ROLE` and `MASTER_ROLE` can be treated as the same. More explanation: * New node will have "cluster_manager", "data", and "ingest" roles by default. Which means the default value of setting "node.roles" will be `["cluster_manager","data","ingest"]`, instead of `["master","data","ingest"]` * "cluster_manager" role will be treated as "master" role in the OpenSearch node of previous versions. * "cluster_manager” role and "master" role have got the same abbreviation name: "m" Signed-off-by: Tianli Feng <ftianli@amazon.com>
This commit is contained in:
parent
641350b0b6
commit
ea31483126
|
@ -111,7 +111,7 @@ public final class Allocators {
|
|||
nodeId,
|
||||
new TransportAddress(TransportAddress.META_ADDRESS, portGenerator.incrementAndGet()),
|
||||
attributes,
|
||||
Sets.newHashSet(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.DATA_ROLE),
|
||||
Sets.newHashSet(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.DATA_ROLE),
|
||||
Version.CURRENT
|
||||
);
|
||||
}
|
||||
|
|
|
@ -210,21 +210,21 @@ public class Node {
|
|||
}
|
||||
|
||||
/**
|
||||
* Teturns whether or not the node <strong>could</strong> be elected master.
|
||||
* Returns whether or not the node <strong>could</strong> be elected master.
|
||||
*/
|
||||
public boolean isMasterEligible() {
|
||||
return roles.contains("master");
|
||||
return roles.contains("master") || roles.contains("cluster_manager");
|
||||
}
|
||||
|
||||
/**
|
||||
* Teturns whether or not the node stores data.
|
||||
* Returns whether or not the node stores data.
|
||||
*/
|
||||
public boolean isData() {
|
||||
return roles.contains("data");
|
||||
}
|
||||
|
||||
/**
|
||||
* Teturns whether or not the node runs ingest pipelines.
|
||||
* Returns whether or not the node runs ingest pipelines.
|
||||
*/
|
||||
public boolean isIngest() {
|
||||
return roles.contains("ingest");
|
||||
|
|
|
@ -91,3 +91,22 @@
|
|||
cluster.stats: {}
|
||||
|
||||
- is_true: nodes.packaging_types
|
||||
|
||||
---
|
||||
"get cluster stats nodes count with both master and cluster_manager":
|
||||
- skip:
|
||||
version: " - 1.4.99"
|
||||
reason: "node role cluster_manager is added in 2.0.0"
|
||||
|
||||
- do:
|
||||
cluster.stats: {}
|
||||
|
||||
- set:
|
||||
nodes.count.cluster_manager: cluster_manager_count
|
||||
|
||||
- gte: { nodes.count.total: 1}
|
||||
- match: { nodes.count.cluster_manager: $cluster_manager_count }
|
||||
- match: { nodes.count.master: $cluster_manager_count }
|
||||
- gte: { nodes.count.data: 1}
|
||||
- gte: { nodes.count.ingest: 0}
|
||||
- gte: { nodes.count.coordinating_only: 0}
|
||||
|
|
|
@ -12,14 +12,24 @@ setup:
|
|||
- is_true: cluster_name
|
||||
|
||||
---
|
||||
"node_info role test":
|
||||
"node_info role test - before 2.0.0":
|
||||
- skip:
|
||||
version: " - 7.7.99"
|
||||
version: " - 7.7.99 , 2.0.0 - "
|
||||
reason: "node roles were not sorted before 7.8.0"
|
||||
features: node_selector
|
||||
|
||||
- do:
|
||||
nodes.info: {}
|
||||
node_selector:
|
||||
# Only send request to nodes in <2.0 versions, especially during ':qa:mixed-cluster:v1.x.x#mixedClusterTest'.
|
||||
# Because YAML REST test takes the minimum OpenSearch version in the cluster to apply the filter in 'skip' section,
|
||||
# see OpenSearchClientYamlSuiteTestCase#initAndResetContext() for detail.
|
||||
# During 'mixedClusterTest', the cluster can be mixed with nodes in 1.x and 2.x versions,
|
||||
# so node_selector is required, and only filtering version in 'skip' is not enough.
|
||||
version: "1.0.0 - 1.4.99"
|
||||
|
||||
- set:
|
||||
# Note: It will only stash the first node_id in the api response.
|
||||
nodes._arbitrary_key_: node_id
|
||||
|
||||
- is_true: nodes.$node_id.roles
|
||||
|
@ -29,3 +39,21 @@ setup:
|
|||
- match: { nodes.$node_id.roles.2: "master" }
|
||||
- match: { nodes.$node_id.roles.3: "remote_cluster_client" }
|
||||
|
||||
---
|
||||
"node_info role test":
|
||||
- skip:
|
||||
version: " - 1.4.99"
|
||||
reason: "node role cluster_manager is added in 2.0.0"
|
||||
|
||||
- do:
|
||||
nodes.info: {}
|
||||
|
||||
- set:
|
||||
nodes._arbitrary_key_: node_id
|
||||
|
||||
- is_true: nodes.$node_id.roles
|
||||
# the roles output is sorted
|
||||
- match: { nodes.$node_id.roles.0: "cluster_manager" }
|
||||
- match: { nodes.$node_id.roles.1: "data" }
|
||||
- match: { nodes.$node_id.roles.2: "ingest" }
|
||||
- match: { nodes.$node_id.roles.3: "remote_cluster_client" }
|
||||
|
|
|
@ -85,6 +85,7 @@ public class ClusterStatsIT extends OpenSearchIntegTestCase {
|
|||
Map<String, Integer> expectedCounts = new HashMap<>();
|
||||
expectedCounts.put(DiscoveryNodeRole.DATA_ROLE.roleName(), 1);
|
||||
expectedCounts.put(DiscoveryNodeRole.MASTER_ROLE.roleName(), 1);
|
||||
expectedCounts.put(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE.roleName(), 1);
|
||||
expectedCounts.put(DiscoveryNodeRole.INGEST_ROLE.roleName(), 1);
|
||||
expectedCounts.put(DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE.roleName(), 1);
|
||||
expectedCounts.put(ClusterStatsNodes.Counts.COORDINATING_ONLY, 0);
|
||||
|
@ -106,7 +107,7 @@ public class ClusterStatsIT extends OpenSearchIntegTestCase {
|
|||
roles.add(DiscoveryNodeRole.INGEST_ROLE);
|
||||
}
|
||||
if (isMasterNode) {
|
||||
roles.add(DiscoveryNodeRole.MASTER_ROLE);
|
||||
roles.add(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE);
|
||||
}
|
||||
if (isRemoteClusterClientNode) {
|
||||
roles.add(DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE);
|
||||
|
@ -129,6 +130,7 @@ public class ClusterStatsIT extends OpenSearchIntegTestCase {
|
|||
}
|
||||
if (isMasterNode) {
|
||||
incrementCountForRole(DiscoveryNodeRole.MASTER_ROLE.roleName(), expectedCounts);
|
||||
incrementCountForRole(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE.roleName(), expectedCounts);
|
||||
}
|
||||
if (isRemoteClusterClientNode) {
|
||||
incrementCountForRole(DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE.roleName(), expectedCounts);
|
||||
|
|
|
@ -95,7 +95,7 @@ public class NodeEnvironmentIT extends OpenSearchIntegTestCase {
|
|||
})
|
||||
);
|
||||
if (writeDanglingIndices) {
|
||||
assertThat(ex.getMessage(), startsWith("node does not have the data and master roles but has index metadata"));
|
||||
assertThat(ex.getMessage(), startsWith("node does not have the data and cluster_manager roles but has index metadata"));
|
||||
} else {
|
||||
assertThat(ex.getMessage(), startsWith("node does not have the data role but has shard data"));
|
||||
}
|
||||
|
|
|
@ -223,7 +223,14 @@ public class ClusterStatsNodes implements ToXContentFragment {
|
|||
roles.merge(COORDINATING_ONLY, 1, Integer::sum);
|
||||
} else {
|
||||
for (DiscoveryNodeRole role : nodeInfo.getNode().getRoles()) {
|
||||
roles.merge(role.roleName(), 1, Integer::sum);
|
||||
// TODO: Remove the 'if' condition and only keep the statement in 'else' after removing MASTER_ROLE.
|
||||
// As of 2.0, CLUSTER_MANAGER_ROLE is added, and it should be taken as MASTER_ROLE
|
||||
if (role.isClusterManager()) {
|
||||
roles.merge(DiscoveryNodeRole.MASTER_ROLE.roleName(), 1, Integer::sum);
|
||||
roles.merge(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE.roleName(), 1, Integer::sum);
|
||||
} else {
|
||||
roles.merge(role.roleName(), 1, Integer::sum);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ public class DiscoveryNode implements Writeable, ToXContentFragment {
|
|||
}
|
||||
|
||||
public static boolean isMasterNode(Settings settings) {
|
||||
return hasRole(settings, DiscoveryNodeRole.MASTER_ROLE);
|
||||
return hasRole(settings, DiscoveryNodeRole.MASTER_ROLE) || hasRole(settings, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -343,7 +343,7 @@ public class DiscoveryNode implements Writeable, ToXContentFragment {
|
|||
final LegacyRole legacyRole = in.readEnum(LegacyRole.class);
|
||||
switch (legacyRole) {
|
||||
case MASTER:
|
||||
roles.add(DiscoveryNodeRole.MASTER_ROLE);
|
||||
roles.add(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE);
|
||||
break;
|
||||
case DATA:
|
||||
roles.add(DiscoveryNodeRole.DATA_ROLE);
|
||||
|
@ -390,11 +390,11 @@ public class DiscoveryNode implements Writeable, ToXContentFragment {
|
|||
.collect(Collectors.toList());
|
||||
out.writeVInt(rolesToWrite.size());
|
||||
for (final DiscoveryNodeRole role : rolesToWrite) {
|
||||
if (role == DiscoveryNodeRole.MASTER_ROLE) {
|
||||
if (role.isClusterManager()) {
|
||||
out.writeEnum(LegacyRole.MASTER);
|
||||
} else if (role == DiscoveryNodeRole.DATA_ROLE) {
|
||||
} else if (role.equals(DiscoveryNodeRole.DATA_ROLE)) {
|
||||
out.writeEnum(LegacyRole.DATA);
|
||||
} else if (role == DiscoveryNodeRole.INGEST_ROLE) {
|
||||
} else if (role.equals(DiscoveryNodeRole.INGEST_ROLE)) {
|
||||
out.writeEnum(LegacyRole.INGEST);
|
||||
}
|
||||
}
|
||||
|
@ -456,7 +456,7 @@ public class DiscoveryNode implements Writeable, ToXContentFragment {
|
|||
* Can this node become master or not.
|
||||
*/
|
||||
public boolean isMasterNode() {
|
||||
return roles.contains(DiscoveryNodeRole.MASTER_ROLE);
|
||||
return roles.contains(DiscoveryNodeRole.MASTER_ROLE) || roles.contains(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -591,7 +591,11 @@ public class DiscoveryNode implements Writeable, ToXContentFragment {
|
|||
+ "], roles by name abbreviation ["
|
||||
+ roleNameAbbreviationToPossibleRoles
|
||||
+ "]";
|
||||
roleMap = roleNameToPossibleRoles;
|
||||
// TODO: Remove the Map 'roleNameToPossibleRolesWithMaster' and let 'roleMap = roleNameToPossibleRoles', after removing MASTER_ROLE.
|
||||
// It's used to allow CLUSTER_MANAGER_ROLE that introduced in 2.0, having the same abbreviation name with MASTER_ROLE.
|
||||
final Map<String, DiscoveryNodeRole> roleNameToPossibleRolesWithMaster = new HashMap<>(roleNameToPossibleRoles);
|
||||
roleNameToPossibleRolesWithMaster.put(DiscoveryNodeRole.MASTER_ROLE.roleName(), DiscoveryNodeRole.MASTER_ROLE);
|
||||
roleMap = Collections.unmodifiableMap(roleNameToPossibleRolesWithMaster);
|
||||
}
|
||||
|
||||
public static Set<String> getPossibleRoleNames() {
|
||||
|
@ -599,7 +603,7 @@ public class DiscoveryNode implements Writeable, ToXContentFragment {
|
|||
}
|
||||
|
||||
/**
|
||||
* Enum that holds all the possible roles that that a node can fulfill in a cluster.
|
||||
* Enum that holds all the possible roles that a node can fulfill in a cluster.
|
||||
* Each role has its name and a corresponding abbreviation used by cat apis.
|
||||
*/
|
||||
private enum LegacyRole {
|
||||
|
|
|
@ -34,6 +34,7 @@ package org.opensearch.cluster.node;
|
|||
|
||||
import org.opensearch.LegacyESVersion;
|
||||
import org.opensearch.Version;
|
||||
import org.opensearch.common.logging.DeprecationLogger;
|
||||
import org.opensearch.common.settings.Setting;
|
||||
import org.opensearch.common.settings.Setting.Property;
|
||||
import org.opensearch.common.settings.Settings;
|
||||
|
@ -41,6 +42,8 @@ import org.opensearch.transport.RemoteClusterService;
|
|||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
@ -50,6 +53,10 @@ import java.util.TreeSet;
|
|||
*/
|
||||
public abstract class DiscoveryNodeRole implements Comparable<DiscoveryNodeRole> {
|
||||
|
||||
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DiscoveryNodeRole.class);
|
||||
public static final String MASTER_ROLE_DEPRECATION_MESSAGE =
|
||||
"Assigning [master] role in setting [node.roles] is deprecated. To promote inclusive language, please use [cluster_manager] role instead.";
|
||||
|
||||
private final String roleName;
|
||||
|
||||
/**
|
||||
|
@ -129,6 +136,13 @@ public abstract class DiscoveryNodeRole implements Comparable<DiscoveryNodeRole>
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the role is compatible with the other roles in the list, when assigning the list of roles to a node.
|
||||
* An {@link IllegalArgumentException} is expected to be thrown, if the role can't coexist with the other roles.
|
||||
* @param roles a {@link List} of {@link DiscoveryNodeRole} that a node is going to have
|
||||
*/
|
||||
public void validateRole(List<DiscoveryNodeRole> roles) {};
|
||||
|
||||
@Override
|
||||
public final boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
@ -193,15 +207,60 @@ public abstract class DiscoveryNodeRole implements Comparable<DiscoveryNodeRole>
|
|||
|
||||
/**
|
||||
* Represents the role for a master-eligible node.
|
||||
* @deprecated As of 2.0, because promoting inclusive language, replaced by {@link #CLUSTER_MANAGER_ROLE}
|
||||
*/
|
||||
@Deprecated
|
||||
public static final DiscoveryNodeRole MASTER_ROLE = new DiscoveryNodeRole("master", "m") {
|
||||
|
||||
@Override
|
||||
public Setting<Boolean> legacySetting() {
|
||||
// copy the setting here so we can mark it private in org.opensearch.node.Node
|
||||
// As of 2.0, set the default value to 'false', so that MASTER_ROLE isn't added as a default value of NODE_ROLES_SETTING
|
||||
return Setting.boolSetting("node.master", false, Property.Deprecated, Property.NodeScope);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateRole(List<DiscoveryNodeRole> roles) {
|
||||
deprecationLogger.deprecate("node_role_master", MASTER_ROLE_DEPRECATION_MESSAGE);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents the role for a cluster-manager-eligible node.
|
||||
*/
|
||||
public static final DiscoveryNodeRole CLUSTER_MANAGER_ROLE = new DiscoveryNodeRole("cluster_manager", "m") {
|
||||
|
||||
@Override
|
||||
public Setting<Boolean> legacySetting() {
|
||||
// copy the setting here so we can mark it private in org.opensearch.node.Node
|
||||
return Setting.boolSetting("node.master", true, Property.Deprecated, Property.NodeScope);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DiscoveryNodeRole getCompatibilityRole(Version nodeVersion) {
|
||||
if (nodeVersion.onOrAfter(Version.V_2_0_0)) {
|
||||
return this;
|
||||
} else {
|
||||
return DiscoveryNodeRole.MASTER_ROLE;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateRole(List<DiscoveryNodeRole> roles) {
|
||||
if (roles.contains(DiscoveryNodeRole.MASTER_ROLE)) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format(
|
||||
Locale.ROOT,
|
||||
"The two roles [%s, %s] can not be assigned together to a node. %s",
|
||||
DiscoveryNodeRole.MASTER_ROLE.roleName(),
|
||||
DiscoveryNodeRole.CLUSTER_MANAGER_ROLE.roleName(),
|
||||
MASTER_ROLE_DEPRECATION_MESSAGE
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public static final DiscoveryNodeRole REMOTE_CLUSTER_CLIENT_ROLE = new DiscoveryNodeRole("remote_cluster_client", "r") {
|
||||
|
@ -223,7 +282,7 @@ public abstract class DiscoveryNodeRole implements Comparable<DiscoveryNodeRole>
|
|||
* The built-in node roles.
|
||||
*/
|
||||
public static SortedSet<DiscoveryNodeRole> BUILT_IN_ROLES = Collections.unmodifiableSortedSet(
|
||||
new TreeSet<>(Arrays.asList(DATA_ROLE, INGEST_ROLE, MASTER_ROLE, REMOTE_CLUSTER_CLIENT_ROLE))
|
||||
new TreeSet<>(Arrays.asList(DATA_ROLE, INGEST_ROLE, CLUSTER_MANAGER_ROLE, REMOTE_CLUSTER_CLIENT_ROLE))
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -262,4 +321,13 @@ public abstract class DiscoveryNodeRole implements Comparable<DiscoveryNodeRole>
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the role is {@link #CLUSTER_MANAGER_ROLE} or {@link #MASTER_ROLE}.
|
||||
* @deprecated As of 2.0, because promoting inclusive language. MASTER_ROLE is deprecated.
|
||||
* @return true if the node role is{@link #CLUSTER_MANAGER_ROLE} or {@link #MASTER_ROLE}
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isClusterManager() {
|
||||
return this.equals(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE) || this.equals(DiscoveryNodeRole.MASTER_ROLE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -370,7 +370,7 @@ public class DiscoveryNodes extends AbstractDiffable<DiscoveryNodes> implements
|
|||
* Works by tracking the current set of nodes and applying each node specification in sequence. The set starts out empty and each node
|
||||
* specification may either add or remove nodes. For instance:
|
||||
*
|
||||
* - _local, _master and _all respectively add to the subset the local node, the currently-elected master, and all the nodes
|
||||
* - _local, _cluster_manager (_master) and _all respectively add to the subset the local node, the currently-elected cluster_manager, and all the nodes
|
||||
* - node IDs, names, hostnames and IP addresses all add to the subset any nodes which match
|
||||
* - a wildcard-based pattern of the form "attr*:value*" adds to the subset all nodes with a matching attribute with a matching value
|
||||
* - role:true adds to the subset all nodes with a matching role
|
||||
|
@ -393,7 +393,7 @@ public class DiscoveryNodes extends AbstractDiffable<DiscoveryNodes> implements
|
|||
if (localNodeId != null) {
|
||||
resolvedNodesIds.add(localNodeId);
|
||||
}
|
||||
} else if (nodeId.equals("_master")) {
|
||||
} else if (nodeId.equals("_master") || nodeId.equals("_cluster_manager")) {
|
||||
String masterNodeId = getMasterNodeId();
|
||||
if (masterNodeId != null) {
|
||||
resolvedNodesIds.add(masterNodeId);
|
||||
|
@ -419,7 +419,7 @@ public class DiscoveryNodes extends AbstractDiffable<DiscoveryNodes> implements
|
|||
} else {
|
||||
resolvedNodesIds.removeAll(dataNodes.keys());
|
||||
}
|
||||
} else if (DiscoveryNodeRole.MASTER_ROLE.roleName().equals(matchAttrName)) {
|
||||
} else if (roleNameIsClusterManager(matchAttrName)) {
|
||||
if (Booleans.parseBoolean(matchAttrValue, true)) {
|
||||
resolvedNodesIds.addAll(masterNodes.keys());
|
||||
} else {
|
||||
|
@ -797,4 +797,17 @@ public class DiscoveryNodes extends AbstractDiffable<DiscoveryNodes> implements
|
|||
return masterNodeId != null && masterNodeId.equals(localNodeId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given name of the node role is 'cluster_manger' or 'master'.
|
||||
* The method is added for {@link #resolveNodes} to keep the code clear, when support the both above roles.
|
||||
* @deprecated As of 2.0, because promoting inclusive language. MASTER_ROLE is deprecated.
|
||||
* @param matchAttrName a given String for a name of the node role.
|
||||
* @return true if the given roleName is 'cluster_manger' or 'master'
|
||||
*/
|
||||
@Deprecated
|
||||
private boolean roleNameIsClusterManager(String matchAttrName) {
|
||||
return DiscoveryNodeRole.MASTER_ROLE.roleName().equals(matchAttrName)
|
||||
|| DiscoveryNodeRole.CLUSTER_MANAGER_ROLE.roleName().equals(matchAttrName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1138,7 +1138,7 @@ public final class NodeEnvironment implements Closeable {
|
|||
Locale.ROOT,
|
||||
"node does not have the %s and %s roles but has index metadata: %s. Use 'opensearch-node repurpose' tool to clean up",
|
||||
DiscoveryNodeRole.DATA_ROLE.roleName(),
|
||||
DiscoveryNodeRole.MASTER_ROLE.roleName(),
|
||||
DiscoveryNodeRole.CLUSTER_MANAGER_ROLE.roleName(),
|
||||
indexMetadataPaths
|
||||
);
|
||||
throw new IllegalStateException(message);
|
||||
|
|
|
@ -51,7 +51,11 @@ public class NodeRoleSettings {
|
|||
.filter(role -> role.isEnabledByDefault(settings))
|
||||
.map(DiscoveryNodeRole::roleName)
|
||||
.collect(Collectors.toList()),
|
||||
roles -> {},
|
||||
roles -> {
|
||||
for (DiscoveryNodeRole role : roles) {
|
||||
role.validateRole(roles);
|
||||
}
|
||||
},
|
||||
Property.NodeScope
|
||||
);
|
||||
|
||||
|
|
|
@ -346,8 +346,9 @@ public class RepositoriesService extends AbstractLifecycleComponent implements C
|
|||
});
|
||||
}
|
||||
|
||||
// Note: "voting_only" role has not been implemented yet, so the method always returns false.
|
||||
static boolean isDedicatedVotingOnlyNode(Set<DiscoveryNodeRole> roles) {
|
||||
return roles.contains(DiscoveryNodeRole.MASTER_ROLE)
|
||||
return roles.contains(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE)
|
||||
&& roles.contains(DiscoveryNodeRole.DATA_ROLE) == false
|
||||
&& roles.stream().anyMatch(role -> role.roleName().equals("voting_only"));
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ public class AddVotingConfigExclusionsRequestTests extends OpenSearchTestCase {
|
|||
"local",
|
||||
buildNewFakeTransportAddress(),
|
||||
emptyMap(),
|
||||
singleton(DiscoveryNodeRole.MASTER_ROLE),
|
||||
singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE),
|
||||
Version.CURRENT
|
||||
);
|
||||
final VotingConfigExclusion localNodeExclusion = new VotingConfigExclusion(localNode);
|
||||
|
@ -122,7 +122,7 @@ public class AddVotingConfigExclusionsRequestTests extends OpenSearchTestCase {
|
|||
"other1",
|
||||
buildNewFakeTransportAddress(),
|
||||
emptyMap(),
|
||||
singleton(DiscoveryNodeRole.MASTER_ROLE),
|
||||
singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE),
|
||||
Version.CURRENT
|
||||
);
|
||||
final VotingConfigExclusion otherNode1Exclusion = new VotingConfigExclusion(otherNode1);
|
||||
|
@ -131,7 +131,7 @@ public class AddVotingConfigExclusionsRequestTests extends OpenSearchTestCase {
|
|||
"other2",
|
||||
buildNewFakeTransportAddress(),
|
||||
emptyMap(),
|
||||
singleton(DiscoveryNodeRole.MASTER_ROLE),
|
||||
singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE),
|
||||
Version.CURRENT
|
||||
);
|
||||
final VotingConfigExclusion otherNode2Exclusion = new VotingConfigExclusion(otherNode2);
|
||||
|
@ -238,7 +238,7 @@ public class AddVotingConfigExclusionsRequestTests extends OpenSearchTestCase {
|
|||
"nodeId1",
|
||||
buildNewFakeTransportAddress(),
|
||||
emptyMap(),
|
||||
singleton(DiscoveryNodeRole.MASTER_ROLE),
|
||||
singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE),
|
||||
Version.CURRENT
|
||||
);
|
||||
final VotingConfigExclusion node1Exclusion = new VotingConfigExclusion(node1);
|
||||
|
@ -248,7 +248,7 @@ public class AddVotingConfigExclusionsRequestTests extends OpenSearchTestCase {
|
|||
"nodeId2",
|
||||
buildNewFakeTransportAddress(),
|
||||
emptyMap(),
|
||||
singleton(DiscoveryNodeRole.MASTER_ROLE),
|
||||
singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE),
|
||||
Version.CURRENT
|
||||
);
|
||||
final VotingConfigExclusion node2Exclusion = new VotingConfigExclusion(node2);
|
||||
|
@ -258,7 +258,7 @@ public class AddVotingConfigExclusionsRequestTests extends OpenSearchTestCase {
|
|||
"nodeId3",
|
||||
buildNewFakeTransportAddress(),
|
||||
emptyMap(),
|
||||
singleton(DiscoveryNodeRole.MASTER_ROLE),
|
||||
singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE),
|
||||
Version.CURRENT
|
||||
);
|
||||
|
||||
|
@ -298,7 +298,7 @@ public class AddVotingConfigExclusionsRequestTests extends OpenSearchTestCase {
|
|||
"nodeId1",
|
||||
buildNewFakeTransportAddress(),
|
||||
emptyMap(),
|
||||
singleton(DiscoveryNodeRole.MASTER_ROLE),
|
||||
singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE),
|
||||
Version.CURRENT
|
||||
);
|
||||
final VotingConfigExclusion node1Exclusion = new VotingConfigExclusion(node1);
|
||||
|
@ -308,7 +308,7 @@ public class AddVotingConfigExclusionsRequestTests extends OpenSearchTestCase {
|
|||
"nodeId2",
|
||||
buildNewFakeTransportAddress(),
|
||||
emptyMap(),
|
||||
singleton(DiscoveryNodeRole.MASTER_ROLE),
|
||||
singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE),
|
||||
Version.CURRENT
|
||||
);
|
||||
final VotingConfigExclusion node2Exclusion = new VotingConfigExclusion(node2);
|
||||
|
@ -318,7 +318,7 @@ public class AddVotingConfigExclusionsRequestTests extends OpenSearchTestCase {
|
|||
"nodeId3",
|
||||
buildNewFakeTransportAddress(),
|
||||
emptyMap(),
|
||||
singleton(DiscoveryNodeRole.MASTER_ROLE),
|
||||
singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE),
|
||||
Version.CURRENT
|
||||
);
|
||||
|
||||
|
@ -348,7 +348,7 @@ public class AddVotingConfigExclusionsRequestTests extends OpenSearchTestCase {
|
|||
"nodeId1",
|
||||
buildNewFakeTransportAddress(),
|
||||
emptyMap(),
|
||||
singleton(DiscoveryNodeRole.MASTER_ROLE),
|
||||
singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE),
|
||||
Version.CURRENT
|
||||
);
|
||||
|
||||
|
@ -357,7 +357,7 @@ public class AddVotingConfigExclusionsRequestTests extends OpenSearchTestCase {
|
|||
"nodeId2",
|
||||
buildNewFakeTransportAddress(),
|
||||
emptyMap(),
|
||||
singleton(DiscoveryNodeRole.MASTER_ROLE),
|
||||
singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE),
|
||||
Version.CURRENT
|
||||
);
|
||||
final VotingConfigExclusion node2Exclusion = new VotingConfigExclusion(node2);
|
||||
|
@ -367,7 +367,7 @@ public class AddVotingConfigExclusionsRequestTests extends OpenSearchTestCase {
|
|||
"nodeId3",
|
||||
buildNewFakeTransportAddress(),
|
||||
emptyMap(),
|
||||
singleton(DiscoveryNodeRole.MASTER_ROLE),
|
||||
singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE),
|
||||
Version.CURRENT
|
||||
);
|
||||
|
||||
|
@ -399,7 +399,7 @@ public class AddVotingConfigExclusionsRequestTests extends OpenSearchTestCase {
|
|||
"local",
|
||||
buildNewFakeTransportAddress(),
|
||||
emptyMap(),
|
||||
singleton(DiscoveryNodeRole.MASTER_ROLE),
|
||||
singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE),
|
||||
Version.CURRENT
|
||||
);
|
||||
final VotingConfigExclusion localNodeExclusion = new VotingConfigExclusion(localNode);
|
||||
|
@ -408,7 +408,7 @@ public class AddVotingConfigExclusionsRequestTests extends OpenSearchTestCase {
|
|||
"other1",
|
||||
buildNewFakeTransportAddress(),
|
||||
emptyMap(),
|
||||
singleton(DiscoveryNodeRole.MASTER_ROLE),
|
||||
singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE),
|
||||
Version.CURRENT
|
||||
);
|
||||
final VotingConfigExclusion otherNode1Exclusion = new VotingConfigExclusion(otherNode1);
|
||||
|
@ -417,7 +417,7 @@ public class AddVotingConfigExclusionsRequestTests extends OpenSearchTestCase {
|
|||
"other2",
|
||||
buildNewFakeTransportAddress(),
|
||||
emptyMap(),
|
||||
singleton(DiscoveryNodeRole.MASTER_ROLE),
|
||||
singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE),
|
||||
Version.CURRENT
|
||||
);
|
||||
final VotingConfigExclusion otherNode2Exclusion = new VotingConfigExclusion(otherNode2);
|
||||
|
|
|
@ -119,7 +119,7 @@ public class TransportAddVotingConfigExclusionsActionTests extends OpenSearchTes
|
|||
name,
|
||||
buildNewFakeTransportAddress(),
|
||||
emptyMap(),
|
||||
singleton(DiscoveryNodeRole.MASTER_ROLE),
|
||||
singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE),
|
||||
Version.CURRENT
|
||||
);
|
||||
}
|
||||
|
|
|
@ -278,7 +278,7 @@ public class TransportResizeActionTests extends OpenSearchTestCase {
|
|||
|
||||
private DiscoveryNode newNode(String nodeId) {
|
||||
final Set<DiscoveryNodeRole> roles = Collections.unmodifiableSet(
|
||||
new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.DATA_ROLE))
|
||||
new HashSet<>(Arrays.asList(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.DATA_ROLE))
|
||||
);
|
||||
return new DiscoveryNode(nodeId, buildNewFakeTransportAddress(), emptyMap(), roles, Version.CURRENT);
|
||||
}
|
||||
|
|
|
@ -263,7 +263,7 @@ public class TransportMultiSearchActionTests extends OpenSearchTestCase {
|
|||
"master",
|
||||
buildNewFakeTransportAddress(),
|
||||
Collections.emptyMap(),
|
||||
Collections.singleton(DiscoveryNodeRole.MASTER_ROLE),
|
||||
Collections.singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE),
|
||||
Version.CURRENT
|
||||
)
|
||||
);
|
||||
|
|
|
@ -121,14 +121,14 @@ public class TransportMasterNodeActionTests extends OpenSearchTestCase {
|
|||
"local_node",
|
||||
buildNewFakeTransportAddress(),
|
||||
Collections.emptyMap(),
|
||||
Collections.singleton(DiscoveryNodeRole.MASTER_ROLE),
|
||||
Collections.singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE),
|
||||
Version.CURRENT
|
||||
);
|
||||
remoteNode = new DiscoveryNode(
|
||||
"remote_node",
|
||||
buildNewFakeTransportAddress(),
|
||||
Collections.emptyMap(),
|
||||
Collections.singleton(DiscoveryNodeRole.MASTER_ROLE),
|
||||
Collections.singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE),
|
||||
Version.CURRENT
|
||||
);
|
||||
allNodes = new DiscoveryNode[] { localNode, remoteNode };
|
||||
|
|
|
@ -172,7 +172,9 @@ public class TransportNodesActionTests extends OpenSearchTestCase {
|
|||
private enum NodeSelector {
|
||||
LOCAL("_local"),
|
||||
ELECTED_MASTER("_master"),
|
||||
// TODO: Remove this element after removing DiscoveryNodeRole.MASTER_ROLE
|
||||
MASTER_ELIGIBLE("master:true"),
|
||||
CLUSTER_MANAGER_ELIGIBLE("cluster_manager:true"),
|
||||
DATA("data:true"),
|
||||
CUSTOM_ATTRIBUTE("attr:value");
|
||||
|
||||
|
|
|
@ -447,17 +447,17 @@ public class ClusterChangedEventTests extends OpenSearchTestCase {
|
|||
if (i == 0) {
|
||||
// the master node
|
||||
builder.masterNodeId(nodeId);
|
||||
roles.add(DiscoveryNodeRole.MASTER_ROLE);
|
||||
roles.add(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE);
|
||||
} else if (i == 1) {
|
||||
// the alternate master node
|
||||
roles.add(DiscoveryNodeRole.MASTER_ROLE);
|
||||
roles.add(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE);
|
||||
} else if (i == 2) {
|
||||
// we need at least one data node
|
||||
roles.add(DiscoveryNodeRole.DATA_ROLE);
|
||||
} else {
|
||||
// remaining nodes can be anything (except for master)
|
||||
if (randomBoolean()) {
|
||||
roles.add(DiscoveryNodeRole.MASTER_ROLE);
|
||||
roles.add(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE);
|
||||
}
|
||||
if (randomBoolean()) {
|
||||
roles.add(DiscoveryNodeRole.DATA_ROLE);
|
||||
|
|
|
@ -112,7 +112,7 @@ public class ClusterBootstrapServiceTests extends OpenSearchTestCase {
|
|||
randomAlphaOfLength(10),
|
||||
buildNewFakeTransportAddress(),
|
||||
emptyMap(),
|
||||
Collections.singleton(DiscoveryNodeRole.MASTER_ROLE),
|
||||
Collections.singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE),
|
||||
Version.CURRENT
|
||||
);
|
||||
}
|
||||
|
@ -522,7 +522,7 @@ public class ClusterBootstrapServiceTests extends OpenSearchTestCase {
|
|||
randomAlphaOfLength(10),
|
||||
buildNewFakeTransportAddress(),
|
||||
emptyMap(),
|
||||
Collections.singleton(DiscoveryNodeRole.MASTER_ROLE),
|
||||
Collections.singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE),
|
||||
Version.CURRENT
|
||||
),
|
||||
new DiscoveryNode(
|
||||
|
@ -530,7 +530,7 @@ public class ClusterBootstrapServiceTests extends OpenSearchTestCase {
|
|||
randomAlphaOfLength(10),
|
||||
otherNode1.getAddress(),
|
||||
emptyMap(),
|
||||
Collections.singleton(DiscoveryNodeRole.MASTER_ROLE),
|
||||
Collections.singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE),
|
||||
Version.CURRENT
|
||||
)
|
||||
).collect(Collectors.toList())
|
||||
|
|
|
@ -287,7 +287,7 @@ public class ClusterFormationFailureHelperTests extends OpenSearchTestCase {
|
|||
"local",
|
||||
buildNewFakeTransportAddress(),
|
||||
emptyMap(),
|
||||
org.opensearch.common.collect.Set.of(DiscoveryNodeRole.MASTER_ROLE),
|
||||
org.opensearch.common.collect.Set.of(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE),
|
||||
Version.CURRENT
|
||||
);
|
||||
clusterState = ClusterState.builder(ClusterName.DEFAULT)
|
||||
|
@ -825,7 +825,7 @@ public class ClusterFormationFailureHelperTests extends OpenSearchTestCase {
|
|||
emptyMap(),
|
||||
new HashSet<>(
|
||||
randomSubsetOf(DiscoveryNodeRole.BUILT_IN_ROLES).stream()
|
||||
.filter(r -> r != DiscoveryNodeRole.MASTER_ROLE)
|
||||
.filter(r -> r != DiscoveryNodeRole.CLUSTER_MANAGER_ROLE)
|
||||
.collect(Collectors.toList())
|
||||
),
|
||||
Version.CURRENT
|
||||
|
|
|
@ -1789,7 +1789,7 @@ public class CoordinatorTests extends AbstractCoordinatorTestCase {
|
|||
"resolvableNodeId",
|
||||
buildNewFakeTransportAddress(),
|
||||
emptyMap(),
|
||||
singleton(DiscoveryNodeRole.MASTER_ROLE),
|
||||
singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE),
|
||||
Version.CURRENT
|
||||
)
|
||||
)
|
||||
|
|
|
@ -248,7 +248,7 @@ public class NodeJoinTests extends OpenSearchTestCase {
|
|||
protected DiscoveryNode newNode(int i, boolean master) {
|
||||
final Set<DiscoveryNodeRole> roles;
|
||||
if (master) {
|
||||
roles = singleton(DiscoveryNodeRole.MASTER_ROLE);
|
||||
roles = singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE);
|
||||
} else {
|
||||
roles = Collections.emptySet();
|
||||
}
|
||||
|
@ -492,7 +492,7 @@ public class NodeJoinTests extends OpenSearchTestCase {
|
|||
"newNodeId",
|
||||
buildNewFakeTransportAddress(),
|
||||
emptyMap(),
|
||||
singleton(DiscoveryNodeRole.MASTER_ROLE),
|
||||
singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE),
|
||||
Version.CURRENT
|
||||
);
|
||||
long newTerm = initialTerm + randomLongBetween(1, 10);
|
||||
|
|
|
@ -87,7 +87,9 @@ public class ClusterHealthAllocationTests extends OpenSearchAllocationTestCase {
|
|||
|
||||
private ClusterState addNode(ClusterState clusterState, String nodeName, boolean isMaster) {
|
||||
DiscoveryNodes.Builder nodeBuilder = DiscoveryNodes.builder(clusterState.getNodes());
|
||||
nodeBuilder.add(newNode(nodeName, Collections.singleton(isMaster ? DiscoveryNodeRole.MASTER_ROLE : DiscoveryNodeRole.DATA_ROLE)));
|
||||
nodeBuilder.add(
|
||||
newNode(nodeName, Collections.singleton(isMaster ? DiscoveryNodeRole.CLUSTER_MANAGER_ROLE : DiscoveryNodeRole.DATA_ROLE))
|
||||
);
|
||||
return ClusterState.builder(clusterState).nodes(nodeBuilder).build();
|
||||
}
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@ public class AutoExpandReplicasTests extends OpenSearchTestCase {
|
|||
|
||||
try {
|
||||
List<DiscoveryNode> allNodes = new ArrayList<>();
|
||||
DiscoveryNode localNode = createNode(DiscoveryNodeRole.MASTER_ROLE); // local node is the master
|
||||
DiscoveryNode localNode = createNode(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); // local node is the master
|
||||
allNodes.add(localNode);
|
||||
int numDataNodes = randomIntBetween(3, 5);
|
||||
List<DiscoveryNode> dataNodes = new ArrayList<>(numDataNodes);
|
||||
|
@ -245,7 +245,7 @@ public class AutoExpandReplicasTests extends OpenSearchTestCase {
|
|||
List<DiscoveryNode> allNodes = new ArrayList<>();
|
||||
DiscoveryNode oldNode = createNode(
|
||||
VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_7_0_0, LegacyESVersion.V_7_5_1),
|
||||
DiscoveryNodeRole.MASTER_ROLE,
|
||||
DiscoveryNodeRole.CLUSTER_MANAGER_ROLE,
|
||||
DiscoveryNodeRole.DATA_ROLE
|
||||
); // local node is the master
|
||||
allNodes.add(oldNode);
|
||||
|
@ -266,11 +266,11 @@ public class AutoExpandReplicasTests extends OpenSearchTestCase {
|
|||
state = cluster.reroute(state, new ClusterRerouteRequest());
|
||||
}
|
||||
|
||||
DiscoveryNode newNode = createNode(LegacyESVersion.V_7_6_0, DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.DATA_ROLE); // local
|
||||
// node
|
||||
// is
|
||||
// the
|
||||
// master
|
||||
DiscoveryNode newNode = createNode(
|
||||
LegacyESVersion.V_7_6_0,
|
||||
DiscoveryNodeRole.CLUSTER_MANAGER_ROLE,
|
||||
DiscoveryNodeRole.DATA_ROLE
|
||||
); // local node is the cluster_manager
|
||||
|
||||
state = cluster.addNodes(state, Collections.singletonList(newNode));
|
||||
|
||||
|
|
|
@ -582,7 +582,7 @@ public class MetadataCreateIndexServiceTests extends OpenSearchTestCase {
|
|||
|
||||
private DiscoveryNode newNode(String nodeId) {
|
||||
final Set<DiscoveryNodeRole> roles = Collections.unmodifiableSet(
|
||||
new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.DATA_ROLE))
|
||||
new HashSet<>(Arrays.asList(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.DATA_ROLE))
|
||||
);
|
||||
return new DiscoveryNode(nodeId, buildNewFakeTransportAddress(), emptyMap(), roles, Version.CURRENT);
|
||||
}
|
||||
|
|
|
@ -261,7 +261,7 @@ public class TemplateUpgradeServiceTests extends OpenSearchTestCase {
|
|||
}
|
||||
|
||||
private static final Set<DiscoveryNodeRole> MASTER_DATA_ROLES = Collections.unmodifiableSet(
|
||||
new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.DATA_ROLE))
|
||||
new HashSet<>(Arrays.asList(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.DATA_ROLE))
|
||||
);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
|
|
@ -56,9 +56,15 @@ public class DiscoveryNodeRoleSettingTests extends OpenSearchTestCase {
|
|||
}
|
||||
|
||||
public void testIsMasterNode() {
|
||||
// It's used to add MASTER_ROLE into 'roleMap', because MASTER_ROLE is removed from DiscoveryNodeRole.BUILT_IN_ROLES in 2.0.
|
||||
DiscoveryNode.setAdditionalRoles(Collections.emptySet());
|
||||
runRoleTest(DiscoveryNode::isMasterNode, DiscoveryNodeRole.MASTER_ROLE);
|
||||
}
|
||||
|
||||
public void testIsClusterManagerNode() {
|
||||
runRoleTest(DiscoveryNode::isMasterNode, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE);
|
||||
}
|
||||
|
||||
public void testIsRemoteClusterClient() {
|
||||
runRoleTest(DiscoveryNode::isRemoteClusterClient, DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE);
|
||||
}
|
||||
|
|
|
@ -128,4 +128,14 @@ public class DiscoveryNodeRoleTests extends OpenSearchTestCase {
|
|||
assertNotEquals(buildInRole.toString(), unknownDataRole.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the method can identify the role as cluster-manager.
|
||||
* Remove along with MASTER_ROLE.
|
||||
*/
|
||||
public void testIsClusterManager() {
|
||||
assertTrue(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE.isClusterManager());
|
||||
assertTrue(DiscoveryNodeRole.MASTER_ROLE.isClusterManager());
|
||||
assertFalse(randomFrom(DiscoveryNodeRole.DATA_ROLE.isClusterManager(), DiscoveryNodeRole.INGEST_ROLE.isClusterManager()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -174,6 +174,12 @@ public class DiscoveryNodeTests extends OpenSearchTestCase {
|
|||
runTestDiscoveryNodeIsRemoteClusterClient(nonRemoteClusterClientNode(), false);
|
||||
}
|
||||
|
||||
// TODO: Remove the test along with MASTER_ROLE. It is added in 2.0, along with the introduction of CLUSTER_MANAGER_ROLE.
|
||||
public void testSetAdditionalRolesCanAddDeprecatedMasterRole() {
|
||||
DiscoveryNode.setAdditionalRoles(Collections.emptySet());
|
||||
assertTrue(DiscoveryNode.getPossibleRoleNames().contains(DiscoveryNodeRole.MASTER_ROLE.roleName()));
|
||||
}
|
||||
|
||||
private void runTestDiscoveryNodeIsRemoteClusterClient(final Settings settings, final boolean expected) {
|
||||
final DiscoveryNode node = DiscoveryNode.createLocal(settings, new TransportAddress(TransportAddress.META_ADDRESS, 9200), "node");
|
||||
assertThat(node.isRemoteClusterClient(), equalTo(expected));
|
||||
|
|
|
@ -361,6 +361,7 @@ public class DiscoveryNodesTests extends OpenSearchTestCase {
|
|||
return Collections.singleton(nodes.getMasterNodeId());
|
||||
}
|
||||
},
|
||||
// TODO: Remove this element after removing DiscoveryNodeRole.MASTER_ROLE
|
||||
MASTER_ELIGIBLE(DiscoveryNodeRole.MASTER_ROLE.roleName() + ":true") {
|
||||
@Override
|
||||
Set<String> matchingNodeIds(DiscoveryNodes nodes) {
|
||||
|
@ -369,6 +370,14 @@ public class DiscoveryNodesTests extends OpenSearchTestCase {
|
|||
return ids;
|
||||
}
|
||||
},
|
||||
CLUSTER_MANAGER_ELIGIBLE(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE.roleName() + ":true") {
|
||||
@Override
|
||||
Set<String> matchingNodeIds(DiscoveryNodes nodes) {
|
||||
Set<String> ids = new HashSet<>();
|
||||
nodes.getMasterNodes().keysIt().forEachRemaining(ids::add);
|
||||
return ids;
|
||||
}
|
||||
},
|
||||
DATA(DiscoveryNodeRole.DATA_ROLE.roleName() + ":true") {
|
||||
@Override
|
||||
Set<String> matchingNodeIds(DiscoveryNodes nodes) {
|
||||
|
|
|
@ -262,7 +262,7 @@ public class DelayedAllocationServiceTests extends OpenSearchAllocationTestCase
|
|||
.routingTable(RoutingTable.builder().addAsNew(metadata.index("short_delay")).addAsNew(metadata.index("long_delay")).build())
|
||||
.nodes(
|
||||
DiscoveryNodes.builder()
|
||||
.add(newNode("node0", singleton(DiscoveryNodeRole.MASTER_ROLE)))
|
||||
.add(newNode("node0", singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE)))
|
||||
.localNodeId("node0")
|
||||
.masterNodeId("node0")
|
||||
.add(newNode("node1"))
|
||||
|
|
|
@ -778,7 +778,7 @@ public class OperationRoutingTests extends OpenSearchTestCase {
|
|||
"master",
|
||||
buildNewFakeTransportAddress(),
|
||||
Collections.emptyMap(),
|
||||
Collections.singleton(DiscoveryNodeRole.MASTER_ROLE),
|
||||
Collections.singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE),
|
||||
Version.CURRENT
|
||||
);
|
||||
allNodes[i] = master;
|
||||
|
|
|
@ -188,7 +188,7 @@ public class AllocationCommandsTests extends OpenSearchAllocationTestCase {
|
|||
.add(newNode("node1"))
|
||||
.add(newNode("node2"))
|
||||
.add(newNode("node3"))
|
||||
.add(newNode("node4", singleton(DiscoveryNodeRole.MASTER_ROLE)))
|
||||
.add(newNode("node4", singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE)))
|
||||
)
|
||||
.build();
|
||||
clusterState = allocation.reroute(clusterState, "reroute");
|
||||
|
@ -748,7 +748,9 @@ public class AllocationCommandsTests extends OpenSearchAllocationTestCase {
|
|||
"test2",
|
||||
buildNewFakeTransportAddress(),
|
||||
emptyMap(),
|
||||
new HashSet<>(randomSubsetOf(new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.INGEST_ROLE)))),
|
||||
new HashSet<>(
|
||||
randomSubsetOf(new HashSet<>(Arrays.asList(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.INGEST_ROLE)))
|
||||
),
|
||||
Version.CURRENT
|
||||
);
|
||||
|
||||
|
@ -817,7 +819,9 @@ public class AllocationCommandsTests extends OpenSearchAllocationTestCase {
|
|||
"test2",
|
||||
buildNewFakeTransportAddress(),
|
||||
emptyMap(),
|
||||
new HashSet<>(randomSubsetOf(new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.INGEST_ROLE)))),
|
||||
new HashSet<>(
|
||||
randomSubsetOf(new HashSet<>(Arrays.asList(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.INGEST_ROLE)))
|
||||
),
|
||||
Version.CURRENT
|
||||
);
|
||||
|
||||
|
|
|
@ -230,7 +230,7 @@ public class FailedNodeRoutingTests extends OpenSearchAllocationTestCase {
|
|||
|
||||
public ClusterState randomInitialClusterState() {
|
||||
List<DiscoveryNode> allNodes = new ArrayList<>();
|
||||
DiscoveryNode localNode = createNode(DiscoveryNodeRole.MASTER_ROLE); // local node is the master
|
||||
DiscoveryNode localNode = createNode(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); // local node is the master
|
||||
allNodes.add(localNode);
|
||||
// at least two nodes that have the data role so that we can allocate shards
|
||||
allNodes.add(createNode(DiscoveryNodeRole.DATA_ROLE));
|
||||
|
|
|
@ -1078,7 +1078,7 @@ public class DiskThresholdDeciderTests extends OpenSearchAllocationTestCase {
|
|||
"node1",
|
||||
buildNewFakeTransportAddress(),
|
||||
emptyMap(),
|
||||
singleton(DiscoveryNodeRole.MASTER_ROLE),
|
||||
singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE),
|
||||
Version.CURRENT
|
||||
);
|
||||
DiscoveryNode discoveryNode2 = new DiscoveryNode(
|
||||
|
@ -1227,7 +1227,7 @@ public class DiskThresholdDeciderTests extends OpenSearchAllocationTestCase {
|
|||
"master",
|
||||
buildNewFakeTransportAddress(),
|
||||
emptyMap(),
|
||||
singleton(DiscoveryNodeRole.MASTER_ROLE),
|
||||
singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE),
|
||||
Version.CURRENT
|
||||
);
|
||||
DiscoveryNode dataNode = new DiscoveryNode(
|
||||
|
|
|
@ -199,7 +199,7 @@ public class RestoreInProgressAllocationDeciderTests extends OpenSearchAllocatio
|
|||
RoutingTable routingTable = RoutingTable.builder().addAsNew(metadata.index("test")).build();
|
||||
|
||||
DiscoveryNodes discoveryNodes = DiscoveryNodes.builder()
|
||||
.add(newNode("master", Collections.singleton(DiscoveryNodeRole.MASTER_ROLE)))
|
||||
.add(newNode("master", Collections.singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE)))
|
||||
.localNodeId("master")
|
||||
.masterNodeId("master")
|
||||
.build();
|
||||
|
|
|
@ -602,7 +602,7 @@ public class NodeEnvironmentTests extends OpenSearchTestCase {
|
|||
);
|
||||
|
||||
assertThat(ex.getMessage(), containsString(indexPath.resolve(MetadataStateFormat.STATE_DIR_NAME).toAbsolutePath().toString()));
|
||||
assertThat(ex.getMessage(), startsWith("node does not have the data and master roles but has index metadata"));
|
||||
assertThat(ex.getMessage(), startsWith("node does not have the data and cluster_manager roles but has index metadata"));
|
||||
}
|
||||
|
||||
/** Converts an array of Strings to an array of Paths, adding an additional child if specified */
|
||||
|
|
|
@ -105,7 +105,7 @@ public class NodeRepurposeCommandTests extends OpenSearchTestCase {
|
|||
dataNoMasterSettings = nonMasterNode(dataMasterSettings);
|
||||
noDataNoMasterSettings = removeRoles(
|
||||
dataMasterSettings,
|
||||
Collections.unmodifiableSet(new HashSet<>(Arrays.asList(DiscoveryNodeRole.DATA_ROLE, DiscoveryNodeRole.MASTER_ROLE)))
|
||||
Collections.unmodifiableSet(new HashSet<>(Arrays.asList(DiscoveryNodeRole.DATA_ROLE, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE)))
|
||||
);
|
||||
|
||||
noDataMasterSettings = masterNode(nonDataNode(dataMasterSettings));
|
||||
|
|
|
@ -304,7 +304,7 @@ public class ClusterStateUpdatersTests extends OpenSearchTestCase {
|
|||
"node1",
|
||||
buildNewFakeTransportAddress(),
|
||||
Collections.emptyMap(),
|
||||
Sets.newHashSet(DiscoveryNodeRole.MASTER_ROLE),
|
||||
Sets.newHashSet(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE),
|
||||
Version.CURRENT
|
||||
);
|
||||
|
||||
|
@ -354,7 +354,7 @@ public class ClusterStateUpdatersTests extends OpenSearchTestCase {
|
|||
"node1",
|
||||
buildNewFakeTransportAddress(),
|
||||
Collections.emptyMap(),
|
||||
Sets.newHashSet(DiscoveryNodeRole.MASTER_ROLE),
|
||||
Sets.newHashSet(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE),
|
||||
Version.CURRENT
|
||||
);
|
||||
final ClusterState updatedState = Function.<ClusterState>identity()
|
||||
|
|
|
@ -97,7 +97,7 @@ public class GatewayMetaStatePersistedStateTests extends OpenSearchTestCase {
|
|||
"node1",
|
||||
buildNewFakeTransportAddress(),
|
||||
Collections.emptyMap(),
|
||||
Sets.newHashSet(DiscoveryNodeRole.MASTER_ROLE),
|
||||
Sets.newHashSet(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE),
|
||||
Version.CURRENT
|
||||
);
|
||||
clusterName = new ClusterName(randomAlphaOfLength(10));
|
||||
|
|
|
@ -327,7 +327,7 @@ public class IndicesClusterStateServiceRandomUpdatesTests extends AbstractIndice
|
|||
Supplier<MockIndicesService> indicesServiceSupplier
|
||||
) {
|
||||
List<DiscoveryNode> allNodes = new ArrayList<>();
|
||||
DiscoveryNode localNode = createNode(DiscoveryNodeRole.MASTER_ROLE); // local node is the master
|
||||
DiscoveryNode localNode = createNode(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); // local node is the master
|
||||
allNodes.add(localNode);
|
||||
// at least two nodes that have the data role so that we can allocate shards
|
||||
allNodes.add(createNode(DiscoveryNodeRole.DATA_ROLE));
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* The OpenSearch Contributors require contributions made to
|
||||
* this file be licensed under the Apache-2.0 license or a
|
||||
* compatible open source license.
|
||||
*/
|
||||
|
||||
package org.opensearch.node;
|
||||
|
||||
import org.opensearch.cluster.node.DiscoveryNode;
|
||||
import org.opensearch.cluster.node.DiscoveryNodeRole;
|
||||
import org.opensearch.common.settings.Settings;
|
||||
import org.opensearch.test.OpenSearchTestCase;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
|
||||
public class NodeRoleSettingsTests extends OpenSearchTestCase {
|
||||
|
||||
/**
|
||||
* Validate cluster_manager role and master role can not coexist in a node.
|
||||
* Remove the test after removing MASTER_ROLE.
|
||||
*/
|
||||
public void testClusterManagerAndMasterRoleCanNotCoexist() {
|
||||
// It's used to add MASTER_ROLE into 'roleMap', because MASTER_ROLE is removed from DiscoveryNodeRole.BUILT_IN_ROLES in 2.0.
|
||||
DiscoveryNode.setAdditionalRoles(Collections.emptySet());
|
||||
Settings roleSettings = Settings.builder().put(NodeRoleSettings.NODE_ROLES_SETTING.getKey(), "cluster_manager, master").build();
|
||||
Exception exception = expectThrows(IllegalArgumentException.class, () -> NodeRoleSettings.NODE_ROLES_SETTING.get(roleSettings));
|
||||
assertThat(exception.getMessage(), containsString("[master, cluster_manager] can not be assigned together to a node"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate cluster_manager role and data role can coexist in a node. The test is added along with validateRole().
|
||||
*/
|
||||
public void testClusterManagerAndDataNodeRoles() {
|
||||
Settings roleSettings = Settings.builder().put(NodeRoleSettings.NODE_ROLES_SETTING.getKey(), "cluster_manager, data").build();
|
||||
assertEquals(
|
||||
Arrays.asList(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.DATA_ROLE),
|
||||
NodeRoleSettings.NODE_ROLES_SETTING.get(roleSettings)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate setting master role will result a deprecation message.
|
||||
* Remove the test after removing MASTER_ROLE.
|
||||
*/
|
||||
public void testMasterRoleDeprecationMessage() {
|
||||
// It's used to add MASTER_ROLE into 'roleMap', because MASTER_ROLE is removed from DiscoveryNodeRole.BUILT_IN_ROLES in 2.0.
|
||||
DiscoveryNode.setAdditionalRoles(Collections.emptySet());
|
||||
Settings roleSettings = Settings.builder().put(NodeRoleSettings.NODE_ROLES_SETTING.getKey(), "master").build();
|
||||
assertEquals(Collections.singletonList(DiscoveryNodeRole.MASTER_ROLE), NodeRoleSettings.NODE_ROLES_SETTING.get(roleSettings));
|
||||
assertWarnings(DiscoveryNodeRole.MASTER_ROLE_DEPRECATION_MESSAGE);
|
||||
}
|
||||
}
|
|
@ -886,7 +886,7 @@ public class PersistentTasksClusterServiceTests extends OpenSearchTestCase {
|
|||
|
||||
private DiscoveryNode newNode(String nodeId) {
|
||||
final Set<DiscoveryNodeRole> roles = Collections.unmodifiableSet(
|
||||
new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.DATA_ROLE))
|
||||
new HashSet<>(Arrays.asList(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.DATA_ROLE))
|
||||
);
|
||||
return new DiscoveryNode(nodeId, buildNewFakeTransportAddress(), emptyMap(), roles, Version.CURRENT);
|
||||
}
|
||||
|
|
|
@ -1500,7 +1500,7 @@ public class SnapshotResiliencyTests extends OpenSearchTestCase {
|
|||
}
|
||||
|
||||
private TestClusterNode newMasterNode(String nodeName) throws IOException {
|
||||
return newNode(nodeName, DiscoveryNodeRole.MASTER_ROLE);
|
||||
return newNode(nodeName, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE);
|
||||
}
|
||||
|
||||
private TestClusterNode newDataNode(String nodeName) throws IOException {
|
||||
|
|
|
@ -747,7 +747,7 @@ public class SniffConnectionStrategyTests extends OpenSearchTestCase {
|
|||
"id",
|
||||
address,
|
||||
Collections.emptyMap(),
|
||||
new HashSet<>(Arrays.asList(DiscoveryNodeRole.DATA_ROLE, DiscoveryNodeRole.MASTER_ROLE)),
|
||||
new HashSet<>(Arrays.asList(DiscoveryNodeRole.DATA_ROLE, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE)),
|
||||
Version.CURRENT
|
||||
);
|
||||
assertTrue(nodePredicate.test(dataMaster));
|
||||
|
@ -757,7 +757,7 @@ public class SniffConnectionStrategyTests extends OpenSearchTestCase {
|
|||
"id",
|
||||
address,
|
||||
Collections.emptyMap(),
|
||||
new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE)),
|
||||
new HashSet<>(Arrays.asList(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE)),
|
||||
Version.CURRENT
|
||||
);
|
||||
assertFalse(nodePredicate.test(dedicatedMaster));
|
||||
|
@ -777,7 +777,7 @@ public class SniffConnectionStrategyTests extends OpenSearchTestCase {
|
|||
"id",
|
||||
address,
|
||||
Collections.emptyMap(),
|
||||
new HashSet<>(Arrays.asList(DiscoveryNodeRole.INGEST_ROLE, DiscoveryNodeRole.MASTER_ROLE)),
|
||||
new HashSet<>(Arrays.asList(DiscoveryNodeRole.INGEST_ROLE, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE)),
|
||||
Version.CURRENT
|
||||
);
|
||||
assertTrue(nodePredicate.test(masterIngest));
|
||||
|
@ -855,7 +855,7 @@ public class SniffConnectionStrategyTests extends OpenSearchTestCase {
|
|||
TransportAddress address = new TransportAddress(TransportAddress.META_ADDRESS, 0);
|
||||
Settings settings = Settings.builder().put("cluster.remote.node.attr", "gateway").build();
|
||||
Predicate<DiscoveryNode> nodePredicate = SniffConnectionStrategy.getNodePredicate(settings);
|
||||
Set<DiscoveryNodeRole> dedicatedMasterRoles = new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE));
|
||||
Set<DiscoveryNodeRole> dedicatedMasterRoles = new HashSet<>(Arrays.asList(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE));
|
||||
Set<DiscoveryNodeRole> allRoles = DiscoveryNodeRole.BUILT_IN_ROLES;
|
||||
{
|
||||
DiscoveryNode node = new DiscoveryNode(
|
||||
|
|
|
@ -149,7 +149,7 @@ public abstract class OpenSearchAllocationTestCase extends OpenSearchTestCase {
|
|||
}
|
||||
|
||||
protected static Set<DiscoveryNodeRole> MASTER_DATA_ROLES = Collections.unmodifiableSet(
|
||||
new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.DATA_ROLE))
|
||||
new HashSet<>(Arrays.asList(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.DATA_ROLE))
|
||||
);
|
||||
|
||||
protected static DiscoveryNode newNode(String nodeId) {
|
||||
|
|
|
@ -164,10 +164,10 @@ public class CoordinationStateTestCluster {
|
|||
|
||||
final Set<DiscoveryNodeRole> roles = new HashSet<>(localNode.getRoles());
|
||||
if (randomBoolean()) {
|
||||
if (roles.contains(DiscoveryNodeRole.MASTER_ROLE)) {
|
||||
roles.remove(DiscoveryNodeRole.MASTER_ROLE);
|
||||
if (roles.contains(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE)) {
|
||||
roles.remove(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE);
|
||||
} else {
|
||||
roles.add(DiscoveryNodeRole.MASTER_ROLE);
|
||||
roles.add(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -787,13 +787,13 @@ public final class InternalTestCluster extends TestCluster {
|
|||
String suffix = "";
|
||||
// only add the suffixes if roles are explicitly defined
|
||||
if (settings.hasValue("nodes.roles")) {
|
||||
if (DiscoveryNode.hasRole(settings, DiscoveryNodeRole.MASTER_ROLE)) {
|
||||
suffix = suffix + DiscoveryNodeRole.MASTER_ROLE.roleNameAbbreviation();
|
||||
if (DiscoveryNode.isMasterNode(settings)) {
|
||||
suffix = suffix + DiscoveryNodeRole.CLUSTER_MANAGER_ROLE.roleNameAbbreviation();
|
||||
}
|
||||
if (DiscoveryNode.isDataNode(settings)) {
|
||||
suffix = suffix + DiscoveryNodeRole.DATA_ROLE.roleNameAbbreviation();
|
||||
}
|
||||
if (DiscoveryNode.hasRole(settings, DiscoveryNodeRole.MASTER_ROLE) == false && DiscoveryNode.isDataNode(settings) == false) {
|
||||
if (!DiscoveryNode.isMasterNode(settings) && !DiscoveryNode.isDataNode(settings)) {
|
||||
suffix = suffix + "c";
|
||||
}
|
||||
}
|
||||
|
@ -2150,7 +2150,7 @@ public final class InternalTestCluster extends TestCluster {
|
|||
}
|
||||
|
||||
public List<String> startMasterOnlyNodes(int numNodes, Settings settings) {
|
||||
return startNodes(numNodes, Settings.builder().put(onlyRole(settings, DiscoveryNodeRole.MASTER_ROLE)).build());
|
||||
return startNodes(numNodes, Settings.builder().put(onlyRole(settings, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE)).build());
|
||||
}
|
||||
|
||||
public List<String> startDataOnlyNodes(int numNodes) {
|
||||
|
|
|
@ -80,6 +80,13 @@ public class NodeRoles {
|
|||
NodeRoleSettings.NODE_ROLES_SETTING.get(settings)
|
||||
.stream()
|
||||
.filter(r -> roles.contains(r) == false)
|
||||
// TODO: Remove the below filter after removing MASTER_ROLE.
|
||||
// It's used to remove both CLUSTER_MANAGER_ROLE and MASTER_ROLE, when requested to remove either.
|
||||
.filter(
|
||||
roles.contains(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE) || roles.contains(DiscoveryNodeRole.MASTER_ROLE)
|
||||
? r -> !r.isClusterManager()
|
||||
: r -> true
|
||||
)
|
||||
.map(DiscoveryNodeRole::roleName)
|
||||
.collect(Collectors.toList())
|
||||
)
|
||||
|
@ -166,7 +173,7 @@ public class NodeRoles {
|
|||
}
|
||||
|
||||
public static Settings masterNode(final Settings settings) {
|
||||
return addRoles(settings, Collections.singleton(DiscoveryNodeRole.MASTER_ROLE));
|
||||
return addRoles(settings, Collections.singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE));
|
||||
}
|
||||
|
||||
public static Settings masterOnlyNode() {
|
||||
|
@ -174,7 +181,7 @@ public class NodeRoles {
|
|||
}
|
||||
|
||||
public static Settings masterOnlyNode(final Settings settings) {
|
||||
return onlyRole(settings, DiscoveryNodeRole.MASTER_ROLE);
|
||||
return onlyRole(settings, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE);
|
||||
}
|
||||
|
||||
public static Settings nonMasterNode() {
|
||||
|
@ -182,7 +189,7 @@ public class NodeRoles {
|
|||
}
|
||||
|
||||
public static Settings nonMasterNode(final Settings settings) {
|
||||
return removeRoles(settings, Collections.singleton(DiscoveryNodeRole.MASTER_ROLE));
|
||||
return removeRoles(settings, Collections.singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE));
|
||||
}
|
||||
|
||||
public static Settings remoteClusterClientNode() {
|
||||
|
|
|
@ -398,17 +398,19 @@ public class InternalTestClusterTests extends OpenSearchTestCase {
|
|||
Function.identity()
|
||||
);
|
||||
cluster.beforeTest(random());
|
||||
// TODO: Remove this line, and replace 'clusterManagerRole' with CLUSTER_MANAGER_ROLE, after MASTER_ROLE is removed.
|
||||
// It is added in 2.0, along with the introduction of CLUSTER_MANAGER_ROLE, aims to test the 2 roles have the same effect.
|
||||
DiscoveryNodeRole clusterManagerRole = randomFrom(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.MASTER_ROLE);
|
||||
List<DiscoveryNodeRole> roles = new ArrayList<>();
|
||||
for (int i = 0; i < numNodes; i++) {
|
||||
final DiscoveryNodeRole role = i == numNodes - 1 && roles.contains(DiscoveryNodeRole.MASTER_ROLE) == false
|
||||
? DiscoveryNodeRole.MASTER_ROLE
|
||||
: // last node and still no master
|
||||
randomFrom(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.DATA_ROLE, DiscoveryNodeRole.INGEST_ROLE);
|
||||
final DiscoveryNodeRole role = i == numNodes - 1 && roles.contains(clusterManagerRole) == false
|
||||
? clusterManagerRole // last node and still no master
|
||||
: randomFrom(clusterManagerRole, DiscoveryNodeRole.DATA_ROLE, DiscoveryNodeRole.INGEST_ROLE);
|
||||
roles.add(role);
|
||||
}
|
||||
|
||||
cluster.setBootstrapMasterNodeIndex(
|
||||
randomIntBetween(0, (int) roles.stream().filter(role -> role.equals(DiscoveryNodeRole.MASTER_ROLE)).count() - 1)
|
||||
randomIntBetween(0, (int) roles.stream().filter(role -> role.equals(clusterManagerRole)).count() - 1)
|
||||
);
|
||||
|
||||
try {
|
||||
|
@ -416,7 +418,7 @@ public class InternalTestClusterTests extends OpenSearchTestCase {
|
|||
for (int i = 0; i < numNodes; i++) {
|
||||
final DiscoveryNodeRole role = roles.get(i);
|
||||
final String node;
|
||||
if (role == DiscoveryNodeRole.MASTER_ROLE) {
|
||||
if (role == clusterManagerRole) {
|
||||
node = cluster.startMasterOnlyNode();
|
||||
} else if (role == DiscoveryNodeRole.DATA_ROLE) {
|
||||
node = cluster.startDataOnlyNode();
|
||||
|
@ -438,7 +440,7 @@ public class InternalTestClusterTests extends OpenSearchTestCase {
|
|||
DiscoveryNode node = cluster.getInstance(ClusterService.class, name).localNode();
|
||||
List<String> paths = Arrays.stream(getNodePaths(cluster, name)).map(Path::toString).collect(Collectors.toList());
|
||||
if (node.isMasterNode()) {
|
||||
result.computeIfAbsent(DiscoveryNodeRole.MASTER_ROLE, k -> new HashSet<>()).addAll(paths);
|
||||
result.computeIfAbsent(clusterManagerRole, k -> new HashSet<>()).addAll(paths);
|
||||
} else if (node.isDataNode()) {
|
||||
result.computeIfAbsent(DiscoveryNodeRole.DATA_ROLE, k -> new HashSet<>()).addAll(paths);
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue