diff --git a/server/src/main/java/org/opensearch/action/support/master/MasterNodeRequest.java b/server/src/main/java/org/opensearch/action/support/master/MasterNodeRequest.java index d5be6c48e23b8..55d5048f14d13 100644 --- a/server/src/main/java/org/opensearch/action/support/master/MasterNodeRequest.java +++ b/server/src/main/java/org/opensearch/action/support/master/MasterNodeRequest.java @@ -44,9 +44,15 @@ */ public abstract class MasterNodeRequest> extends ActionRequest { + /** + * @deprecated As of 2.0, because promoting inclusive language, replaced by {@link #DEFAULT_CLUSTER_MANAGER_NODE_TIMEOUT} + */ + @Deprecated public static final TimeValue DEFAULT_MASTER_NODE_TIMEOUT = TimeValue.timeValueSeconds(30); - protected TimeValue masterNodeTimeout = DEFAULT_MASTER_NODE_TIMEOUT; + public static final TimeValue DEFAULT_CLUSTER_MANAGER_NODE_TIMEOUT = TimeValue.timeValueSeconds(30); + + protected TimeValue masterNodeTimeout = DEFAULT_CLUSTER_MANAGER_NODE_TIMEOUT; protected MasterNodeRequest() {} @@ -63,21 +69,49 @@ public void writeTo(StreamOutput out) throws IOException { /** * A timeout value in case the master has not been discovered yet or disconnected. + * @deprecated As of 2.0, because promoting inclusive language, replaced by {@link #clusterManagerNodeTimeout} */ + @Deprecated @SuppressWarnings("unchecked") public final Request masterNodeTimeout(TimeValue timeout) { this.masterNodeTimeout = timeout; return (Request) this; } + /** + * A timeout value in case the cluster manager has not been discovered yet or disconnected. + */ + @SuppressWarnings("unchecked") + public final Request clusterManagerNodeTimeout(TimeValue timeout) { + this.masterNodeTimeout = timeout; + return (Request) this; + } + /** * A timeout value in case the master has not been discovered yet or disconnected. + * @deprecated As of 2.0, because promoting inclusive language, replaced by {@link #clusterManagerNodeTimeout} */ + @Deprecated public final Request masterNodeTimeout(String timeout) { return masterNodeTimeout(TimeValue.parseTimeValue(timeout, null, getClass().getSimpleName() + ".masterNodeTimeout")); } + /** + * A timeout value in case the cluster manager has not been discovered yet or disconnected. + */ + public final Request clusterManagerNodeTimeout(String timeout) { + return clusterManagerNodeTimeout(TimeValue.parseTimeValue(timeout, null, getClass().getSimpleName() + ".masterNodeTimeout")); + } + + /** + * @deprecated As of 2.0, because promoting inclusive language, replaced by {@link #clusterManagerNodeTimeout} + */ + @Deprecated public final TimeValue masterNodeTimeout() { return this.masterNodeTimeout; } + + public final TimeValue clusterManagerNodeTimeout() { + return this.masterNodeTimeout; + } } diff --git a/server/src/main/java/org/opensearch/rest/RestRequest.java b/server/src/main/java/org/opensearch/rest/RestRequest.java index 7d11da7e122cd..dabcea154ba1d 100644 --- a/server/src/main/java/org/opensearch/rest/RestRequest.java +++ b/server/src/main/java/org/opensearch/rest/RestRequest.java @@ -54,6 +54,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -578,6 +579,31 @@ public static XContentType parseContentType(List header) { throw new IllegalArgumentException("empty Content-Type header"); } + /** + * The method is only used to validate whether the values of the 2 request parameters "master_timeout" and "cluster_manager_timeout" is the same value or not. + * If the 2 values are not the same, throw an {@link OpenSearchParseException}. + * @param keys Keys of the request parameters. + * @deprecated The method will be removed along with the request parameter "master_timeout". + */ + @Deprecated + public void validateParamValuesAreEqual(String... keys) { + // Filter the non-null values of the parameters with the key, and get the distinct values. + Set set = new HashSet<>(); + for (String key : keys) { + String value = param(key); + if (value != null) { + set.add(value); + } + } + // If there are more than 1 distinct value of the request parameters, throw an exception. + if (set.size() > 1) { + throw new OpenSearchParseException( + "The values of the request parameters: {} are required to be equal, otherwise please only assign value to one of the request parameters.", + Arrays.toString(keys) + ); + } + } + public static class ContentTypeHeaderException extends RuntimeException { ContentTypeHeaderException(final IllegalArgumentException cause) { diff --git a/server/src/main/java/org/opensearch/rest/action/cat/RestPluginsAction.java b/server/src/main/java/org/opensearch/rest/action/cat/RestPluginsAction.java index 79cac0f906c74..5058967bc55dc 100644 --- a/server/src/main/java/org/opensearch/rest/action/cat/RestPluginsAction.java +++ b/server/src/main/java/org/opensearch/rest/action/cat/RestPluginsAction.java @@ -76,6 +76,9 @@ public RestChannelConsumer doCatRequest(final RestRequest request, final NodeCli clusterStateRequest.clear().nodes(true); clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local())); clusterStateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout())); + // Add "cluster_manager_timeout" as the alternative to "master_timeout", for promoting inclusive language. + request.validateParamValuesAreEqual("master_timeout", "cluster_manager_timeout"); + clusterStateRequest.masterNodeTimeout(request.paramAsTime("cluster_manager_timeout", clusterStateRequest.masterNodeTimeout())); return channel -> client.admin().cluster().state(clusterStateRequest, new RestActionListener(channel) { @Override