Search in sources :

Example 1 with UpgradeResponse

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);
        }
    });
}
Also used : UpgradeRequest(org.elasticsearch.action.admin.indices.upgrade.post.UpgradeRequest) BaseRestHandler(org.elasticsearch.rest.BaseRestHandler) UpgradeStatusRequest(org.elasticsearch.action.admin.indices.upgrade.get.UpgradeStatusRequest) GET(org.elasticsearch.rest.RestRequest.Method.GET) RestResponse(org.elasticsearch.rest.RestResponse) RestBuilderListener(org.elasticsearch.rest.action.RestBuilderListener) IOException(java.io.IOException) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) RestController(org.elasticsearch.rest.RestController) UpgradeStatusResponse(org.elasticsearch.action.admin.indices.upgrade.get.UpgradeStatusResponse) Strings(org.elasticsearch.common.Strings) BytesRestResponse(org.elasticsearch.rest.BytesRestResponse) POST(org.elasticsearch.rest.RestRequest.Method.POST) Version(org.elasticsearch.Version) Settings(org.elasticsearch.common.settings.Settings) RestActions.buildBroadcastShardsHeader(org.elasticsearch.rest.action.RestActions.buildBroadcastShardsHeader) UpgradeResponse(org.elasticsearch.action.admin.indices.upgrade.post.UpgradeResponse) Map(java.util.Map) IndicesOptions(org.elasticsearch.action.support.IndicesOptions) RestRequest(org.elasticsearch.rest.RestRequest) OK(org.elasticsearch.rest.RestStatus.OK) NodeClient(org.elasticsearch.client.node.NodeClient) Tuple(org.elasticsearch.common.collect.Tuple) UpgradeResponse(org.elasticsearch.action.admin.indices.upgrade.post.UpgradeResponse) Version(org.elasticsearch.Version) UpgradeRequest(org.elasticsearch.action.admin.indices.upgrade.post.UpgradeRequest) RestResponse(org.elasticsearch.rest.RestResponse) BytesRestResponse(org.elasticsearch.rest.BytesRestResponse) BytesRestResponse(org.elasticsearch.rest.BytesRestResponse) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) IOException(java.io.IOException)

Example 2 with UpgradeResponse

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;
}
Also used : UpgradeResponse(org.elasticsearch.action.admin.indices.upgrade.post.UpgradeResponse) UpgradeRequest(org.elasticsearch.action.admin.indices.upgrade.post.UpgradeRequest) FutureActionListener(io.crate.action.FutureActionListener)

Aggregations

UpgradeRequest (org.elasticsearch.action.admin.indices.upgrade.post.UpgradeRequest)2 UpgradeResponse (org.elasticsearch.action.admin.indices.upgrade.post.UpgradeResponse)2 FutureActionListener (io.crate.action.FutureActionListener)1 IOException (java.io.IOException)1 Map (java.util.Map)1 Version (org.elasticsearch.Version)1 UpgradeStatusRequest (org.elasticsearch.action.admin.indices.upgrade.get.UpgradeStatusRequest)1 UpgradeStatusResponse (org.elasticsearch.action.admin.indices.upgrade.get.UpgradeStatusResponse)1 IndicesOptions (org.elasticsearch.action.support.IndicesOptions)1 NodeClient (org.elasticsearch.client.node.NodeClient)1 Strings (org.elasticsearch.common.Strings)1 Tuple (org.elasticsearch.common.collect.Tuple)1 Settings (org.elasticsearch.common.settings.Settings)1 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)1 BaseRestHandler (org.elasticsearch.rest.BaseRestHandler)1 BytesRestResponse (org.elasticsearch.rest.BytesRestResponse)1 RestController (org.elasticsearch.rest.RestController)1 RestRequest (org.elasticsearch.rest.RestRequest)1 GET (org.elasticsearch.rest.RestRequest.Method.GET)1 POST (org.elasticsearch.rest.RestRequest.Method.POST)1