Skip to content

Commit

Permalink
Replace parameter 'master_timeout' with 'cluster_manager_tiemout' in …
Browse files Browse the repository at this point in the history
…RequestConverters of High-Level-Rest-Client (#2683)

The REST API request parameter "master_timeout" will be deprecated in server version 3.0, and removed in 4.0. The alternative parameter "cluster_manager_timeout" is added in server 2.0 .
With the change in this commit, High-Level-Rest-Client will not be compatible with OpenSearch server 1.x (and below).
- Use parameter `cluster_manager_timeout` instead of `master_timeout` in High-Level-Rest-Client `RequestConverters` class for building REST requests
- Modify corresponding unit tests
- Change lots of "master timeout" in internal method and class names.

Signed-off-by: Tianli Feng <[email protected]>
  • Loading branch information
Tianli Feng authored Apr 19, 2022
1 parent ede26d9 commit 18f4495
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static Request clusterPutSettings(ClusterUpdateSettingsRequest clusterUpdateSett

RequestConverters.Params parameters = new RequestConverters.Params();
parameters.withTimeout(clusterUpdateSettingsRequest.timeout());
parameters.withMasterTimeout(clusterUpdateSettingsRequest.masterNodeTimeout());
parameters.withClusterManagerTimeout(clusterUpdateSettingsRequest.masterNodeTimeout());
request.addParameters(parameters.asMap());
request.setEntity(RequestConverters.createEntity(clusterUpdateSettingsRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE));
return request;
Expand All @@ -69,7 +69,7 @@ static Request clusterGetSettings(ClusterGetSettingsRequest clusterGetSettingsRe
RequestConverters.Params parameters = new RequestConverters.Params();
parameters.withLocal(clusterGetSettingsRequest.local());
parameters.withIncludeDefaults(clusterGetSettingsRequest.includeDefaults());
parameters.withMasterTimeout(clusterGetSettingsRequest.masterNodeTimeout());
parameters.withClusterManagerTimeout(clusterGetSettingsRequest.masterNodeTimeout());
request.addParameters(parameters.asMap());
return request;
}
Expand All @@ -88,7 +88,7 @@ static Request clusterHealth(ClusterHealthRequest healthRequest) {
.withWaitForNodes(healthRequest.waitForNodes())
.withWaitForEvents(healthRequest.waitForEvents())
.withTimeout(healthRequest.timeout())
.withMasterTimeout(healthRequest.masterNodeTimeout())
.withClusterManagerTimeout(healthRequest.masterNodeTimeout())
.withLocal(healthRequest.local())
.withLevel(healthRequest.level());
request.addParameters(params.asMap());
Expand All @@ -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.withClusterManagerTimeout(putComponentTemplateRequest.masterNodeTimeout());
if (putComponentTemplateRequest.create()) {
params.putParam("create", Boolean.TRUE.toString());
}
Expand All @@ -124,7 +124,7 @@ static Request getComponentTemplates(GetComponentTemplatesRequest getComponentTe
final Request request = new Request(HttpGet.METHOD_NAME, endpoint);
final RequestConverters.Params params = new RequestConverters.Params();
params.withLocal(getComponentTemplatesRequest.isLocal());
params.withMasterTimeout(getComponentTemplatesRequest.getMasterNodeTimeout());
params.withClusterManagerTimeout(getComponentTemplatesRequest.getMasterNodeTimeout());
request.addParameters(params.asMap());
return request;
}
Expand All @@ -136,7 +136,7 @@ static Request componentTemplatesExist(ComponentTemplatesExistRequest componentT
final Request request = new Request(HttpHead.METHOD_NAME, endpoint);
final RequestConverters.Params params = new RequestConverters.Params();
params.withLocal(componentTemplatesRequest.isLocal());
params.withMasterTimeout(componentTemplatesRequest.getMasterNodeTimeout());
params.withClusterManagerTimeout(componentTemplatesRequest.getMasterNodeTimeout());
request.addParameters(params.asMap());
return request;
}
Expand All @@ -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.withClusterManagerTimeout(deleteComponentTemplateRequest.masterNodeTimeout());
request.addParameters(params.asMap());
return request;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ static Request deleteIndex(DeleteIndexRequest deleteIndexRequest) {

RequestConverters.Params parameters = new RequestConverters.Params();
parameters.withTimeout(deleteIndexRequest.timeout());
parameters.withMasterTimeout(deleteIndexRequest.masterNodeTimeout());
parameters.withClusterManagerTimeout(deleteIndexRequest.masterNodeTimeout());
parameters.withIndicesOptions(deleteIndexRequest.indicesOptions());
request.addParameters(parameters.asMap());
return request;
Expand All @@ -131,7 +131,7 @@ static Request openIndex(OpenIndexRequest openIndexRequest) {

RequestConverters.Params parameters = new RequestConverters.Params();
parameters.withTimeout(openIndexRequest.timeout());
parameters.withMasterTimeout(openIndexRequest.masterNodeTimeout());
parameters.withClusterManagerTimeout(openIndexRequest.masterNodeTimeout());
parameters.withWaitForActiveShards(openIndexRequest.waitForActiveShards());
parameters.withIndicesOptions(openIndexRequest.indicesOptions());
request.addParameters(parameters.asMap());
Expand All @@ -144,7 +144,7 @@ static Request closeIndex(CloseIndexRequest closeIndexRequest) {

RequestConverters.Params parameters = new RequestConverters.Params();
parameters.withTimeout(closeIndexRequest.timeout());
parameters.withMasterTimeout(closeIndexRequest.masterNodeTimeout());
parameters.withClusterManagerTimeout(closeIndexRequest.masterNodeTimeout());
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.withClusterManagerTimeout(createIndexRequest.masterNodeTimeout());
parameters.withWaitForActiveShards(createIndexRequest.waitForActiveShards());
request.addParameters(parameters.asMap());
request.setEntity(RequestConverters.createEntity(createIndexRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE));
Expand All @@ -168,7 +168,7 @@ static Request updateAliases(IndicesAliasesRequest indicesAliasesRequest) throws

RequestConverters.Params parameters = new RequestConverters.Params();
parameters.withTimeout(indicesAliasesRequest.timeout());
parameters.withMasterTimeout(indicesAliasesRequest.masterNodeTimeout());
parameters.withClusterManagerTimeout(indicesAliasesRequest.masterNodeTimeout());
request.addParameters(parameters.asMap());
request.setEntity(RequestConverters.createEntity(indicesAliasesRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE));
return request;
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.withClusterManagerTimeout(putMappingRequest.masterNodeTimeout());
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.withClusterManagerTimeout(getMappingsRequest.masterNodeTimeout());
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.withClusterManagerTimeout(resizeRequest.masterNodeTimeout());
params.withWaitForActiveShards(resizeRequest.getWaitForActiveShards());
request.addParameters(params.asMap());
request.setEntity(RequestConverters.createEntity(resizeRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE));
Expand All @@ -349,7 +349,7 @@ private static Request resize(org.opensearch.action.admin.indices.shrink.ResizeR

RequestConverters.Params params = new RequestConverters.Params();
params.withTimeout(resizeRequest.timeout());
params.withMasterTimeout(resizeRequest.masterNodeTimeout());
params.withClusterManagerTimeout(resizeRequest.masterNodeTimeout());
params.withWaitForActiveShards(resizeRequest.getTargetIndexRequest().waitForActiveShards());
request.addParameters(params.asMap());
request.setEntity(RequestConverters.createEntity(resizeRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE));
Expand All @@ -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.withClusterManagerTimeout(rolloverRequest.masterNodeTimeout());
params.withWaitForActiveShards(rolloverRequest.getCreateIndexRequest().waitForActiveShards());
if (rolloverRequest.isDryRun()) {
params.putParam("dry_run", Boolean.TRUE.toString());
Expand All @@ -386,7 +386,7 @@ static Request getSettings(GetSettingsRequest getSettingsRequest) {
params.withIndicesOptions(getSettingsRequest.indicesOptions());
params.withLocal(getSettingsRequest.local());
params.withIncludeDefaults(getSettingsRequest.includeDefaults());
params.withMasterTimeout(getSettingsRequest.masterNodeTimeout());
params.withClusterManagerTimeout(getSettingsRequest.masterNodeTimeout());
request.addParameters(params.asMap());
return request;
}
Expand All @@ -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.withClusterManagerTimeout(getIndexRequest.masterNodeTimeout());
request.addParameters(params.asMap());
return request;
}
Expand All @@ -429,7 +429,7 @@ static Request indexPutSettings(UpdateSettingsRequest updateSettingsRequest) thr

RequestConverters.Params parameters = new RequestConverters.Params();
parameters.withTimeout(updateSettingsRequest.timeout());
parameters.withMasterTimeout(updateSettingsRequest.masterNodeTimeout());
parameters.withClusterManagerTimeout(updateSettingsRequest.masterNodeTimeout());
parameters.withIndicesOptions(updateSettingsRequest.indicesOptions());
parameters.withPreserveExisting(updateSettingsRequest.isPreserveExisting());
request.addParameters(parameters.asMap());
Expand All @@ -443,7 +443,7 @@ static Request putTemplate(PutIndexTemplateRequest putIndexTemplateRequest) thro
.build();
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
RequestConverters.Params params = new RequestConverters.Params();
params.withMasterTimeout(putIndexTemplateRequest.masterNodeTimeout());
params.withClusterManagerTimeout(putIndexTemplateRequest.masterNodeTimeout());
if (putIndexTemplateRequest.create()) {
params.putParam("create", Boolean.TRUE.toString());
}
Expand All @@ -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.withClusterManagerTimeout(putIndexTemplateRequest.masterNodeTimeout());
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.withClusterManagerTimeout(simulateIndexTemplateRequest.masterNodeTimeout());
PutComposableIndexTemplateRequest putComposableIndexTemplateRequest = simulateIndexTemplateRequest.indexTemplateV2Request();
if (putComposableIndexTemplateRequest != null) {
if (putComposableIndexTemplateRequest.create()) {
Expand Down Expand Up @@ -529,7 +529,7 @@ static Request getTemplates(GetIndexTemplatesRequest getIndexTemplatesRequest) {
final Request request = new Request(HttpGet.METHOD_NAME, endpoint);
final RequestConverters.Params params = new RequestConverters.Params();
params.withLocal(getIndexTemplatesRequest.isLocal());
params.withMasterTimeout(getIndexTemplatesRequest.getMasterNodeTimeout());
params.withClusterManagerTimeout(getIndexTemplatesRequest.getMasterNodeTimeout());
request.addParameters(params.asMap());
return request;
}
Expand All @@ -541,7 +541,7 @@ static Request getIndexTemplates(GetComposableIndexTemplateRequest getIndexTempl
final Request request = new Request(HttpGet.METHOD_NAME, endpoint);
final RequestConverters.Params params = new RequestConverters.Params();
params.withLocal(getIndexTemplatesRequest.isLocal());
params.withMasterTimeout(getIndexTemplatesRequest.getMasterNodeTimeout());
params.withClusterManagerTimeout(getIndexTemplatesRequest.getMasterNodeTimeout());
request.addParameters(params.asMap());
return request;
}
Expand All @@ -553,7 +553,7 @@ static Request templatesExist(IndexTemplatesExistRequest indexTemplatesExistRequ
final Request request = new Request(HttpHead.METHOD_NAME, endpoint);
final RequestConverters.Params params = new RequestConverters.Params();
params.withLocal(indexTemplatesExistRequest.isLocal());
params.withMasterTimeout(indexTemplatesExistRequest.getMasterNodeTimeout());
params.withClusterManagerTimeout(indexTemplatesExistRequest.getMasterNodeTimeout());
request.addParameters(params.asMap());
return request;
}
Expand All @@ -565,7 +565,7 @@ static Request templatesExist(ComposableIndexTemplateExistRequest indexTemplates
final Request request = new Request(HttpHead.METHOD_NAME, endpoint);
final RequestConverters.Params params = new RequestConverters.Params();
params.withLocal(indexTemplatesExistRequest.isLocal());
params.withMasterTimeout(indexTemplatesExistRequest.getMasterNodeTimeout());
params.withClusterManagerTimeout(indexTemplatesExistRequest.getMasterNodeTimeout());
request.addParameters(params.asMap());
return request;
}
Expand All @@ -587,7 +587,7 @@ static Request deleteTemplate(DeleteIndexTemplateRequest deleteIndexTemplateRequ
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_template").addPathPart(name).build();
Request request = new Request(HttpDelete.METHOD_NAME, endpoint);
RequestConverters.Params params = new RequestConverters.Params();
params.withMasterTimeout(deleteIndexTemplateRequest.masterNodeTimeout());
params.withClusterManagerTimeout(deleteIndexTemplateRequest.masterNodeTimeout());
request.addParameters(params.asMap());
return request;
}
Expand All @@ -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.withClusterManagerTimeout(deleteIndexTemplateRequest.masterNodeTimeout());
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.withClusterManagerTimeout(deleteAliasRequest.masterNodeTimeout());
request.addParameters(parameters.asMap());
return request;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static Request getPipeline(GetPipelineRequest getPipelineRequest) {
Request request = new Request(HttpGet.METHOD_NAME, endpoint);

RequestConverters.Params parameters = new RequestConverters.Params();
parameters.withMasterTimeout(getPipelineRequest.masterNodeTimeout());
parameters.withClusterManagerTimeout(getPipelineRequest.masterNodeTimeout());
request.addParameters(parameters.asMap());
return request;
}
Expand All @@ -67,7 +67,7 @@ static Request putPipeline(PutPipelineRequest putPipelineRequest) throws IOExcep

RequestConverters.Params parameters = new RequestConverters.Params();
parameters.withTimeout(putPipelineRequest.timeout());
parameters.withMasterTimeout(putPipelineRequest.masterNodeTimeout());
parameters.withClusterManagerTimeout(putPipelineRequest.masterNodeTimeout());
request.addParameters(parameters.asMap());
request.setEntity(RequestConverters.createEntity(putPipelineRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE));
return request;
Expand All @@ -81,7 +81,7 @@ static Request deletePipeline(DeletePipelineRequest deletePipelineRequest) {

RequestConverters.Params parameters = new RequestConverters.Params();
parameters.withTimeout(deletePipelineRequest.timeout());
parameters.withMasterTimeout(deletePipelineRequest.masterNodeTimeout());
parameters.withClusterManagerTimeout(deletePipelineRequest.masterNodeTimeout());
request.addParameters(parameters.asMap());
return request;
}
Expand Down
Loading

0 comments on commit 18f4495

Please sign in to comment.