-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chunked Encoding for NodeStatsResponse (#90097)
Turn this into a chunked response to some degree. Only chunks per node for now, since deeper chunking needs larger changes downstream that don't fit in well with the current API.
- Loading branch information
1 parent
bfda66a
commit 5d784d6
Showing
5 changed files
with
88 additions
and
47 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
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
50 changes: 50 additions & 0 deletions
50
server/src/main/java/org/elasticsearch/action/support/nodes/BaseNodesXContentResponse.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,50 @@ | ||
/* | ||
* 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.nodes; | ||
|
||
import org.elasticsearch.action.FailedNodeException; | ||
import org.elasticsearch.cluster.ClusterName; | ||
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 BaseNodesXContentResponse<TNodeResponse extends BaseNodeResponse> extends BaseNodesResponse<TNodeResponse> | ||
implements | ||
ChunkedToXContent { | ||
|
||
protected BaseNodesXContentResponse(ClusterName clusterName, List<TNodeResponse> nodes, List<FailedNodeException> failures) { | ||
super(clusterName, nodes, failures); | ||
} | ||
|
||
protected BaseNodesXContentResponse(StreamInput in) throws IOException { | ||
super(in); | ||
} | ||
|
||
@Override | ||
public final Iterator<? extends ToXContent> toXContentChunked() { | ||
return Iterators.concat(Iterators.single((b, p) -> { | ||
b.startObject(); | ||
RestActions.buildNodesHeader(b, p, this); | ||
return b.field("cluster_name", getClusterName().value()); | ||
}), xContentChunks(), Iterators.single((ToXContent) (b, p) -> b.endObject())); | ||
} | ||
|
||
@Override | ||
public boolean isFragment() { | ||
return false; | ||
} | ||
|
||
protected abstract Iterator<? extends ToXContent> xContentChunks(); | ||
} |
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