use of org.elasticsearch.action.admin.indices.upgrade.post.UpgradeResponse in project elasticsearch by elastic.
the class RestUpgradeAction method handlePost.
private RestChannelConsumer handlePost(final RestRequest request, NodeClient client) {
UpgradeRequest upgradeReq = new UpgradeRequest(Strings.splitStringByCommaToArray(request.param("index")));
upgradeReq.indicesOptions(IndicesOptions.fromRequest(request, upgradeReq.indicesOptions()));
upgradeReq.upgradeOnlyAncientSegments(request.paramAsBoolean("only_ancient_segments", false));
return channel -> client.admin().indices().upgrade(upgradeReq, new RestBuilderListener<UpgradeResponse>(channel) {
@Override
public RestResponse buildResponse(UpgradeResponse response, XContentBuilder builder) throws Exception {
builder.startObject();
buildBroadcastShardsHeader(builder, request, response);
builder.startObject("upgraded_indices");
for (Map.Entry<String, Tuple<Version, String>> entry : response.versions().entrySet()) {
builder.startObject(entry.getKey());
builder.field("upgrade_version", entry.getValue().v1());
builder.field("oldest_lucene_segment_version", entry.getValue().v2());
builder.endObject();
}
builder.endObject();
builder.endObject();
return new BytesRestResponse(OK, builder);
}
});
}
use of org.elasticsearch.action.admin.indices.upgrade.post.UpgradeResponse in project crate by crate.
the class DDLStatementDispatcher method executeUpgradeSegments.
private static CompletableFuture<Long> executeUpgradeSegments(OptimizeTableAnalyzedStatement analysis, TransportUpgradeAction transportUpgradeAction) {
UpgradeRequest request = new UpgradeRequest(analysis.indexNames().toArray(new String[0]));
FutureActionListener<UpgradeResponse, Long> listener = new FutureActionListener<>(Functions.constant((long) analysis.indexNames().size()));
transportUpgradeAction.execute(request, listener);
return listener;
}
Aggregations