-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use chunked encoding for indices stats response (#91760)
These responses can become huge, lets chunk them by index.
- Loading branch information
1 parent
c66ac71
commit 7dbc1ea
Showing
6 changed files
with
188 additions
and
94 deletions.
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
45 changes: 45 additions & 0 deletions
45
...er/src/main/java/org/elasticsearch/action/support/broadcast/ChunkedBroadcastResponse.java
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
package org.elasticsearch.action.support.broadcast; | ||
|
||
import org.elasticsearch.action.support.DefaultShardOperationFailedException; | ||
import org.elasticsearch.common.collect.Iterators; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.xcontent.ChunkedToXContent; | ||
import org.elasticsearch.rest.action.RestActions; | ||
import org.elasticsearch.xcontent.ToXContent; | ||
|
||
import java.io.IOException; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
public abstract class ChunkedBroadcastResponse extends BaseBroadcastResponse implements ChunkedToXContent { | ||
public ChunkedBroadcastResponse(StreamInput in) throws IOException { | ||
super(in); | ||
} | ||
|
||
public ChunkedBroadcastResponse( | ||
int totalShards, | ||
int successfulShards, | ||
int failedShards, | ||
List<DefaultShardOperationFailedException> shardFailures | ||
) { | ||
super(totalShards, successfulShards, failedShards, shardFailures); | ||
} | ||
|
||
@Override | ||
public final Iterator<ToXContent> toXContentChunked(ToXContent.Params params) { | ||
return Iterators.concat(Iterators.single((b, p) -> { | ||
b.startObject(); | ||
RestActions.buildBroadcastShardsHeader(b, p, this); | ||
return b; | ||
}), customXContentChunks(params), Iterators.single((builder, p) -> builder.endObject())); | ||
} | ||
|
||
protected abstract Iterator<ToXContent> customXContentChunks(ToXContent.Params params); | ||
} |
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.