-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Use TaskId in TaskAwareRequest.createRequest #130131
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
Use TaskId in TaskAwareRequest.createRequest #130131
Conversation
Use TaskId instead of passing a node name and ID individually.
429db8b
to
0f9d2bd
Compare
Pinging @elastic/es-distributed-coordination (Team:Distributed Coordination) |
@@ -141,9 +149,9 @@ public Task register(String type, String action, TaskAwareRequest request, boole | |||
headers.put(key, httpHeader); | |||
} | |||
} | |||
String localNodeId = Optional.ofNullable(lastDiscoveryNodes.getLocalNodeId()).orElse(initialNodeId); |
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.
The node id from NodeEnvironment isn't the "initial" node id, it is the node id. That's what is passed in to the local node in DiscoveryNodes, see the LocalNodeFactory in NodeConstruction.
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.
But can't lastDiscoverNodes
change, thereby changing the node ID? Or is the applyClusterState
not really meant for mutation, but rather is just a way to set this value post-construction?
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.
The local node in DiscoveryNodes won't effectively change, see DiscoveryNodes.readFrom
where the local node id is passed in, not ready from the wire.
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.
OK, I've renamed this to nodeId
, and added a comment on the field to make its existence clearer.
@@ -141,9 +150,9 @@ public Task register(String type, String action, TaskAwareRequest request, boole | |||
headers.put(key, httpHeader); | |||
} | |||
} | |||
String localNodeId = Optional.ofNullable(lastDiscoveryNodes.getLocalNodeId()).orElse(nodeId); |
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.
Sorry I didn't make my point clear: there is no need to look at DiscoveryNodes at all, this is the node id, it can't change.
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.
Ah, got it! I've replaced to code to only use nodeId
.
…alouche/elasticsearch into refactor/task_aware_request_task_id
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.
seems there are a few remaining places calling it "initial" node id. Also, the PR title should be updated, the "TODO refactor" is not needed
ThreadPool threadPool, | ||
Set<String> taskHeaders, | ||
Tracer tracer, | ||
@Nullable String initialNodeId |
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 should not be nullable, and also not "initial"?
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.
Good catch! I've went over and removed all new @Nullable
, and renamed initialNodeId
to nodeId
.
7f0b984
to
d4de01c
Compare
@@ -59,9 +59,7 @@ protected MockTransportService createTransportService() { | |||
new NoneCircuitBreakerService(), | |||
new SharedGroupFactory(Settings.EMPTY) | |||
), | |||
threadPool, | |||
TransportService.NOOP_TRANSPORT_INTERCEPTOR, |
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.
It seemed all clients passed the same Settings.EMPTY
, interceptor, and null
in the clusterSettings
to this constructor (refactored to a factory method), so I've simplified the method by removing those parameters.
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.
LGTM
@@ -96,10 +98,15 @@ public TaskManager(Settings settings, ThreadPool threadPool, Set<String> taskHea | |||
} | |||
|
|||
public TaskManager(Settings settings, ThreadPool threadPool, Set<String> taskHeaders, Tracer tracer) { |
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.
please mention with a comment this is just for tests (creating the uuid). we should move all these uses to explicitly pass a test nodeid, but that can be a followup
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.
Done.
26af770
to
8fe47d9
Compare
Thanks for the review @rjernst! |
This PR resolves the TODOs introduced in #127472.