use of org.opensearch.action.admin.cluster.allocation.ClusterAllocationExplainRequest in project OpenSearch by opensearch-project.
the class RestClusterAllocationExplainAction method prepareRequest.
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
ClusterAllocationExplainRequest req;
if (request.hasContentOrSourceParam() == false) {
// Empty request signals "explain the first unassigned shard you find"
req = new ClusterAllocationExplainRequest();
} else {
try (XContentParser parser = request.contentOrSourceParamParser()) {
req = ClusterAllocationExplainRequest.parse(parser);
}
}
req.includeYesDecisions(request.paramAsBoolean("include_yes_decisions", false));
req.includeDiskInfo(request.paramAsBoolean("include_disk_info", false));
return channel -> client.admin().cluster().allocationExplain(req, new RestBuilderListener<ClusterAllocationExplainResponse>(channel) {
@Override
public RestResponse buildResponse(ClusterAllocationExplainResponse response, XContentBuilder builder) throws IOException {
response.getExplanation().toXContent(builder, ToXContent.EMPTY_PARAMS);
return new BytesRestResponse(RestStatus.OK, builder);
}
});
}
Aggregations