Skip to content

Commit

Permalink
Deprecate public methods and variables that contain 'master' terminol…
Browse files Browse the repository at this point in the history
…ogy in 'client' directory (opensearch-project#3966)

* Deprecate public methods and variables that contain 'master' terminology in 'client' directory

Signed-off-by: Tianli Feng <[email protected]>

* Change 1 String type usages with 'master' to 'cluster manager'

Signed-off-by: Tianli Feng <[email protected]>
  • Loading branch information
Tianli Feng committed Jul 22, 2022
1 parent 0a42e6d commit d2fe0ef
Show file tree
Hide file tree
Showing 13 changed files with 165 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
Expand All @@ -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));
Expand All @@ -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());
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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());
}
Expand All @@ -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()) {
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
*/
Expand All @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class GetIndexTemplatesRequest implements Validatable {

private final List<String> names;

private TimeValue clusterManagerNodeTimeout = TimedRequest.DEFAULT_MASTER_NODE_TIMEOUT;
private TimeValue clusterManagerNodeTimeout = TimedRequest.DEFAULT_CLUSTER_MANAGER_NODE_TIMEOUT;
private boolean local = false;

/**
Expand Down Expand Up @@ -86,17 +86,41 @@ public List<String> 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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit d2fe0ef

Please sign in to comment.