|
@@ -19,11 +19,13 @@
|
|
|
|
|
|
package org.elasticsearch.rest.action.admin.indices;
|
|
|
|
|
|
+import org.elasticsearch.Version;
|
|
|
import org.elasticsearch.action.admin.indices.close.CloseIndexRequest;
|
|
|
import org.elasticsearch.action.support.ActiveShardCount;
|
|
|
import org.elasticsearch.action.support.IndicesOptions;
|
|
|
import org.elasticsearch.client.node.NodeClient;
|
|
|
import org.elasticsearch.common.Strings;
|
|
|
+import org.elasticsearch.common.logging.DeprecationLogger;
|
|
|
import org.elasticsearch.rest.BaseRestHandler;
|
|
|
import org.elasticsearch.rest.RestRequest;
|
|
|
import org.elasticsearch.rest.action.RestToXContentListener;
|
|
@@ -35,6 +37,8 @@ import static org.elasticsearch.rest.RestRequest.Method.POST;
|
|
|
|
|
|
public class RestCloseIndexAction extends BaseRestHandler {
|
|
|
|
|
|
+ private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestCloseIndexAction.class);
|
|
|
+
|
|
|
@Override
|
|
|
public List<Route> routes() {
|
|
|
return List.of(
|
|
@@ -54,7 +58,17 @@ public class RestCloseIndexAction extends BaseRestHandler {
|
|
|
closeIndexRequest.timeout(request.paramAsTime("timeout", closeIndexRequest.timeout()));
|
|
|
closeIndexRequest.indicesOptions(IndicesOptions.fromRequest(request, closeIndexRequest.indicesOptions()));
|
|
|
String waitForActiveShards = request.param("wait_for_active_shards");
|
|
|
- if (waitForActiveShards != null) {
|
|
|
+ if ("index-setting".equalsIgnoreCase(waitForActiveShards)) {
|
|
|
+ deprecationLogger.deprecate("close-index-wait_for_active_shards-index-setting",
|
|
|
+ "?wait_for_active_shards=index-setting is now the default behaviour; the 'index-setting' value for this parameter " +
|
|
|
+ "should no longer be used since it will become unsupported in version " + (Version.V_7_0_0.major + 2));
|
|
|
+ // TODO in v9:
|
|
|
+ // - throw an IllegalArgumentException here
|
|
|
+ // - record the removal of support for this value as a breaking change.
|
|
|
+ // - mention Version.V_8_0_0 in the code to ensure that we revisit this in v10
|
|
|
+ // TODO in v10:
|
|
|
+ // - remove the IllegalArgumentException here
|
|
|
+ } else if (waitForActiveShards != null) {
|
|
|
closeIndexRequest.waitForActiveShards(ActiveShardCount.parseString(waitForActiveShards));
|
|
|
}
|
|
|
return channel -> client.admin().indices().close(closeIndexRequest, new RestToXContentListener<>(channel));
|