-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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 _coordinating_only
for nodes resolving in nodes API
#30313
Changes from 1 commit
d2ef73c
2b6eac6
2c50745
1f51cf7
7a73b41
6082969
3f1a3e6
aa337fc
e905aaa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,6 +148,19 @@ public ImmutableOpenMap<String, DiscoveryNode> getMasterAndDataNodes() { | |
return nodes.build(); | ||
} | ||
|
||
/** | ||
* Get a {@link Map} of the coordinating only nodes (nodes which are neither master, nor data, nor ingest nodes) arranged by their ids | ||
* | ||
* @return {@link Map} of the coordinating only nodes arranged by their ids | ||
*/ | ||
public ImmutableOpenMap<String, DiscoveryNode> getCoordinatingOnlyNodes() { | ||
ImmutableOpenMap.Builder<String, DiscoveryNode> nodes = ImmutableOpenMap.builder(this.nodes); | ||
nodes.removeAll(masterNodes.keys()); | ||
nodes.removeAll(dataNodes.keys()); | ||
nodes.removeAll(ingestNodes.keys()); | ||
return nodes.build(); | ||
} | ||
|
||
/** | ||
* Get a node by its id | ||
* | ||
|
@@ -294,10 +307,10 @@ public DiscoveryNode resolveNode(String node) { | |
|
||
/** | ||
* resolves a set of node "descriptions" to concrete and existing node ids. "descriptions" can be (resolved in this order): | ||
* - "_local" or "_master" for the relevant nodes | ||
* - "_local", "_master" or "_coordinating_only" for the relevant nodes | ||
* - a node id | ||
* - a wild card pattern that will be matched against node names | ||
* - a "attr:value" pattern, where attr can be a node role (master, data, ingest etc.) in which case the value can be true of false | ||
* - a "attr:value" pattern, where attr can be a node role (master, data, ingest etc.) in which case the value can be true or false, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
* or a generic node attribute name in which case value will be treated as a wildcard and matched against the node attribute values. | ||
*/ | ||
public String[] resolveNodes(String... nodes) { | ||
|
@@ -316,6 +329,8 @@ public String[] resolveNodes(String... nodes) { | |
if (masterNodeId != null) { | ||
resolvedNodesIds.add(masterNodeId); | ||
} | ||
} else if (nodeId.equals("_coordinating_only")) { | ||
resolvedNodesIds.addAll(getCoordinatingOnlyNodes().keys()); | ||
} else if (nodeExists(nodeId)) { | ||
resolvedNodesIds.add(nodeId); | ||
} else { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,9 +102,7 @@ public void testCoordinatorOnlyNodes() { | |
.map(DiscoveryNode::getId) | ||
.toArray(String[]::new); | ||
|
||
assertThat( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it'd be good to keep this assertion here too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks good now, thanks 👍 |
||
discoveryNodes.resolveNodes("_all", "data:false", "ingest:false", "master:false"), | ||
arrayContainingInAnyOrder(coordinatorOnlyNodes)); | ||
assertThat(discoveryNodes.resolveNodes("_coordinating_only"), arrayContainingInAnyOrder(coordinatorOnlyNodes)); | ||
} | ||
|
||
public void testResolveNodesIds() { | ||
|
@@ -254,6 +252,13 @@ Set<String> matchingNodeIds(DiscoveryNodes nodes) { | |
Set<String> matchingNodeIds(DiscoveryNodes nodes) { | ||
return Collections.singleton(nodes.getMasterNodeId()); | ||
} | ||
}, COORDINATING_ONLY("_coordinating_only") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like a hangover of the previous approach - should be |
||
@Override | ||
Set<String> matchingNodeIds(DiscoveryNodes nodes) { | ||
Set<String> ids = new HashSet<>(); | ||
nodes.getCoordinatingOnlyNodes().keysIt().forEachRemaining(ids::add); | ||
return ids; | ||
} | ||
}, MASTER_ELIGIBLE(DiscoveryNode.Role.MASTER.getRoleName() + ":true") { | ||
@Override | ||
Set<String> matchingNodeIds(DiscoveryNodes nodes) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't make sense -
_local
refers to the node receiving the request, but_master
and_coordinating_only
refer to all master and coordinating nodes. I think it might be better to expand this section of the docs with something like a bulleted list, since this sentence is becoming unwieldy.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @DaveCTurner, I just find this part a little bit confusing when we say
"nodes to execute on"
or"node receiving the request"
. If I understand well, all the_local
,_master
,_coordinating_only
or node id, custom attributes etc. are just filters right ? When I do aGET /_nodes/_local
it returns to me the node info of the local node, if I do aGET /_nodes/_master
, it returns to me the node info of master node ? same for other api like nodes stats, nodes hot_threads etc. So if the local node is the master, I get the same result for the above 2 requests right ? What we would explain here is not "the node to which request was forwarded" ?