From d2fe0efbaece27df9be55f4755b7238b4ebfd0e0 Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Thu, 21 Jul 2022 22:57:32 -0700 Subject: [PATCH] Deprecate public methods and variables that contain 'master' terminology in 'client' directory (#3966) * Deprecate public methods and variables that contain 'master' terminology in 'client' directory Signed-off-by: Tianli Feng * Change 1 String type usages with 'master' to 'cluster manager' Signed-off-by: Tianli Feng --- .../client/ClusterRequestConverters.java | 4 +-- .../client/IndicesRequestConverters.java | 22 ++++++------ .../org/opensearch/client/TimedRequest.java | 30 +++++++++++++--- .../indices/GetComponentTemplatesRequest.java | 34 ++++++++++++++++--- .../GetComposableIndexTemplateRequest.java | 34 ++++++++++++++++--- .../indices/GetIndexTemplatesRequest.java | 34 ++++++++++++++++--- .../opensearch/client/TimedRequestTests.java | 6 ++-- .../ClusterClientDocumentationIT.java | 8 ++--- .../IndicesClientDocumentationIT.java | 28 +++++++-------- .../indices/CloseIndexRequestTests.java | 6 ++-- .../main/java/org/opensearch/client/Node.java | 11 +++++- .../org/opensearch/client/NodeSelector.java | 6 ++-- .../sniff/OpenSearchNodesSnifferTests.java | 2 +- 13 files changed, 165 insertions(+), 60 deletions(-) diff --git a/client/rest-high-level/src/main/java/org/opensearch/client/ClusterRequestConverters.java b/client/rest-high-level/src/main/java/org/opensearch/client/ClusterRequestConverters.java index a912ae8ece3f5..9a386fe732adb 100644 --- a/client/rest-high-level/src/main/java/org/opensearch/client/ClusterRequestConverters.java +++ b/client/rest-high-level/src/main/java/org/opensearch/client/ClusterRequestConverters.java @@ -105,7 +105,7 @@ static Request putComponentTemplate(PutComponentTemplateRequest putComponentTemp .build(); Request request = new Request(HttpPut.METHOD_NAME, endpoint); RequestConverters.Params params = new RequestConverters.Params(); - params.withMasterTimeout(putComponentTemplateRequest.masterNodeTimeout()); + params.withMasterTimeout(putComponentTemplateRequest.clusterManagerNodeTimeout()); if (putComponentTemplateRequest.create()) { params.putParam("create", Boolean.TRUE.toString()); } @@ -146,7 +146,7 @@ static Request deleteComponentTemplate(DeleteComponentTemplateRequest deleteComp String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_component_template").addPathPart(name).build(); Request request = new Request(HttpDelete.METHOD_NAME, endpoint); RequestConverters.Params params = new RequestConverters.Params(); - params.withMasterTimeout(deleteComponentTemplateRequest.masterNodeTimeout()); + params.withMasterTimeout(deleteComponentTemplateRequest.clusterManagerNodeTimeout()); request.addParameters(params.asMap()); return request; } diff --git a/client/rest-high-level/src/main/java/org/opensearch/client/IndicesRequestConverters.java b/client/rest-high-level/src/main/java/org/opensearch/client/IndicesRequestConverters.java index e1d8ffb381f06..8fbdf87538c74 100644 --- a/client/rest-high-level/src/main/java/org/opensearch/client/IndicesRequestConverters.java +++ b/client/rest-high-level/src/main/java/org/opensearch/client/IndicesRequestConverters.java @@ -144,7 +144,7 @@ static Request closeIndex(CloseIndexRequest closeIndexRequest) { RequestConverters.Params parameters = new RequestConverters.Params(); parameters.withTimeout(closeIndexRequest.timeout()); - parameters.withMasterTimeout(closeIndexRequest.masterNodeTimeout()); + parameters.withMasterTimeout(closeIndexRequest.clusterManagerNodeTimeout()); parameters.withIndicesOptions(closeIndexRequest.indicesOptions()); request.addParameters(parameters.asMap()); return request; @@ -156,7 +156,7 @@ static Request createIndex(CreateIndexRequest createIndexRequest) throws IOExcep RequestConverters.Params parameters = new RequestConverters.Params(); parameters.withTimeout(createIndexRequest.timeout()); - parameters.withMasterTimeout(createIndexRequest.masterNodeTimeout()); + parameters.withMasterTimeout(createIndexRequest.clusterManagerNodeTimeout()); parameters.withWaitForActiveShards(createIndexRequest.waitForActiveShards()); request.addParameters(parameters.asMap()); request.setEntity(RequestConverters.createEntity(createIndexRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE)); @@ -179,7 +179,7 @@ static Request putMapping(PutMappingRequest putMappingRequest) throws IOExceptio RequestConverters.Params parameters = new RequestConverters.Params(); parameters.withTimeout(putMappingRequest.timeout()); - parameters.withMasterTimeout(putMappingRequest.masterNodeTimeout()); + parameters.withMasterTimeout(putMappingRequest.clusterManagerNodeTimeout()); parameters.withIndicesOptions(putMappingRequest.indicesOptions()); request.addParameters(parameters.asMap()); request.setEntity(RequestConverters.createEntity(putMappingRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE)); @@ -192,7 +192,7 @@ static Request getMappings(GetMappingsRequest getMappingsRequest) { Request request = new Request(HttpGet.METHOD_NAME, RequestConverters.endpoint(indices, "_mapping")); RequestConverters.Params parameters = new RequestConverters.Params(); - parameters.withMasterTimeout(getMappingsRequest.masterNodeTimeout()); + parameters.withMasterTimeout(getMappingsRequest.clusterManagerNodeTimeout()); parameters.withIndicesOptions(getMappingsRequest.indicesOptions()); parameters.withLocal(getMappingsRequest.local()); request.addParameters(parameters.asMap()); @@ -332,7 +332,7 @@ private static Request resize(ResizeRequest resizeRequest, ResizeType type) thro RequestConverters.Params params = new RequestConverters.Params(); params.withTimeout(resizeRequest.timeout()); - params.withMasterTimeout(resizeRequest.masterNodeTimeout()); + params.withMasterTimeout(resizeRequest.clusterManagerNodeTimeout()); params.withWaitForActiveShards(resizeRequest.getWaitForActiveShards()); request.addParameters(params.asMap()); request.setEntity(RequestConverters.createEntity(resizeRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE)); @@ -365,7 +365,7 @@ static Request rollover(RolloverRequest rolloverRequest) throws IOException { RequestConverters.Params params = new RequestConverters.Params(); params.withTimeout(rolloverRequest.timeout()); - params.withMasterTimeout(rolloverRequest.masterNodeTimeout()); + params.withMasterTimeout(rolloverRequest.clusterManagerNodeTimeout()); params.withWaitForActiveShards(rolloverRequest.getCreateIndexRequest().waitForActiveShards()); if (rolloverRequest.isDryRun()) { params.putParam("dry_run", Boolean.TRUE.toString()); @@ -402,7 +402,7 @@ static Request getIndex(GetIndexRequest getIndexRequest) { params.withLocal(getIndexRequest.local()); params.withIncludeDefaults(getIndexRequest.includeDefaults()); params.withHuman(getIndexRequest.humanReadable()); - params.withMasterTimeout(getIndexRequest.masterNodeTimeout()); + params.withMasterTimeout(getIndexRequest.clusterManagerNodeTimeout()); request.addParameters(params.asMap()); return request; } @@ -461,7 +461,7 @@ static Request putIndexTemplate(PutComposableIndexTemplateRequest putIndexTempla .build(); Request request = new Request(HttpPut.METHOD_NAME, endpoint); RequestConverters.Params params = new RequestConverters.Params(); - params.withMasterTimeout(putIndexTemplateRequest.masterNodeTimeout()); + params.withMasterTimeout(putIndexTemplateRequest.clusterManagerNodeTimeout()); if (putIndexTemplateRequest.create()) { params.putParam("create", Boolean.TRUE.toString()); } @@ -479,7 +479,7 @@ static Request simulateIndexTemplate(SimulateIndexTemplateRequest simulateIndexT .build(); Request request = new Request(HttpPost.METHOD_NAME, endpoint); RequestConverters.Params params = new RequestConverters.Params(); - params.withMasterTimeout(simulateIndexTemplateRequest.masterNodeTimeout()); + params.withMasterTimeout(simulateIndexTemplateRequest.clusterManagerNodeTimeout()); PutComposableIndexTemplateRequest putComposableIndexTemplateRequest = simulateIndexTemplateRequest.indexTemplateV2Request(); if (putComposableIndexTemplateRequest != null) { if (putComposableIndexTemplateRequest.create()) { @@ -597,7 +597,7 @@ static Request deleteIndexTemplate(DeleteComposableIndexTemplateRequest deleteIn String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_index_template").addPathPart(name).build(); Request request = new Request(HttpDelete.METHOD_NAME, endpoint); RequestConverters.Params params = new RequestConverters.Params(); - params.withMasterTimeout(deleteIndexTemplateRequest.masterNodeTimeout()); + params.withMasterTimeout(deleteIndexTemplateRequest.clusterManagerNodeTimeout()); request.addParameters(params.asMap()); return request; } @@ -610,7 +610,7 @@ static Request deleteAlias(DeleteAliasRequest deleteAliasRequest) { Request request = new Request(HttpDelete.METHOD_NAME, endpoint); RequestConverters.Params parameters = new RequestConverters.Params(); parameters.withTimeout(deleteAliasRequest.timeout()); - parameters.withMasterTimeout(deleteAliasRequest.masterNodeTimeout()); + parameters.withMasterTimeout(deleteAliasRequest.clusterManagerNodeTimeout()); request.addParameters(parameters.asMap()); return request; } diff --git a/client/rest-high-level/src/main/java/org/opensearch/client/TimedRequest.java b/client/rest-high-level/src/main/java/org/opensearch/client/TimedRequest.java index b5e7209a5212b..dad5b6a3679ec 100644 --- a/client/rest-high-level/src/main/java/org/opensearch/client/TimedRequest.java +++ b/client/rest-high-level/src/main/java/org/opensearch/client/TimedRequest.java @@ -44,10 +44,13 @@ public abstract class TimedRequest implements Validatable { public static final TimeValue DEFAULT_ACK_TIMEOUT = timeValueSeconds(30); - public static final TimeValue DEFAULT_MASTER_NODE_TIMEOUT = TimeValue.timeValueSeconds(30); + public static final TimeValue DEFAULT_CLUSTER_MANAGER_NODE_TIMEOUT = TimeValue.timeValueSeconds(30); + /** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #DEFAULT_CLUSTER_MANAGER_NODE_TIMEOUT} */ + @Deprecated + public static final TimeValue DEFAULT_MASTER_NODE_TIMEOUT = DEFAULT_CLUSTER_MANAGER_NODE_TIMEOUT; private TimeValue timeout = DEFAULT_ACK_TIMEOUT; - private TimeValue clusterManagerTimeout = DEFAULT_MASTER_NODE_TIMEOUT; + private TimeValue clusterManagerTimeout = DEFAULT_CLUSTER_MANAGER_NODE_TIMEOUT; /** * Sets the timeout to wait for the all the nodes to acknowledge @@ -61,10 +64,20 @@ public void setTimeout(TimeValue timeout) { * Sets the timeout to connect to the cluster-manager node * @param clusterManagerTimeout timeout as a {@link TimeValue} */ - public void setMasterTimeout(TimeValue clusterManagerTimeout) { + public void setClusterManagerTimeout(TimeValue clusterManagerTimeout) { this.clusterManagerTimeout = clusterManagerTimeout; } + /** + * Sets the timeout to connect to the cluster-manager node + * @param clusterManagerTimeout timeout as a {@link TimeValue} + * @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #setClusterManagerTimeout(TimeValue)} + */ + @Deprecated + public void setMasterTimeout(TimeValue clusterManagerTimeout) { + setClusterManagerTimeout(clusterManagerTimeout); + } + /** * Returns the request timeout */ @@ -75,7 +88,16 @@ public TimeValue timeout() { /** * Returns the timeout for the request to be completed on the cluster-manager node */ - public TimeValue masterNodeTimeout() { + public TimeValue clusterManagerNodeTimeout() { return clusterManagerTimeout; } + + /** + * Returns the timeout for the request to be completed on the cluster-manager node + * @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #clusterManagerNodeTimeout()} + */ + @Deprecated + public TimeValue masterNodeTimeout() { + return clusterManagerNodeTimeout(); + } } diff --git a/client/rest-high-level/src/main/java/org/opensearch/client/indices/GetComponentTemplatesRequest.java b/client/rest-high-level/src/main/java/org/opensearch/client/indices/GetComponentTemplatesRequest.java index ba9702fd6f2f2..6326e8edf763b 100644 --- a/client/rest-high-level/src/main/java/org/opensearch/client/indices/GetComponentTemplatesRequest.java +++ b/client/rest-high-level/src/main/java/org/opensearch/client/indices/GetComponentTemplatesRequest.java @@ -44,7 +44,7 @@ public class GetComponentTemplatesRequest implements Validatable { private final String name; - private TimeValue clusterManagerNodeTimeout = TimedRequest.DEFAULT_MASTER_NODE_TIMEOUT; + private TimeValue clusterManagerNodeTimeout = TimedRequest.DEFAULT_CLUSTER_MANAGER_NODE_TIMEOUT; private boolean local = false; /** @@ -67,17 +67,41 @@ public String name() { /** * @return the timeout for waiting for the cluster-manager node to respond */ - public TimeValue getMasterNodeTimeout() { + public TimeValue getClusterManagerNodeTimeout() { return clusterManagerNodeTimeout; } - public void setMasterNodeTimeout(@Nullable TimeValue clusterManagerNodeTimeout) { + /** + * @return the timeout for waiting for the cluster-manager node to respond + * @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #getMasterNodeTimeout()} + */ + @Deprecated + public TimeValue getMasterNodeTimeout() { + return getClusterManagerNodeTimeout(); + } + + public void setClusterManagerNodeTimeout(@Nullable TimeValue clusterManagerNodeTimeout) { this.clusterManagerNodeTimeout = clusterManagerNodeTimeout; } + /** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #setClusterManagerNodeTimeout(TimeValue)} */ + @Deprecated + public void setMasterNodeTimeout(@Nullable TimeValue clusterManagerNodeTimeout) { + setClusterManagerNodeTimeout(clusterManagerNodeTimeout); + } + + public void setClusterManagerNodeTimeout(String clusterManagerNodeTimeout) { + final TimeValue timeValue = TimeValue.parseTimeValue( + clusterManagerNodeTimeout, + getClass().getSimpleName() + ".clusterManagerNodeTimeout" + ); + setClusterManagerNodeTimeout(timeValue); + } + + /** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #setClusterManagerNodeTimeout(String)} */ + @Deprecated public void setMasterNodeTimeout(String clusterManagerNodeTimeout) { - final TimeValue timeValue = TimeValue.parseTimeValue(clusterManagerNodeTimeout, getClass().getSimpleName() + ".masterNodeTimeout"); - setMasterNodeTimeout(timeValue); + setClusterManagerNodeTimeout(clusterManagerNodeTimeout); } /** diff --git a/client/rest-high-level/src/main/java/org/opensearch/client/indices/GetComposableIndexTemplateRequest.java b/client/rest-high-level/src/main/java/org/opensearch/client/indices/GetComposableIndexTemplateRequest.java index cc8e820d5929f..73f6f15fc7a78 100644 --- a/client/rest-high-level/src/main/java/org/opensearch/client/indices/GetComposableIndexTemplateRequest.java +++ b/client/rest-high-level/src/main/java/org/opensearch/client/indices/GetComposableIndexTemplateRequest.java @@ -44,7 +44,7 @@ public class GetComposableIndexTemplateRequest implements Validatable { private final String name; - private TimeValue clusterManagerNodeTimeout = TimedRequest.DEFAULT_MASTER_NODE_TIMEOUT; + private TimeValue clusterManagerNodeTimeout = TimedRequest.DEFAULT_CLUSTER_MANAGER_NODE_TIMEOUT; private boolean local = false; /** @@ -67,17 +67,41 @@ public String name() { /** * @return the timeout for waiting for the cluster-manager node to respond */ - public TimeValue getMasterNodeTimeout() { + public TimeValue getClusterManagerNodeTimeout() { return clusterManagerNodeTimeout; } - public void setMasterNodeTimeout(@Nullable TimeValue clusterManagerNodeTimeout) { + /** + * @return the timeout for waiting for the cluster-manager node to respond + * @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #getMasterNodeTimeout()} + */ + @Deprecated + public TimeValue getMasterNodeTimeout() { + return getClusterManagerNodeTimeout(); + } + + public void setClusterManagerNodeTimeout(@Nullable TimeValue clusterManagerNodeTimeout) { this.clusterManagerNodeTimeout = clusterManagerNodeTimeout; } + /** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #setClusterManagerNodeTimeout(TimeValue)} */ + @Deprecated + public void setMasterNodeTimeout(@Nullable TimeValue clusterManagerNodeTimeout) { + setClusterManagerNodeTimeout(clusterManagerNodeTimeout); + } + + public void setClusterManagerNodeTimeout(String clusterManagerNodeTimeout) { + final TimeValue timeValue = TimeValue.parseTimeValue( + clusterManagerNodeTimeout, + getClass().getSimpleName() + ".clusterManagerNodeTimeout" + ); + setClusterManagerNodeTimeout(timeValue); + } + + /** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #setClusterManagerNodeTimeout(String)} */ + @Deprecated public void setMasterNodeTimeout(String clusterManagerNodeTimeout) { - final TimeValue timeValue = TimeValue.parseTimeValue(clusterManagerNodeTimeout, getClass().getSimpleName() + ".masterNodeTimeout"); - setMasterNodeTimeout(timeValue); + setClusterManagerNodeTimeout(clusterManagerNodeTimeout); } /** diff --git a/client/rest-high-level/src/main/java/org/opensearch/client/indices/GetIndexTemplatesRequest.java b/client/rest-high-level/src/main/java/org/opensearch/client/indices/GetIndexTemplatesRequest.java index f46af130cc9b0..c1bf001e525b3 100644 --- a/client/rest-high-level/src/main/java/org/opensearch/client/indices/GetIndexTemplatesRequest.java +++ b/client/rest-high-level/src/main/java/org/opensearch/client/indices/GetIndexTemplatesRequest.java @@ -51,7 +51,7 @@ public class GetIndexTemplatesRequest implements Validatable { private final List names; - private TimeValue clusterManagerNodeTimeout = TimedRequest.DEFAULT_MASTER_NODE_TIMEOUT; + private TimeValue clusterManagerNodeTimeout = TimedRequest.DEFAULT_CLUSTER_MANAGER_NODE_TIMEOUT; private boolean local = false; /** @@ -86,17 +86,41 @@ public List names() { /** * @return the timeout for waiting for the cluster-manager node to respond */ - public TimeValue getMasterNodeTimeout() { + public TimeValue getClusterManagerNodeTimeout() { return clusterManagerNodeTimeout; } - public void setMasterNodeTimeout(@Nullable TimeValue clusterManagerNodeTimeout) { + /** + * @return the timeout for waiting for the cluster-manager node to respond + * @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #getMasterNodeTimeout()} + */ + @Deprecated + public TimeValue getMasterNodeTimeout() { + return getClusterManagerNodeTimeout(); + } + + public void setClusterManagerNodeTimeout(@Nullable TimeValue clusterManagerNodeTimeout) { this.clusterManagerNodeTimeout = clusterManagerNodeTimeout; } + /** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #setClusterManagerNodeTimeout(TimeValue)} */ + @Deprecated + public void setMasterNodeTimeout(@Nullable TimeValue clusterManagerNodeTimeout) { + setClusterManagerNodeTimeout(clusterManagerNodeTimeout); + } + + public void setClusterManagerNodeTimeout(String clusterManagerNodeTimeout) { + final TimeValue timeValue = TimeValue.parseTimeValue( + clusterManagerNodeTimeout, + getClass().getSimpleName() + ".clusterManagerNodeTimeout" + ); + setClusterManagerNodeTimeout(timeValue); + } + + /** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #setClusterManagerNodeTimeout(String)} */ + @Deprecated public void setMasterNodeTimeout(String clusterManagerNodeTimeout) { - final TimeValue timeValue = TimeValue.parseTimeValue(clusterManagerNodeTimeout, getClass().getSimpleName() + ".masterNodeTimeout"); - setMasterNodeTimeout(timeValue); + setClusterManagerNodeTimeout(clusterManagerNodeTimeout); } /** diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/TimedRequestTests.java b/client/rest-high-level/src/test/java/org/opensearch/client/TimedRequestTests.java index 659238debccad..a630f4f5c1489 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/TimedRequestTests.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/TimedRequestTests.java @@ -41,7 +41,7 @@ public void testDefaults() { TimedRequest timedRequest = new TimedRequest() { }; assertEquals(timedRequest.timeout(), TimedRequest.DEFAULT_ACK_TIMEOUT); - assertEquals(timedRequest.masterNodeTimeout(), TimedRequest.DEFAULT_MASTER_NODE_TIMEOUT); + assertEquals(timedRequest.clusterManagerNodeTimeout(), TimedRequest.DEFAULT_CLUSTER_MANAGER_NODE_TIMEOUT); } public void testNonDefaults() { @@ -50,8 +50,8 @@ public void testNonDefaults() { TimeValue timeout = TimeValue.timeValueSeconds(randomIntBetween(0, 1000)); TimeValue clusterManagerTimeout = TimeValue.timeValueSeconds(randomIntBetween(0, 1000)); timedRequest.setTimeout(timeout); - timedRequest.setMasterTimeout(clusterManagerTimeout); + timedRequest.setClusterManagerTimeout(clusterManagerTimeout); assertEquals(timedRequest.timeout(), timeout); - assertEquals(timedRequest.masterNodeTimeout(), clusterManagerTimeout); + assertEquals(timedRequest.clusterManagerNodeTimeout(), clusterManagerTimeout); } } diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/ClusterClientDocumentationIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/ClusterClientDocumentationIT.java index baebd12e22a99..a3803701be718 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/ClusterClientDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/ClusterClientDocumentationIT.java @@ -515,8 +515,8 @@ public void testGetComponentTemplates() throws Exception { // end::get-component-templates-request // tag::get-component-templates-request-masterTimeout - request.setMasterNodeTimeout(TimeValue.timeValueMinutes(1)); // <1> - request.setMasterNodeTimeout("1m"); // <2> + request.setClusterManagerNodeTimeout(TimeValue.timeValueMinutes(1)); // <1> + request.setClusterManagerNodeTimeout("1m"); // <2> // end::get-component-templates-request-masterTimeout // tag::get-component-templates-execute @@ -603,7 +603,7 @@ public void testPutComponentTemplate() throws Exception { // end::put-component-template-request-create // tag::put-component-template-request-masterTimeout - request.setMasterTimeout(TimeValue.timeValueMinutes(1)); // <1> + request.setClusterManagerTimeout(TimeValue.timeValueMinutes(1)); // <1> // end::put-component-template-request-masterTimeout request.create(false); // make test happy @@ -670,7 +670,7 @@ public void testDeleteComponentTemplate() throws Exception { // end::delete-component-template-request // tag::delete-component-template-request-masterTimeout - deleteRequest.setMasterTimeout(TimeValue.timeValueMinutes(1)); // <1> + deleteRequest.setClusterManagerTimeout(TimeValue.timeValueMinutes(1)); // <1> // end::delete-component-template-request-masterTimeout // tag::delete-component-template-execute diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/IndicesClientDocumentationIT.java b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/IndicesClientDocumentationIT.java index 85c5d622f6f60..dd25463d02977 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/documentation/IndicesClientDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/documentation/IndicesClientDocumentationIT.java @@ -381,7 +381,7 @@ public void testCreateIndex() throws IOException { request.setTimeout(TimeValue.timeValueMinutes(2)); // <1> // end::create-index-request-timeout // tag::create-index-request-masterTimeout - request.setMasterTimeout(TimeValue.timeValueMinutes(1)); // <1> + request.setClusterManagerTimeout(TimeValue.timeValueMinutes(1)); // <1> // end::create-index-request-masterTimeout // tag::create-index-request-waitForActiveShards request.waitForActiveShards(ActiveShardCount.from(2)); // <1> @@ -526,7 +526,7 @@ public void testPutMapping() throws IOException { // end::put-mapping-request-timeout // tag::put-mapping-request-masterTimeout - request.setMasterTimeout(TimeValue.timeValueMinutes(1)); // <1> + request.setClusterManagerTimeout(TimeValue.timeValueMinutes(1)); // <1> // end::put-mapping-request-masterTimeout // tag::put-mapping-execute @@ -597,7 +597,7 @@ public void testGetMapping() throws IOException { // end::get-mappings-request // tag::get-mappings-request-masterTimeout - request.setMasterTimeout(TimeValue.timeValueMinutes(1)); // <1> + request.setClusterManagerTimeout(TimeValue.timeValueMinutes(1)); // <1> // end::get-mappings-request-masterTimeout // tag::get-mappings-request-indicesOptions @@ -1374,7 +1374,7 @@ public void testCloseIndex() throws Exception { request.setTimeout(TimeValue.timeValueMinutes(2)); // <1> // end::close-index-request-timeout // tag::close-index-request-masterTimeout - request.setMasterTimeout(TimeValue.timeValueMinutes(1)); // <1> + request.setClusterManagerTimeout(TimeValue.timeValueMinutes(1)); // <1> // end::close-index-request-masterTimeout // tag::close-index-request-indicesOptions @@ -1815,7 +1815,7 @@ public void testRolloverIndex() throws Exception { request.setTimeout(TimeValue.timeValueMinutes(2)); // <1> // end::rollover-index-request-timeout // tag::rollover-index-request-masterTimeout - request.setMasterTimeout(TimeValue.timeValueMinutes(1)); // <1> + request.setClusterManagerTimeout(TimeValue.timeValueMinutes(1)); // <1> // end::rollover-index-request-masterTimeout // tag::rollover-index-request-dryRun request.dryRun(true); // <1> @@ -2231,8 +2231,8 @@ public void testGetTemplates() throws Exception { // end::get-templates-request // tag::get-templates-request-masterTimeout - request.setMasterNodeTimeout(TimeValue.timeValueMinutes(1)); // <1> - request.setMasterNodeTimeout("1m"); // <2> + request.setClusterManagerNodeTimeout(TimeValue.timeValueMinutes(1)); // <1> + request.setClusterManagerNodeTimeout("1m"); // <2> // end::get-templates-request-masterTimeout // tag::get-templates-execute @@ -2291,8 +2291,8 @@ public void testGetIndexTemplatesV2() throws Exception { // end::get-index-templates-v2-request // tag::get-index-templates-v2-request-masterTimeout - request.setMasterNodeTimeout(TimeValue.timeValueMinutes(1)); // <1> - request.setMasterNodeTimeout("1m"); // <2> + request.setClusterManagerNodeTimeout(TimeValue.timeValueMinutes(1)); // <1> + request.setClusterManagerNodeTimeout("1m"); // <2> // end::get-index-templates-v2-request-masterTimeout // tag::get-index-templates-v2-execute @@ -2450,7 +2450,7 @@ public void testPutIndexTemplateV2() throws Exception { // end::put-index-template-v2-request-create // tag::put-index-template-v2-request-masterTimeout - request.setMasterTimeout(TimeValue.timeValueMinutes(1)); // <1> + request.setClusterManagerTimeout(TimeValue.timeValueMinutes(1)); // <1> // end::put-index-template-v2-request-masterTimeout request.create(false); // make test happy @@ -2511,7 +2511,7 @@ public void testDeleteIndexTemplateV2() throws Exception { // end::delete-index-template-v2-request // tag::delete-index-template-v2-request-masterTimeout - deleteRequest.setMasterTimeout(TimeValue.timeValueMinutes(1)); // <1> + deleteRequest.setClusterManagerTimeout(TimeValue.timeValueMinutes(1)); // <1> // end::delete-index-template-v2-request-masterTimeout // tag::delete-index-template-v2-execute @@ -2644,8 +2644,8 @@ public void testTemplatesExist() throws Exception { // tag::templates-exist-request-optionals request.setLocal(true); // <1> - request.setMasterNodeTimeout(TimeValue.timeValueMinutes(1)); // <2> - request.setMasterNodeTimeout("1m"); // <3> + request.setClusterManagerNodeTimeout(TimeValue.timeValueMinutes(1)); // <2> + request.setClusterManagerNodeTimeout("1m"); // <3> // end::templates-exist-request-optionals // tag::templates-exist-execute @@ -2973,7 +2973,7 @@ public void testDeleteAlias() throws Exception { request.setTimeout(TimeValue.timeValueMinutes(2)); // <1> // end::delete-alias-request-timeout // tag::delete-alias-request-masterTimeout - request.setMasterTimeout(TimeValue.timeValueMinutes(1)); // <1> + request.setClusterManagerTimeout(TimeValue.timeValueMinutes(1)); // <1> // end::delete-alias-request-masterTimeout // tag::delete-alias-execute diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/indices/CloseIndexRequestTests.java b/client/rest-high-level/src/test/java/org/opensearch/client/indices/CloseIndexRequestTests.java index 5bfb0abab9f37..15ae0bbca910a 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/indices/CloseIndexRequestTests.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/indices/CloseIndexRequestTests.java @@ -75,15 +75,15 @@ public void testWaitForActiveShards() { public void testTimeout() { final CloseIndexRequest request = new CloseIndexRequest("index"); assertEquals(request.timeout(), TimedRequest.DEFAULT_ACK_TIMEOUT); - assertEquals(request.masterNodeTimeout(), TimedRequest.DEFAULT_MASTER_NODE_TIMEOUT); + assertEquals(request.clusterManagerNodeTimeout(), TimedRequest.DEFAULT_CLUSTER_MANAGER_NODE_TIMEOUT); final TimeValue timeout = TimeValue.timeValueSeconds(randomIntBetween(0, 1000)); request.setTimeout(timeout); final TimeValue clusterManagerTimeout = TimeValue.timeValueSeconds(randomIntBetween(0, 1000)); - request.setMasterTimeout(clusterManagerTimeout); + request.setClusterManagerTimeout(clusterManagerTimeout); assertEquals(request.timeout(), timeout); - assertEquals(request.masterNodeTimeout(), clusterManagerTimeout); + assertEquals(request.clusterManagerNodeTimeout(), clusterManagerTimeout); } } diff --git a/client/rest/src/main/java/org/opensearch/client/Node.java b/client/rest/src/main/java/org/opensearch/client/Node.java index 952823cf29d6c..c02ac6c68718f 100644 --- a/client/rest/src/main/java/org/opensearch/client/Node.java +++ b/client/rest/src/main/java/org/opensearch/client/Node.java @@ -212,10 +212,19 @@ public Roles(final Set roles) { /** * Returns whether or not the node could be elected cluster-manager. */ - public boolean isMasterEligible() { + public boolean isClusterManagerEligible() { return roles.contains("master") || roles.contains("cluster_manager"); } + /** + * Returns whether or not the node could be elected cluster-manager. + * @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #isClusterManagerEligible()} + */ + @Deprecated + public boolean isMasterEligible() { + return isClusterManagerEligible(); + } + /** * Returns whether or not the node stores data. */ diff --git a/client/rest/src/main/java/org/opensearch/client/NodeSelector.java b/client/rest/src/main/java/org/opensearch/client/NodeSelector.java index 1d1c09f33fef7..a54c6b1514717 100644 --- a/client/rest/src/main/java/org/opensearch/client/NodeSelector.java +++ b/client/rest/src/main/java/org/opensearch/client/NodeSelector.java @@ -89,7 +89,9 @@ public void select(Iterable nodes) { for (Iterator itr = nodes.iterator(); itr.hasNext();) { Node node = itr.next(); if (node.getRoles() == null) continue; - if (node.getRoles().isMasterEligible() && false == node.getRoles().isData() && false == node.getRoles().isIngest()) { + if (node.getRoles().isClusterManagerEligible() + && false == node.getRoles().isData() + && false == node.getRoles().isIngest()) { itr.remove(); } } @@ -97,7 +99,7 @@ public void select(Iterable nodes) { @Override public String toString() { - return "SKIP_DEDICATED_MASTERS"; + return "SKIP_DEDICATED_CLUSTER_MANAGERS"; } }; } diff --git a/client/sniffer/src/test/java/org/opensearch/client/sniff/OpenSearchNodesSnifferTests.java b/client/sniffer/src/test/java/org/opensearch/client/sniff/OpenSearchNodesSnifferTests.java index 8cc6f5f006861..1d06e9353726d 100644 --- a/client/sniffer/src/test/java/org/opensearch/client/sniff/OpenSearchNodesSnifferTests.java +++ b/client/sniffer/src/test/java/org/opensearch/client/sniff/OpenSearchNodesSnifferTests.java @@ -287,7 +287,7 @@ private static SniffResponse buildSniffResponse(OpenSearchNodesSniffer.Scheme sc Collections.shuffle(roles, getRandom()); generator.writeArrayFieldStart("roles"); for (String role : roles) { - if ("cluster_manager".equals(role) && node.getRoles().isMasterEligible()) { + if ("cluster_manager".equals(role) && node.getRoles().isClusterManagerEligible()) { generator.writeString("cluster_manager"); } if ("data".equals(role) && node.getRoles().isData()) {