Add request parameter 'cluster_manager_timeout' and deprecate 'master_timeout' - in Index Template APIs (#2678)
- Deprecate the request parameter `master_timeout` that used in Index Template APIs which have got the parameter. (The other Index APIs are addressed in PR https://github.com/opensearch-project/OpenSearch/pull/2660) - Add alternative new request parameter `cluster_manager_timeout`. - Add unit tests. Signed-off-by: Tianli Feng <ftianli@amazon.com>
This commit is contained in:
parent
ba8657aca5
commit
ba3ed8a9cb
|
@ -28,7 +28,15 @@
|
|||
},
|
||||
"master_timeout":{
|
||||
"type":"time",
|
||||
"description":"Specify timeout for connection to master"
|
||||
"description":"Specify timeout for connection to master node",
|
||||
"deprecated":{
|
||||
"version":"2.0.0",
|
||||
"description":"To support inclusive language, use 'cluster_manager_timeout' instead."
|
||||
}
|
||||
},
|
||||
"cluster_manager_timeout":{
|
||||
"type":"time",
|
||||
"description":"Specify timeout for connection to cluster-manager node"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,15 @@
|
|||
"params":{
|
||||
"master_timeout":{
|
||||
"type":"time",
|
||||
"description":"Explicit operation timeout for connection to master node"
|
||||
"description":"Explicit operation timeout for connection to master node",
|
||||
"deprecated":{
|
||||
"version":"2.0.0",
|
||||
"description":"To support inclusive language, use 'cluster_manager_timeout' instead."
|
||||
}
|
||||
},
|
||||
"cluster_manager_timeout":{
|
||||
"type":"time",
|
||||
"description":"Explicit operation timeout for connection to cluster-manager node"
|
||||
},
|
||||
"local":{
|
||||
"type":"boolean",
|
||||
|
|
|
@ -34,7 +34,15 @@
|
|||
},
|
||||
"master_timeout":{
|
||||
"type":"time",
|
||||
"description":"Specify timeout for connection to master"
|
||||
"description":"Specify timeout for connection to master node",
|
||||
"deprecated":{
|
||||
"version":"2.0.0",
|
||||
"description":"To support inclusive language, use 'cluster_manager_timeout' instead."
|
||||
}
|
||||
},
|
||||
"cluster_manager_timeout":{
|
||||
"type":"time",
|
||||
"description":"Specify timeout for connection to cluster-manager node"
|
||||
}
|
||||
},
|
||||
"body":{
|
||||
|
|
|
@ -28,7 +28,15 @@
|
|||
},
|
||||
"master_timeout":{
|
||||
"type":"time",
|
||||
"description":"Specify timeout for connection to master"
|
||||
"description":"Specify timeout for connection to master node",
|
||||
"deprecated":{
|
||||
"version":"2.0.0",
|
||||
"description":"To support inclusive language, use 'cluster_manager_timeout' instead."
|
||||
}
|
||||
},
|
||||
"cluster_manager_timeout":{
|
||||
"type":"time",
|
||||
"description":"Specify timeout for connection to cluster-manager node"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,15 @@
|
|||
},
|
||||
"master_timeout":{
|
||||
"type":"time",
|
||||
"description":"Specify timeout for connection to master"
|
||||
"description":"Specify timeout for connection to master node",
|
||||
"deprecated":{
|
||||
"version":"2.0.0",
|
||||
"description":"To support inclusive language, use 'cluster_manager_timeout' instead."
|
||||
}
|
||||
},
|
||||
"cluster_manager_timeout":{
|
||||
"type":"time",
|
||||
"description":"Specify timeout for connection to cluster-manager node"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,15 @@
|
|||
},
|
||||
"master_timeout":{
|
||||
"type":"time",
|
||||
"description":"Explicit operation timeout for connection to master node"
|
||||
"description":"Explicit operation timeout for connection to master node",
|
||||
"deprecated":{
|
||||
"version":"2.0.0",
|
||||
"description":"To support inclusive language, use 'cluster_manager_timeout' instead."
|
||||
}
|
||||
},
|
||||
"cluster_manager_timeout":{
|
||||
"type":"time",
|
||||
"description":"Explicit operation timeout for connection to cluster-manager node"
|
||||
},
|
||||
"local":{
|
||||
"type":"boolean",
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
"description":"Explicit operation timeout for connection to master node",
|
||||
"deprecated":{
|
||||
"version":"2.0.0",
|
||||
"description":"To promote inclusive language, use 'cluster_manager_timeout' instead."
|
||||
"description":"To support inclusive language, use 'cluster_manager_timeout' instead."
|
||||
}
|
||||
},
|
||||
"cluster_manager_timeout":{
|
||||
|
|
|
@ -35,7 +35,15 @@
|
|||
},
|
||||
"master_timeout":{
|
||||
"type":"time",
|
||||
"description":"Specify timeout for connection to master"
|
||||
"description":"Specify timeout for connection to master node",
|
||||
"deprecated":{
|
||||
"version":"2.0.0",
|
||||
"description":"To support inclusive language, use 'cluster_manager_timeout' instead."
|
||||
}
|
||||
},
|
||||
"cluster_manager_timeout":{
|
||||
"type":"time",
|
||||
"description":"Specify timeout for connection to cluster-manager node"
|
||||
}
|
||||
},
|
||||
"body":{
|
||||
|
|
|
@ -34,7 +34,15 @@
|
|||
},
|
||||
"master_timeout":{
|
||||
"type":"time",
|
||||
"description":"Specify timeout for connection to master"
|
||||
"description":"Specify timeout for connection to master node",
|
||||
"deprecated":{
|
||||
"version":"2.0.0",
|
||||
"description":"To support inclusive language, use 'cluster_manager_timeout' instead."
|
||||
}
|
||||
},
|
||||
"cluster_manager_timeout":{
|
||||
"type":"time",
|
||||
"description":"Specify timeout for connection to cluster-manager node"
|
||||
}
|
||||
},
|
||||
"body":{
|
||||
|
|
|
@ -34,7 +34,15 @@
|
|||
},
|
||||
"master_timeout":{
|
||||
"type":"time",
|
||||
"description":"Specify timeout for connection to master"
|
||||
"description":"Specify timeout for connection to master node",
|
||||
"deprecated":{
|
||||
"version":"2.0.0",
|
||||
"description":"To support inclusive language, use 'cluster_manager_timeout' instead."
|
||||
}
|
||||
},
|
||||
"cluster_manager_timeout":{
|
||||
"type":"time",
|
||||
"description":"Specify timeout for connection to cluster-manager node"
|
||||
}
|
||||
},
|
||||
"body":{
|
||||
|
|
|
@ -40,7 +40,15 @@
|
|||
},
|
||||
"master_timeout":{
|
||||
"type":"time",
|
||||
"description":"Specify timeout for connection to master"
|
||||
"description":"Specify timeout for connection to master node",
|
||||
"deprecated":{
|
||||
"version":"2.0.0",
|
||||
"description":"To support inclusive language, use 'cluster_manager_timeout' instead."
|
||||
}
|
||||
},
|
||||
"cluster_manager_timeout":{
|
||||
"type":"time",
|
||||
"description":"Specify timeout for connection to cluster-manager node"
|
||||
}
|
||||
},
|
||||
"body":{
|
||||
|
|
|
@ -169,7 +169,7 @@ setup:
|
|||
cluster.state:
|
||||
metric: [ master_node, version ]
|
||||
allowed_warnings:
|
||||
- 'Deprecated value [master_node] used for parameter [metric]. To promote inclusive language, please use [cluster_manager_node] instead. It will be unsupported in a future major version.'
|
||||
- 'Parameter [master_timeout] is deprecated and will be removed in 3.0. To support inclusive language, please use [cluster_manager_timeout] instead.'
|
||||
|
||||
- match: { cluster_uuid: $cluster_uuid }
|
||||
- is_true: master_node
|
||||
|
|
|
@ -6,6 +6,8 @@ setup:
|
|||
ignore: [404]
|
||||
---
|
||||
"Test indices.exists_template":
|
||||
- skip:
|
||||
features: allowed_warnings
|
||||
|
||||
- do:
|
||||
indices.exists_template:
|
||||
|
@ -23,6 +25,8 @@ setup:
|
|||
number_of_replicas: 0
|
||||
|
||||
- do:
|
||||
allowed_warnings:
|
||||
- "Parameter [master_timeout] is deprecated and will be removed in 3.0. To support inclusive language, please use [cluster_manager_timeout] instead."
|
||||
indices.exists_template:
|
||||
name: test
|
||||
master_timeout: 1m
|
||||
|
|
|
@ -72,8 +72,12 @@ setup:
|
|||
|
||||
---
|
||||
"Get template with flat settings and master timeout":
|
||||
- skip:
|
||||
features: allowed_warnings
|
||||
|
||||
- do:
|
||||
allowed_warnings:
|
||||
- "Parameter [master_timeout] is deprecated and will be removed in 3.0. To support inclusive language, please use [cluster_manager_timeout] instead."
|
||||
indices.get_template:
|
||||
name: test
|
||||
flat_settings: true
|
||||
|
|
|
@ -34,6 +34,7 @@ package org.opensearch.rest.action.admin.indices;
|
|||
|
||||
import org.opensearch.action.admin.indices.template.delete.DeleteComponentTemplateAction;
|
||||
import org.opensearch.client.node.NodeClient;
|
||||
import org.opensearch.common.logging.DeprecationLogger;
|
||||
import org.opensearch.rest.BaseRestHandler;
|
||||
import org.opensearch.rest.RestRequest;
|
||||
import org.opensearch.rest.action.RestToXContentListener;
|
||||
|
@ -46,6 +47,8 @@ import static org.opensearch.rest.RestRequest.Method.DELETE;
|
|||
|
||||
public class RestDeleteComponentTemplateAction extends BaseRestHandler {
|
||||
|
||||
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestDeleteComponentTemplateAction.class);
|
||||
|
||||
@Override
|
||||
public List<Route> routes() {
|
||||
return Collections.singletonList(new Route(DELETE, "/_component_template/{name}"));
|
||||
|
@ -60,7 +63,8 @@ public class RestDeleteComponentTemplateAction extends BaseRestHandler {
|
|||
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
|
||||
|
||||
DeleteComponentTemplateAction.Request deleteReq = new DeleteComponentTemplateAction.Request(request.param("name"));
|
||||
deleteReq.masterNodeTimeout(request.paramAsTime("master_timeout", deleteReq.masterNodeTimeout()));
|
||||
deleteReq.masterNodeTimeout(request.paramAsTime("cluster_manager_timeout", deleteReq.masterNodeTimeout()));
|
||||
parseDeprecatedMasterTimeoutParameter(deleteReq, request, deprecationLogger, getName());
|
||||
|
||||
return channel -> client.execute(DeleteComponentTemplateAction.INSTANCE, deleteReq, new RestToXContentListener<>(channel));
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ package org.opensearch.rest.action.admin.indices;
|
|||
|
||||
import org.opensearch.action.admin.indices.template.delete.DeleteComposableIndexTemplateAction;
|
||||
import org.opensearch.client.node.NodeClient;
|
||||
import org.opensearch.common.logging.DeprecationLogger;
|
||||
import org.opensearch.rest.BaseRestHandler;
|
||||
import org.opensearch.rest.RestRequest;
|
||||
import org.opensearch.rest.action.RestToXContentListener;
|
||||
|
@ -46,6 +47,8 @@ import static org.opensearch.rest.RestRequest.Method.DELETE;
|
|||
|
||||
public class RestDeleteComposableIndexTemplateAction extends BaseRestHandler {
|
||||
|
||||
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestDeleteComposableIndexTemplateAction.class);
|
||||
|
||||
@Override
|
||||
public List<Route> routes() {
|
||||
return Collections.singletonList(new Route(DELETE, "/_index_template/{name}"));
|
||||
|
@ -60,7 +63,8 @@ public class RestDeleteComposableIndexTemplateAction extends BaseRestHandler {
|
|||
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
|
||||
|
||||
DeleteComposableIndexTemplateAction.Request deleteReq = new DeleteComposableIndexTemplateAction.Request(request.param("name"));
|
||||
deleteReq.masterNodeTimeout(request.paramAsTime("master_timeout", deleteReq.masterNodeTimeout()));
|
||||
deleteReq.masterNodeTimeout(request.paramAsTime("cluster_manager_timeout", deleteReq.masterNodeTimeout()));
|
||||
parseDeprecatedMasterTimeoutParameter(deleteReq, request, deprecationLogger, getName());
|
||||
|
||||
return channel -> client.execute(DeleteComposableIndexTemplateAction.INSTANCE, deleteReq, new RestToXContentListener<>(channel));
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ package org.opensearch.rest.action.admin.indices;
|
|||
|
||||
import org.opensearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest;
|
||||
import org.opensearch.client.node.NodeClient;
|
||||
import org.opensearch.common.logging.DeprecationLogger;
|
||||
import org.opensearch.rest.BaseRestHandler;
|
||||
import org.opensearch.rest.RestRequest;
|
||||
import org.opensearch.rest.action.RestToXContentListener;
|
||||
|
@ -45,6 +46,8 @@ import static org.opensearch.rest.RestRequest.Method.DELETE;
|
|||
|
||||
public class RestDeleteIndexTemplateAction extends BaseRestHandler {
|
||||
|
||||
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestDeleteIndexTemplateAction.class);
|
||||
|
||||
@Override
|
||||
public List<Route> routes() {
|
||||
return singletonList(new Route(DELETE, "/_template/{name}"));
|
||||
|
@ -58,7 +61,10 @@ public class RestDeleteIndexTemplateAction extends BaseRestHandler {
|
|||
@Override
|
||||
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
|
||||
DeleteIndexTemplateRequest deleteIndexTemplateRequest = new DeleteIndexTemplateRequest(request.param("name"));
|
||||
deleteIndexTemplateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", deleteIndexTemplateRequest.masterNodeTimeout()));
|
||||
deleteIndexTemplateRequest.masterNodeTimeout(
|
||||
request.paramAsTime("cluster_manager_timeout", deleteIndexTemplateRequest.masterNodeTimeout())
|
||||
);
|
||||
parseDeprecatedMasterTimeoutParameter(deleteIndexTemplateRequest, request, deprecationLogger, getName());
|
||||
return channel -> client.admin().indices().deleteTemplate(deleteIndexTemplateRequest, new RestToXContentListener<>(channel));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ package org.opensearch.rest.action.admin.indices;
|
|||
|
||||
import org.opensearch.action.admin.indices.template.get.GetComponentTemplateAction;
|
||||
import org.opensearch.client.node.NodeClient;
|
||||
import org.opensearch.common.logging.DeprecationLogger;
|
||||
import org.opensearch.common.settings.Settings;
|
||||
import org.opensearch.rest.BaseRestHandler;
|
||||
import org.opensearch.rest.RestRequest;
|
||||
|
@ -52,6 +53,8 @@ import static org.opensearch.rest.RestStatus.OK;
|
|||
|
||||
public class RestGetComponentTemplateAction extends BaseRestHandler {
|
||||
|
||||
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestGetComponentTemplateAction.class);
|
||||
|
||||
@Override
|
||||
public List<Route> routes() {
|
||||
return Arrays.asList(
|
||||
|
@ -72,7 +75,8 @@ public class RestGetComponentTemplateAction extends BaseRestHandler {
|
|||
final GetComponentTemplateAction.Request getRequest = new GetComponentTemplateAction.Request(request.param("name"));
|
||||
|
||||
getRequest.local(request.paramAsBoolean("local", getRequest.local()));
|
||||
getRequest.masterNodeTimeout(request.paramAsTime("master_timeout", getRequest.masterNodeTimeout()));
|
||||
getRequest.masterNodeTimeout(request.paramAsTime("cluster_manager_timeout", getRequest.masterNodeTimeout()));
|
||||
parseDeprecatedMasterTimeoutParameter(getRequest, request, deprecationLogger, getName());
|
||||
|
||||
final boolean implicitAll = getRequest.name() == null;
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ package org.opensearch.rest.action.admin.indices;
|
|||
|
||||
import org.opensearch.action.admin.indices.template.get.GetComposableIndexTemplateAction;
|
||||
import org.opensearch.client.node.NodeClient;
|
||||
import org.opensearch.common.logging.DeprecationLogger;
|
||||
import org.opensearch.common.settings.Settings;
|
||||
import org.opensearch.rest.BaseRestHandler;
|
||||
import org.opensearch.rest.RestRequest;
|
||||
|
@ -52,6 +53,8 @@ import static org.opensearch.rest.RestStatus.OK;
|
|||
|
||||
public class RestGetComposableIndexTemplateAction extends BaseRestHandler {
|
||||
|
||||
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestGetComposableIndexTemplateAction.class);
|
||||
|
||||
@Override
|
||||
public List<Route> routes() {
|
||||
return Arrays.asList(
|
||||
|
@ -71,7 +74,8 @@ public class RestGetComposableIndexTemplateAction extends BaseRestHandler {
|
|||
final GetComposableIndexTemplateAction.Request getRequest = new GetComposableIndexTemplateAction.Request(request.param("name"));
|
||||
|
||||
getRequest.local(request.paramAsBoolean("local", getRequest.local()));
|
||||
getRequest.masterNodeTimeout(request.paramAsTime("master_timeout", getRequest.masterNodeTimeout()));
|
||||
getRequest.masterNodeTimeout(request.paramAsTime("cluster_manager_timeout", getRequest.masterNodeTimeout()));
|
||||
parseDeprecatedMasterTimeoutParameter(getRequest, request, deprecationLogger, getName());
|
||||
|
||||
final boolean implicitAll = getRequest.name() == null;
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.opensearch.action.admin.indices.template.get.GetIndexTemplatesRequest
|
|||
import org.opensearch.action.admin.indices.template.get.GetIndexTemplatesResponse;
|
||||
import org.opensearch.client.node.NodeClient;
|
||||
import org.opensearch.common.Strings;
|
||||
import org.opensearch.common.logging.DeprecationLogger;
|
||||
import org.opensearch.common.settings.Settings;
|
||||
import org.opensearch.rest.BaseRestHandler;
|
||||
import org.opensearch.rest.RestRequest;
|
||||
|
@ -58,6 +59,8 @@ import static org.opensearch.rest.RestStatus.OK;
|
|||
*/
|
||||
public class RestGetIndexTemplateAction extends BaseRestHandler {
|
||||
|
||||
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestGetIndexTemplateAction.class);
|
||||
|
||||
@Override
|
||||
public List<Route> routes() {
|
||||
return unmodifiableList(
|
||||
|
@ -76,7 +79,10 @@ public class RestGetIndexTemplateAction extends BaseRestHandler {
|
|||
|
||||
final GetIndexTemplatesRequest getIndexTemplatesRequest = new GetIndexTemplatesRequest(names);
|
||||
getIndexTemplatesRequest.local(request.paramAsBoolean("local", getIndexTemplatesRequest.local()));
|
||||
getIndexTemplatesRequest.masterNodeTimeout(request.paramAsTime("master_timeout", getIndexTemplatesRequest.masterNodeTimeout()));
|
||||
getIndexTemplatesRequest.masterNodeTimeout(
|
||||
request.paramAsTime("cluster_manager_timeout", getIndexTemplatesRequest.masterNodeTimeout())
|
||||
);
|
||||
parseDeprecatedMasterTimeoutParameter(getIndexTemplatesRequest, request, deprecationLogger, getName());
|
||||
|
||||
final boolean implicitAll = getIndexTemplatesRequest.names().length == 0;
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ package org.opensearch.rest.action.admin.indices;
|
|||
import org.opensearch.action.admin.indices.template.put.PutComponentTemplateAction;
|
||||
import org.opensearch.client.node.NodeClient;
|
||||
import org.opensearch.cluster.metadata.ComponentTemplate;
|
||||
import org.opensearch.common.logging.DeprecationLogger;
|
||||
import org.opensearch.rest.BaseRestHandler;
|
||||
import org.opensearch.rest.RestRequest;
|
||||
import org.opensearch.rest.action.RestToXContentListener;
|
||||
|
@ -48,6 +49,8 @@ import static org.opensearch.rest.RestRequest.Method.PUT;
|
|||
|
||||
public class RestPutComponentTemplateAction extends BaseRestHandler {
|
||||
|
||||
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestPutComponentTemplateAction.class);
|
||||
|
||||
@Override
|
||||
public List<Route> routes() {
|
||||
return Arrays.asList(new Route(POST, "/_component_template/{name}"), new Route(PUT, "/_component_template/{name}"));
|
||||
|
@ -62,7 +65,8 @@ public class RestPutComponentTemplateAction extends BaseRestHandler {
|
|||
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
|
||||
|
||||
PutComponentTemplateAction.Request putRequest = new PutComponentTemplateAction.Request(request.param("name"));
|
||||
putRequest.masterNodeTimeout(request.paramAsTime("master_timeout", putRequest.masterNodeTimeout()));
|
||||
putRequest.masterNodeTimeout(request.paramAsTime("cluster_manager_timeout", putRequest.masterNodeTimeout()));
|
||||
parseDeprecatedMasterTimeoutParameter(putRequest, request, deprecationLogger, getName());
|
||||
putRequest.create(request.paramAsBoolean("create", false));
|
||||
putRequest.cause(request.param("cause", "api"));
|
||||
putRequest.componentTemplate(ComponentTemplate.parse(request.contentParser()));
|
||||
|
|
|
@ -35,6 +35,7 @@ package org.opensearch.rest.action.admin.indices;
|
|||
import org.opensearch.action.admin.indices.template.put.PutComposableIndexTemplateAction;
|
||||
import org.opensearch.client.node.NodeClient;
|
||||
import org.opensearch.cluster.metadata.ComposableIndexTemplate;
|
||||
import org.opensearch.common.logging.DeprecationLogger;
|
||||
import org.opensearch.rest.BaseRestHandler;
|
||||
import org.opensearch.rest.RestRequest;
|
||||
import org.opensearch.rest.action.RestToXContentListener;
|
||||
|
@ -48,6 +49,8 @@ import static org.opensearch.rest.RestRequest.Method.PUT;
|
|||
|
||||
public class RestPutComposableIndexTemplateAction extends BaseRestHandler {
|
||||
|
||||
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestPutComposableIndexTemplateAction.class);
|
||||
|
||||
@Override
|
||||
public List<Route> routes() {
|
||||
return Arrays.asList(new Route(POST, "/_index_template/{name}"), new Route(PUT, "/_index_template/{name}"));
|
||||
|
@ -62,7 +65,8 @@ public class RestPutComposableIndexTemplateAction extends BaseRestHandler {
|
|||
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
|
||||
|
||||
PutComposableIndexTemplateAction.Request putRequest = new PutComposableIndexTemplateAction.Request(request.param("name"));
|
||||
putRequest.masterNodeTimeout(request.paramAsTime("master_timeout", putRequest.masterNodeTimeout()));
|
||||
putRequest.masterNodeTimeout(request.paramAsTime("cluster_manager_timeout", putRequest.masterNodeTimeout()));
|
||||
parseDeprecatedMasterTimeoutParameter(putRequest, request, deprecationLogger, getName());
|
||||
putRequest.create(request.paramAsBoolean("create", false));
|
||||
putRequest.cause(request.param("cause", "api"));
|
||||
putRequest.indexTemplate(ComposableIndexTemplate.parse(request.contentParser()));
|
||||
|
|
|
@ -78,7 +78,8 @@ public class RestPutIndexTemplateAction extends BaseRestHandler {
|
|||
putRequest.patterns(Arrays.asList(request.paramAsStringArray("index_patterns", Strings.EMPTY_ARRAY)));
|
||||
}
|
||||
putRequest.order(request.paramAsInt("order", putRequest.order()));
|
||||
putRequest.masterNodeTimeout(request.paramAsTime("master_timeout", putRequest.masterNodeTimeout()));
|
||||
putRequest.masterNodeTimeout(request.paramAsTime("cluster_manager_timeout", putRequest.masterNodeTimeout()));
|
||||
parseDeprecatedMasterTimeoutParameter(putRequest, request, deprecationLogger, getName());
|
||||
putRequest.create(request.paramAsBoolean("create", false));
|
||||
putRequest.cause(request.param("cause", ""));
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ import org.opensearch.action.admin.indices.template.post.SimulateIndexTemplateRe
|
|||
import org.opensearch.action.admin.indices.template.put.PutComposableIndexTemplateAction;
|
||||
import org.opensearch.client.node.NodeClient;
|
||||
import org.opensearch.cluster.metadata.ComposableIndexTemplate;
|
||||
import org.opensearch.common.logging.DeprecationLogger;
|
||||
import org.opensearch.rest.BaseRestHandler;
|
||||
import org.opensearch.rest.RestRequest;
|
||||
import org.opensearch.rest.action.RestToXContentListener;
|
||||
|
@ -48,6 +49,8 @@ import static org.opensearch.rest.RestRequest.Method.POST;
|
|||
|
||||
public class RestSimulateIndexTemplateAction extends BaseRestHandler {
|
||||
|
||||
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestSimulateIndexTemplateAction.class);
|
||||
|
||||
@Override
|
||||
public List<Route> routes() {
|
||||
return org.opensearch.common.collect.List.of(new Route(POST, "/_index_template/_simulate_index/{name}"));
|
||||
|
@ -62,8 +65,9 @@ public class RestSimulateIndexTemplateAction extends BaseRestHandler {
|
|||
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
|
||||
SimulateIndexTemplateRequest simulateIndexTemplateRequest = new SimulateIndexTemplateRequest(request.param("name"));
|
||||
simulateIndexTemplateRequest.masterNodeTimeout(
|
||||
request.paramAsTime("master_timeout", simulateIndexTemplateRequest.masterNodeTimeout())
|
||||
request.paramAsTime("cluster_manager_timeout", simulateIndexTemplateRequest.masterNodeTimeout())
|
||||
);
|
||||
parseDeprecatedMasterTimeoutParameter(simulateIndexTemplateRequest, request, deprecationLogger, getName());
|
||||
if (request.hasContent()) {
|
||||
PutComposableIndexTemplateAction.Request indexTemplateRequest = new PutComposableIndexTemplateAction.Request(
|
||||
"simulating_template"
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.opensearch.action.admin.indices.template.post.SimulateTemplateAction;
|
|||
import org.opensearch.action.admin.indices.template.put.PutComposableIndexTemplateAction;
|
||||
import org.opensearch.client.node.NodeClient;
|
||||
import org.opensearch.cluster.metadata.ComposableIndexTemplate;
|
||||
import org.opensearch.common.logging.DeprecationLogger;
|
||||
import org.opensearch.rest.BaseRestHandler;
|
||||
import org.opensearch.rest.RestRequest;
|
||||
import org.opensearch.rest.action.RestToXContentListener;
|
||||
|
@ -47,6 +48,8 @@ import java.util.List;
|
|||
import static org.opensearch.rest.RestRequest.Method.POST;
|
||||
|
||||
public class RestSimulateTemplateAction extends BaseRestHandler {
|
||||
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestSimulateTemplateAction.class);
|
||||
|
||||
@Override
|
||||
public List<Route> routes() {
|
||||
return Arrays.asList(new Route(POST, "/_index_template/_simulate"), new Route(POST, "/_index_template/_simulate/{name}"));
|
||||
|
@ -58,7 +61,7 @@ public class RestSimulateTemplateAction extends BaseRestHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
|
||||
public RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
|
||||
SimulateTemplateAction.Request simulateRequest = new SimulateTemplateAction.Request();
|
||||
simulateRequest.templateName(request.param("name"));
|
||||
if (request.hasContent()) {
|
||||
|
@ -71,7 +74,8 @@ public class RestSimulateTemplateAction extends BaseRestHandler {
|
|||
|
||||
simulateRequest.indexTemplateRequest(indexTemplateRequest);
|
||||
}
|
||||
simulateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", simulateRequest.masterNodeTimeout()));
|
||||
simulateRequest.masterNodeTimeout(request.paramAsTime("cluster_manager_timeout", simulateRequest.masterNodeTimeout()));
|
||||
parseDeprecatedMasterTimeoutParameter(simulateRequest, request, deprecationLogger, getName());
|
||||
|
||||
return channel -> client.execute(SimulateTemplateAction.INSTANCE, simulateRequest, new RestToXContentListener<>(channel));
|
||||
}
|
||||
|
|
|
@ -41,6 +41,17 @@ import org.opensearch.rest.action.admin.indices.RestPutMappingAction;
|
|||
import org.opensearch.rest.action.admin.indices.RestResizeHandler;
|
||||
import org.opensearch.rest.action.admin.indices.RestRolloverIndexAction;
|
||||
import org.opensearch.rest.action.admin.indices.RestUpdateSettingsAction;
|
||||
import org.opensearch.rest.action.admin.indices.RestDeleteComponentTemplateAction;
|
||||
import org.opensearch.rest.action.admin.indices.RestDeleteComposableIndexTemplateAction;
|
||||
import org.opensearch.rest.action.admin.indices.RestDeleteIndexTemplateAction;
|
||||
import org.opensearch.rest.action.admin.indices.RestGetComponentTemplateAction;
|
||||
import org.opensearch.rest.action.admin.indices.RestGetComposableIndexTemplateAction;
|
||||
import org.opensearch.rest.action.admin.indices.RestGetIndexTemplateAction;
|
||||
import org.opensearch.rest.action.admin.indices.RestPutComponentTemplateAction;
|
||||
import org.opensearch.rest.action.admin.indices.RestPutComposableIndexTemplateAction;
|
||||
import org.opensearch.rest.action.admin.indices.RestPutIndexTemplateAction;
|
||||
import org.opensearch.rest.action.admin.indices.RestSimulateIndexTemplateAction;
|
||||
import org.opensearch.rest.action.admin.indices.RestSimulateTemplateAction;
|
||||
import org.opensearch.rest.action.cat.RestAllocationAction;
|
||||
import org.opensearch.rest.action.cat.RestRepositoriesAction;
|
||||
import org.opensearch.rest.action.cat.RestThreadPoolAction;
|
||||
|
@ -425,6 +436,87 @@ public class RenamedTimeoutRequestParameterTests extends OpenSearchTestCase {
|
|||
assertWarnings(MASTER_TIMEOUT_DEPRECATED_MESSAGE);
|
||||
}
|
||||
|
||||
public void testDeleteComponentTemplate() {
|
||||
RestDeleteComponentTemplateAction action = new RestDeleteComponentTemplateAction();
|
||||
Exception e = assertThrows(OpenSearchParseException.class, () -> action.prepareRequest(getRestRequestWithBothParams(), client));
|
||||
assertThat(e.getMessage(), containsString(DUPLICATE_PARAMETER_ERROR_MESSAGE));
|
||||
assertWarnings(MASTER_TIMEOUT_DEPRECATED_MESSAGE);
|
||||
}
|
||||
|
||||
public void testDeleteComposableIndexTemplate() {
|
||||
RestDeleteComposableIndexTemplateAction action = new RestDeleteComposableIndexTemplateAction();
|
||||
Exception e = assertThrows(OpenSearchParseException.class, () -> action.prepareRequest(getRestRequestWithBothParams(), client));
|
||||
assertThat(e.getMessage(), containsString(DUPLICATE_PARAMETER_ERROR_MESSAGE));
|
||||
assertWarnings(MASTER_TIMEOUT_DEPRECATED_MESSAGE);
|
||||
}
|
||||
|
||||
public void testDeleteIndexTemplate() {
|
||||
RestDeleteIndexTemplateAction action = new RestDeleteIndexTemplateAction();
|
||||
Exception e = assertThrows(OpenSearchParseException.class, () -> action.prepareRequest(getRestRequestWithBothParams(), client));
|
||||
assertThat(e.getMessage(), containsString(DUPLICATE_PARAMETER_ERROR_MESSAGE));
|
||||
assertWarnings(MASTER_TIMEOUT_DEPRECATED_MESSAGE);
|
||||
}
|
||||
|
||||
public void testGetComponentTemplate() {
|
||||
RestGetComponentTemplateAction action = new RestGetComponentTemplateAction();
|
||||
Exception e = assertThrows(OpenSearchParseException.class, () -> action.prepareRequest(getRestRequestWithBothParams(), client));
|
||||
assertThat(e.getMessage(), containsString(DUPLICATE_PARAMETER_ERROR_MESSAGE));
|
||||
assertWarnings(MASTER_TIMEOUT_DEPRECATED_MESSAGE);
|
||||
}
|
||||
|
||||
public void testGetComposableIndexTemplate() {
|
||||
RestGetComposableIndexTemplateAction action = new RestGetComposableIndexTemplateAction();
|
||||
Exception e = assertThrows(OpenSearchParseException.class, () -> action.prepareRequest(getRestRequestWithBothParams(), client));
|
||||
assertThat(e.getMessage(), containsString(DUPLICATE_PARAMETER_ERROR_MESSAGE));
|
||||
assertWarnings(MASTER_TIMEOUT_DEPRECATED_MESSAGE);
|
||||
}
|
||||
|
||||
public void testGetIndexTemplate() {
|
||||
RestGetIndexTemplateAction action = new RestGetIndexTemplateAction();
|
||||
Exception e = assertThrows(OpenSearchParseException.class, () -> action.prepareRequest(getRestRequestWithBothParams(), client));
|
||||
assertThat(e.getMessage(), containsString(DUPLICATE_PARAMETER_ERROR_MESSAGE));
|
||||
assertWarnings(MASTER_TIMEOUT_DEPRECATED_MESSAGE);
|
||||
}
|
||||
|
||||
public void testPutComponentTemplate() {
|
||||
RestPutComponentTemplateAction action = new RestPutComponentTemplateAction();
|
||||
Exception e = assertThrows(OpenSearchParseException.class, () -> action.prepareRequest(getRestRequestWithBothParams(), client));
|
||||
assertThat(e.getMessage(), containsString(DUPLICATE_PARAMETER_ERROR_MESSAGE));
|
||||
assertWarnings(MASTER_TIMEOUT_DEPRECATED_MESSAGE);
|
||||
}
|
||||
|
||||
public void testPutComposableIndexTemplate() {
|
||||
RestPutComposableIndexTemplateAction action = new RestPutComposableIndexTemplateAction();
|
||||
Exception e = assertThrows(OpenSearchParseException.class, () -> action.prepareRequest(getRestRequestWithBothParams(), client));
|
||||
assertThat(e.getMessage(), containsString(DUPLICATE_PARAMETER_ERROR_MESSAGE));
|
||||
assertWarnings(MASTER_TIMEOUT_DEPRECATED_MESSAGE);
|
||||
}
|
||||
|
||||
public void testPutIndexTemplate() {
|
||||
RestPutIndexTemplateAction action = new RestPutIndexTemplateAction();
|
||||
Exception e = assertThrows(OpenSearchParseException.class, () -> action.prepareRequest(getRestRequestWithBothParams(), client));
|
||||
assertThat(e.getMessage(), containsString(DUPLICATE_PARAMETER_ERROR_MESSAGE));
|
||||
assertWarnings(MASTER_TIMEOUT_DEPRECATED_MESSAGE);
|
||||
}
|
||||
|
||||
public void testSimulateIndexTemplate() {
|
||||
FakeRestRequest request = new FakeRestRequest();
|
||||
request.params().put("cluster_manager_timeout", randomFrom("1h", "2m"));
|
||||
request.params().put("master_timeout", "3s");
|
||||
request.params().put("name", "test");
|
||||
RestSimulateIndexTemplateAction action = new RestSimulateIndexTemplateAction();
|
||||
Exception e = assertThrows(OpenSearchParseException.class, () -> action.prepareRequest(request, client));
|
||||
assertThat(e.getMessage(), containsString(DUPLICATE_PARAMETER_ERROR_MESSAGE));
|
||||
assertWarnings(MASTER_TIMEOUT_DEPRECATED_MESSAGE);
|
||||
}
|
||||
|
||||
public void testSimulateTemplate() {
|
||||
RestSimulateTemplateAction action = new RestSimulateTemplateAction();
|
||||
Exception e = assertThrows(OpenSearchParseException.class, () -> action.prepareRequest(getRestRequestWithBothParams(), client));
|
||||
assertThat(e.getMessage(), containsString(DUPLICATE_PARAMETER_ERROR_MESSAGE));
|
||||
assertWarnings(MASTER_TIMEOUT_DEPRECATED_MESSAGE);
|
||||
}
|
||||
|
||||
private MasterNodeRequest getMasterNodeRequest() {
|
||||
return new MasterNodeRequest() {
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue