-
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
Merged
elasticsearchmachine
merged 4 commits into
elastic:main
from
DaveCTurner:2022-12-22-ccr-chunking
Dec 22, 2022
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,11 +7,15 @@ | |
|
||
package org.elasticsearch.xpack.ccr.rest; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.elasticsearch.action.support.ThreadedActionListener; | ||
import org.elasticsearch.client.internal.node.NodeClient; | ||
import org.elasticsearch.common.Strings; | ||
import org.elasticsearch.rest.BaseRestHandler; | ||
import org.elasticsearch.rest.RestRequest; | ||
import org.elasticsearch.rest.action.RestToXContentListener; | ||
import org.elasticsearch.rest.action.RestChunkedToXContentListener; | ||
import org.elasticsearch.xpack.ccr.Ccr; | ||
import org.elasticsearch.xpack.core.ccr.action.FollowStatsAction; | ||
|
||
import java.util.List; | ||
|
@@ -20,6 +24,8 @@ | |
|
||
public class RestFollowStatsAction extends BaseRestHandler { | ||
|
||
private static final Logger logger = LogManager.getLogger(RestFollowStatsAction.class); | ||
|
||
@Override | ||
public List<Route> routes() { | ||
return List.of(new Route(GET, "/{index}/_ccr/stats")); | ||
|
@@ -34,7 +40,17 @@ public String getName() { | |
protected RestChannelConsumer prepareRequest(final RestRequest restRequest, final NodeClient client) { | ||
final FollowStatsAction.StatsRequest request = new FollowStatsAction.StatsRequest(); | ||
request.setIndices(Strings.splitStringByCommaToArray(restRequest.param("index"))); | ||
return channel -> client.execute(FollowStatsAction.INSTANCE, request, new RestToXContentListener<>(channel)); | ||
return channel -> client.execute( | ||
FollowStatsAction.INSTANCE, | ||
request, | ||
new ThreadedActionListener<>( | ||
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. Same here why does this need threading if it's chunked encoding? |
||
logger, | ||
client.threadPool(), | ||
Ccr.CCR_THREAD_POOL_NAME, | ||
new RestChunkedToXContentListener<>(channel), | ||
false | ||
) | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.elasticsearch/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/FollowStatsAction.java
Lines 73 to 78 in c1efe47
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.