-
Notifications
You must be signed in to change notification settings - Fork 25.5k
Simplify TransportNodesAction #92987
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
Simplify TransportNodesAction #92987
Conversation
Recent improvements to the primitives for writing async code (particularly elastic#92452 and elastic#92620) mean that we can enormously simplify `TransportNodesAction`. In particular, we can avoid accumulating an intermediate array of responses for later processing in favour of just accumulating the successes and failures into their final separate lists. We also no longer need to use a separate `NodesResponseTracker` to discard responses on cancellation.
Pinging @elastic/es-distributed (Team:Distributed) |
@DaveCTurner thanks! Indeed, I am :). I am catching up on the changes and I will review it right away! |
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.
Nice work, I have some minor comments and a few questions that will help me learn too. Thank you for improving this.
server/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesAction.java
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesAction.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesAction.java
Outdated
Show resolved
Hide resolved
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.
I didn't get a ping to review again but all my comments were addressed so LGTM 🚀
Thanks @DaveCTurner
Thanks @gmarouli ! |
Similarly to elastic#92987, recent improvements to the primitives for writing async code (particularly elastic#92452 and elastic#92620) mean that we can enormously simplify `TransportBroadcastByNodeAction`. In particular, we can avoid accumulating an intermediate array of responses for later processing in favour of just accumulating the successes and failures into their final separate lists. We also no longer need to use a separate `NodesResponseTracker` to discard responses on cancellation. Finally, we can now discard shard-level responses more promptly on cancellation.
Similarly to #92987, recent improvements to the primitives for writing async code (particularly #92452 and #92620) mean that we can enormously simplify `TransportBroadcastByNodeAction`. In particular, we can avoid accumulating an intermediate array of responses for later processing in favour of just accumulating the successes and failures into their final separate lists. We also no longer need to use a separate `NodesResponseTracker` to discard responses on cancellation. Finally, we can now discard shard-level responses more promptly on cancellation.
Each `TransportTasksAction` fans-out to multiple nodes, accumulates responses and retains them until all the nodes have responded, and then converts the responses into a final result. Similarly to elastic#92987 and elastic#93484, we should accumulate the responses in a structure that doesn't require so much copying later on, and should drop the received responses if the task is cancelled while some nodes' responses are still pending.
We have this somewhat-complex pattern in 3 places already, and elastic#96279 will introduce a couple more, so this commit extracts it as a dedicated utility. Relates elastic#92987 Relates elastic#93484
Each `TransportTasksAction` fans-out to multiple nodes, accumulates responses and retains them until all the nodes have responded, and then converts the responses into a final result. Similarly to #92987 and #93484, we should accumulate the responses in a structure that doesn't require so much copying later on, and should drop the received responses if the task is cancelled while some nodes' responses are still pending.
Recent improvements to the primitives for writing async code (particularly #92452 and #92620) mean that we can enormously simplify
TransportNodesAction
. In particular, we can avoid accumulating an intermediate array of responses for later processing in favour of just accumulating the successes and failures into their final separate lists. We also no longer need to use a separateNodesResponseTracker
to discard responses on cancellation.