Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new node role 'cluster_manager' as the alternative for 'master' role and deprecate 'master' role #2424

Merged
merged 57 commits into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from 54 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
344998c
Add a new role cluster_manager as alternative to existing master role
tlfeng Mar 9, 2022
0396a4a
Add CLUSTER_MANAGER_ROLE in server code and replace MASTER_ROLE in tests
Mar 10, 2022
77520c8
adjust format by spotlessApply
Mar 10, 2022
085f07f
add hack in setAdditionalRoles() to allow CLUSTER_MANAGER_ROLE having…
Mar 10, 2022
d9aec73
adjust format by spotlessApply
Mar 10, 2022
02f8f86
Fix DiscoveryNodeRoleSettingTests
Mar 10, 2022
573380f
Change todo expression
Mar 10, 2022
bd395af
adjust format by spotlessApply
tlfeng Mar 10, 2022
83460f4
remove MASTER_ROLE from built-in roles
tlfeng Mar 10, 2022
0940b41
fix unit tests
tlfeng Mar 10, 2022
41806f0
Fix unit tests
Mar 10, 2022
11c4ff5
Adjust format
Mar 10, 2022
8cc54e3
Remove temprorary log message
Mar 10, 2022
f06766e
Remove temprorary log message
Mar 10, 2022
70c8f4a
Remove duplicate m in node.role of cat nodes API
Mar 10, 2022
e8e2e30
Add yaml rest test for node role cluster_manager
Mar 10, 2022
46098cd
Allow _cluster_manager as a value of node filter
Mar 10, 2022
73b4652
Add compatitabilityRole to cluster_manager role
Mar 12, 2022
d1acef0
Revert adding isClusterManagerEligible()
Mar 12, 2022
812aa39
Remove master role from the default value of node.roles
Mar 12, 2022
d15e44f
Revert a mistake of removing javadoc comment
Mar 12, 2022
0189e86
Add a comment of setting a default value of a temp setting to false
Mar 12, 2022
14ef7c5
Fix cluster stats nodes count
Mar 12, 2022
06fdf74
Fix DiscoveryNodeRoleSettingTests
Mar 12, 2022
10247a2
adjust format
Mar 12, 2022
8817b73
Reduce code change
Mar 12, 2022
010fd29
Skip run node_info role test during during mixedClusterTest, after a …
Mar 12, 2022
eda18db
Skip run node_info role test during during mixedClusterTest, after a …
Mar 13, 2022
8f9ab2b
Add unit tests in DiscoveryNodeTests
Mar 13, 2022
22567a4
Revert adding clustermanager role into isDedicatedVotingOnlyNode
Mar 13, 2022
4e0b27c
Modify the test to assign master and clusetr_manager role in Internal…
Mar 13, 2022
6d08a78
modify the comment
Mar 13, 2022
8ca3a9f
Add cluster_manager role to be tested by node selector in 2 uni tests
Mar 13, 2022
4c0e5f4
Revert import util.*
Mar 13, 2022
4fa904f
Fix newly added test in DiscoveryNodeTests
Mar 13, 2022
d1ee0c6
Fix nodes.info yaml rest test during mixedclustertest
Mar 13, 2022
a4b7b72
Reduce code change in removeRoles()
Mar 13, 2022
dafc3b7
Merge branch 'main' into node-role-cluster-manager
Mar 13, 2022
4fd23e6
Merge branch 'main' into node-role-cluster-manager
Mar 17, 2022
7a2a6b9
Change == to equals()
Mar 17, 2022
83a3c73
Change Version.Current to Version.v2_0_0, since current is a moving t…
Mar 17, 2022
e4404d7
Remove an unnecessary TODO
Mar 17, 2022
b5837b7
Change MASTER_ROLE to CLUSTER_MANAGER_ROLE directly in a method about…
Mar 17, 2022
ebb1c45
Fix yaml rest test by adding proper node selector
Mar 17, 2022
0dadd68
Add validateRole() to aviod cluster_manager and master role exist tog…
Mar 17, 2022
6845cdd
Remove an unnecessary TODO
Mar 17, 2022
f818ea1
Remove validateRole() in MASTER_ROLE
Mar 17, 2022
5847ae0
Add unit test for the role setting validator
Mar 17, 2022
14124bd
Modify error message for both roles assigned
Mar 17, 2022
ef70fe9
Merge branch 'main' into node-role-cluster-manager
Mar 17, 2022
a2661a8
Reduce || for comparing with cluster_manager and master role by warpp…
Mar 17, 2022
47961ce
Merge branch 'main' into node-role-cluster-manager
Mar 17, 2022
f59a27b
Add deprecation message for setting master role
Mar 17, 2022
90f143a
Modify the deprecation message for master role
Mar 17, 2022
69c3795
Merge branch 'main' into node-role-cluster-manager
Mar 18, 2022
87e5048
Revert code about abbr name in RestNodesAction
Mar 18, 2022
f57741d
Merge remote-tracking branch 'upstream/main' into node-role-cluster-m…
Mar 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public static DiscoveryNode newNode(String nodeId, Map<String, String> attribute
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
);
}
Expand Down
8 changes: 4 additions & 4 deletions client/rest/src/main/java/org/opensearch/client/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,21 +210,21 @@ public Roles(final Set<String> roles) {
}

