diff --git a/client/rest-high-level/src/main/java/org/opensearch/client/SearchPipelineRequestConverters.java b/client/rest-high-level/src/main/java/org/opensearch/client/SearchPipelineRequestConverters.java index 3186a59a1118c..655e3728edd71 100644 --- a/client/rest-high-level/src/main/java/org/opensearch/client/SearchPipelineRequestConverters.java +++ b/client/rest-high-level/src/main/java/org/opensearch/client/SearchPipelineRequestConverters.java @@ -8,9 +8,9 @@ package org.opensearch.client; -import org.apache.hc.client5.http.classic.methods.HttpDelete; -import org.apache.hc.client5.http.classic.methods.HttpGet; -import org.apache.hc.client5.http.classic.methods.HttpPut; +import org.apache.http.client.methods.HttpDelete; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPut; import org.opensearch.action.search.DeleteSearchPipelineRequest; import org.opensearch.action.search.GetSearchPipelineRequest; import org.opensearch.action.search.PutSearchPipelineRequest; @@ -28,7 +28,7 @@ static Request putPipeline(PutSearchPipelineRequest putPipelineRequest) throws I RequestConverters.Params params = new RequestConverters.Params(); params.withTimeout(putPipelineRequest.timeout()); - params.withClusterManagerTimeout(putPipelineRequest.clusterManagerNodeTimeout()); + params.withMasterTimeout(putPipelineRequest.clusterManagerNodeTimeout()); request.addParameters(params.asMap()); request.setEntity(RequestConverters.createEntity(putPipelineRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE)); return request; @@ -42,7 +42,7 @@ static Request deletePipeline(DeleteSearchPipelineRequest deletePipelineRequest) RequestConverters.Params parameters = new RequestConverters.Params(); parameters.withTimeout(deletePipelineRequest.timeout()); - parameters.withClusterManagerTimeout(deletePipelineRequest.clusterManagerNodeTimeout()); + parameters.withMasterTimeout(deletePipelineRequest.clusterManagerNodeTimeout()); request.addParameters(parameters.asMap()); return request; } @@ -54,7 +54,7 @@ static Request getPipeline(GetSearchPipelineRequest getPipelineRequest) { Request request = new Request(HttpGet.METHOD_NAME, endpoint); RequestConverters.Params parameters = new RequestConverters.Params(); - parameters.withClusterManagerTimeout(getPipelineRequest.clusterManagerNodeTimeout()); + parameters.withMasterTimeout(getPipelineRequest.clusterManagerNodeTimeout()); request.addParameters(parameters.asMap()); return request; } diff --git a/server/src/main/java/org/opensearch/OpenSearchException.java b/server/src/main/java/org/opensearch/OpenSearchException.java index 5ead26cb892c8..54f6ffa1cc8fa 100644 --- a/server/src/main/java/org/opensearch/OpenSearchException.java +++ b/server/src/main/java/org/opensearch/OpenSearchException.java @@ -78,6 +78,7 @@ import static org.opensearch.Version.V_2_4_0; import static org.opensearch.Version.V_2_5_0; import static org.opensearch.Version.V_2_6_0; +import static org.opensearch.Version.V_2_7_0; import static org.opensearch.cluster.metadata.IndexMetadata.INDEX_UUID_NA_VALUE; import static org.opensearch.common.xcontent.XContentParserUtils.ensureExpectedToken; import static org.opensearch.common.xcontent.XContentParserUtils.ensureFieldName; @@ -1658,12 +1659,7 @@ private enum OpenSearchExceptionHandle { V_2_6_0 ), NODE_WEIGHED_AWAY_EXCEPTION(NodeWeighedAwayException.class, NodeWeighedAwayException::new, 169, V_2_6_0), - SEARCH_PIPELINE_PROCESSING_EXCEPTION( - SearchPipelineProcessingException.class, - SearchPipelineProcessingException::new, - 170, - V_3_0_0 // TODO: Update if/when we backport to 2.x - ), + SEARCH_PIPELINE_PROCESSING_EXCEPTION(SearchPipelineProcessingException.class, SearchPipelineProcessingException::new, 170, V_2_7_0), INDEX_CREATE_BLOCK_EXCEPTION( org.opensearch.cluster.block.IndexCreateBlockException.class, org.opensearch.cluster.block.IndexCreateBlockException::new, diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/info/NodeInfo.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/info/NodeInfo.java index 4366d113e411b..4e93b5d784558 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/info/NodeInfo.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/info/NodeInfo.java @@ -102,9 +102,9 @@ public NodeInfo(StreamInput in) throws IOException { addInfoIfNonNull(IngestInfo.class, in.readOptionalWriteable(IngestInfo::new)); if (in.getVersion().onOrAfter(LegacyESVersion.V_7_10_0)) { addInfoIfNonNull(AggregationInfo.class, in.readOptionalWriteable(AggregationInfo::new)); - if (in.getVersion().onOrAfter(Version.V_3_0_0)) { // TODO: Change if/when we backport to 2.x - addInfoIfNonNull(SearchPipelineInfo.class, in.readOptionalWriteable(SearchPipelineInfo::new)); } + if (in.getVersion().onOrAfter(Version.V_2_7_0)) { + addInfoIfNonNull(SearchPipelineInfo.class, in.readOptionalWriteable(SearchPipelineInfo::new)); } } @@ -232,10 +232,11 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalWriteable(getInfo(IngestInfo.class)); if (out.getVersion().onOrAfter(LegacyESVersion.V_7_10_0)) { out.writeOptionalWriteable(getInfo(AggregationInfo.class)); - if (out.getVersion().onOrAfter(Version.V_3_0_0)) { // TODO: Change if/when we backport to 2.x - out.writeOptionalWriteable(getInfo(SearchPipelineInfo.class)); } + if (out.getVersion().onOrAfter(Version.V_2_7_0)) { + out.writeOptionalWriteable(getInfo(SearchPipelineInfo.class)); } + } public static NodeInfo.Builder builder(Version version, Build build, DiscoveryNode node) { return new Builder(version, build, node); @@ -349,6 +350,4 @@ public NodeInfo build() { } } - - } } diff --git a/server/src/main/java/org/opensearch/action/search/SearchRequest.java b/server/src/main/java/org/opensearch/action/search/SearchRequest.java index 6e47af081b494..a2b66b77a9178 100644 --- a/server/src/main/java/org/opensearch/action/search/SearchRequest.java +++ b/server/src/main/java/org/opensearch/action/search/SearchRequest.java @@ -259,9 +259,9 @@ public SearchRequest(StreamInput in) throws IOException { if (in.getVersion().onOrAfter(Version.V_1_1_0)) { cancelAfterTimeInterval = in.readOptionalTimeValue(); - if (in.getVersion().onOrAfter(Version.V_3_0_0)) { // TODO: Update if/when we backport to 2.x - pipeline = in.readOptionalString(); } + if (in.getVersion().onOrAfter(Version.V_2_7_0)) { // TODO: Update if/when we backport to 2.x + pipeline = in.readOptionalString(); } } @@ -299,9 +299,9 @@ public void writeTo(StreamOutput out) throws IOException { if (out.getVersion().onOrAfter(Version.V_1_1_0)) { out.writeOptionalTimeValue(cancelAfterTimeInterval); - if (out.getVersion().onOrAfter(Version.V_3_0_0)) { // TODO: Update if/when we backport to 2.x - out.writeOptionalString(pipeline); } + if (out.getVersion().onOrAfter(Version.V_2_7_0)) { + out.writeOptionalString(pipeline); } } diff --git a/server/src/main/java/org/opensearch/common/util/CollectionUtils.java b/server/src/main/java/org/opensearch/common/util/CollectionUtils.java index a4a69cbf0e74f..6452d7061fdfa 100644 --- a/server/src/main/java/org/opensearch/common/util/CollectionUtils.java +++ b/server/src/main/java/org/opensearch/common/util/CollectionUtils.java @@ -353,4 +353,16 @@ public static List> eagerPartition(List list, int size) { return result; } + + /** + * Check if a collection is empty or not. Empty collection mean either it is null or it has no elements in it. If + * collection contains a null element it means it is not empty. + * + * @param collection {@link Collection} + * @return boolean + * @param Element + */ + public static boolean isEmpty(final Collection collection) { + return collection == null || collection.isEmpty(); + } }