-
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
Chunked encoding for CCR APIs #92526
Chunked encoding for CCR APIs #92526
Conversation
The CCR info and stats APIs can send fairly sizeable responses that scale as `O(#shards)`. This commit makes them chunked. Relates elastic#89838
Pinging @elastic/es-distributed (Team:Distributed) |
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.
Looks good just a random NIT and a question on the threading.
return channel -> client.execute( | ||
CcrStatsAction.INSTANCE, | ||
request, | ||
new ThreadedActionListener<>( |
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.
Why do I still need a threaded listener with chunked encoding?
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 toXContent
implementation collects all the shard responses into a map keyed by index up-front - I think that should be done elsewhere.
Lines 73 to 78 in c1efe47
// sort by index name, then shard ID | |
final Map<String, Map<Integer, StatsResponse>> taskResponsesByIndex = new TreeMap<>(); | |
for (final StatsResponse response : statsResponse) { | |
taskResponsesByIndex.computeIfAbsent(response.status().followerIndex(), k -> new TreeMap<>()) | |
.put(response.status().getShardId(), response); | |
} |
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.
On reflection this could reasonably be using the CCR pool, adjusted in a194c11.
return channel -> client.execute( | ||
FollowStatsAction.INSTANCE, | ||
request, | ||
new ThreadedActionListener<>( |
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.
Same here why does this need threading if it's chunked encoding?
(builder, params) -> builder.startObject().field("auto_follow_stats", autoFollowStats, params).field("follow_stats") | ||
), | ||
followStats.toXContentChunked(outerParams), | ||
Iterators.single((builder, params) -> builder.endObject()) |
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.
NIT: I added org.elasticsearch.common.xcontent.ChunkedToXContentHelper#endObject
for this.
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 thanks for the explanation.
The CCR info and stats APIs can send fairly sizeable responses that scale as
O(#shards)
. This commit makes them chunked.Relates #89838