/**
* 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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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" }
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public void testNodeCounts() {
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);
Expand All @@ -106,7 +107,7 @@ public void testNodeCounts() {
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);
Expand All @@ -129,6 +130,7 @@ public void testNodeCounts() {
}
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public Settings onNodeStopped(String nodeName) {
})
);
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"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,14 @@ private Counts(final List<NodeInfo> nodeInfos) {
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);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public static boolean hasRole(final Settings settings, final DiscoveryNodeRole r
}

public static boolean isMasterNode(Settings settings) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isMasterNode -> isClusterManager?

Copy link
Collaborator Author

@tlfeng tlfeng Mar 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Such method is published into Maven as Java API (https://opensearch.org/javadocs/1.2.4/OpenSearch/server/build/docs/javadoc/org/opensearch/cluster/node/DiscoveryNode.html#isMasterNode()), so I'm not going to change the name soon, in case any plugins or clients are using the method, though maybe no other software using it 😅.
I think the normal way is to deprecate this method and create new method aside, but it will be a huge work to deprecate all the methods/classes with the mane "master", so I'm planning to rename them in place in next major version.
Of course, I think there is an option to choose a few common used methods to follow the normal deprecation path. I haven't got a decision which method to rename in place, and which to create alternative method aside.
There is a discussion in the PR #2453, you could take a look at. Renaming the Java APIs is tracked in issue #1684

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deprecating isMaster in favour of isClusterManager sounds like a plan

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will mark it in an issue and deprecate it another PR. Thank you!

return hasRole(settings, DiscoveryNodeRole.MASTER_ROLE);
return hasRole(settings, DiscoveryNodeRole.MASTER_ROLE) || hasRole(settings, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE);
}

/**
Expand Down Expand Up @@ -343,7 +343,7 @@ public DiscoveryNode(StreamInput in) throws IOException {
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);
Expand Down Expand Up @@ -390,11 +390,11 @@ public void writeTo(StreamOutput out) throws IOException {
.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);
}
}
Expand Down Expand Up @@ -456,7 +456,7 @@ public boolean isDataNode() {
* Can this node become master or not.
*/
public boolean isMasterNode() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isMasterNode -> isClusterManager?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(please see the above comment 😁)

return roles.contains(DiscoveryNodeRole.MASTER_ROLE);
return roles.contains(DiscoveryNodeRole.MASTER_ROLE) || roles.contains(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE);
}

/**
Expand Down Expand Up @@ -591,15 +591,19 @@ public static void setAdditionalRoles(final Set<DiscoveryNodeRole> additionalRol
+ "], 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() {
return roleMap.keySet();
}

/**
* 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@

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;
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;
Expand All @@ -50,6 +53,10 @@
*/
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;

/**
Expand Down Expand Up @@ -129,6 +136,13 @@ public DiscoveryNodeRole getCompatibilityRole(Version nodeVersion) {
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;
Expand Down Expand Up @@ -193,15 +207,60 @@ public Setting<Boolean> legacySetting() {

/**
* 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
)
);
}
}
Copy link
Collaborator Author

@tlfeng tlfeng Mar 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrross Thanks for your opinion to not allow "master" role and "cluster_manager" role coexisting. 👍 😄
I updated the code in commit 0dadd68 f818ea1, and unit test 5847ae0.

It's achieved by adding a method validateRole() to allow defining different validation rule for each role, to check the compatibility with the other roles in the setting node.roles.


};

public static final DiscoveryNodeRole REMOTE_CLUSTER_CLIENT_ROLE = new DiscoveryNodeRole("remote_cluster_client", "r") {
Expand All @@ -223,7 +282,7 @@ public Setting<Boolean> legacySetting() {
* 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))
);

/**
Expand Down Expand Up @@ -262,4 +321,13 @@ public Setting<Boolean> legacySetting() {

}

/**
* 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ public DiscoveryNode resolveNode(String node) {
* 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
Expand All @@ -393,7 +393,7 @@ public String[] resolveNodes(String... nodes) {
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);
Expand All @@ -419,7 +419,7 @@ public String[] resolveNodes(String... nodes) {
} 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 {
Expand Down Expand Up @@ -797,4 +797,17 @@ public boolean isLocalNodeElectedMaster() {
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);
}
}
Loading