From c7e56f48c728d49eae87f87e7395d2d920fb4010 Mon Sep 17 00:00:00 2001 From: Kaushal Kumar Date: Tue, 14 May 2024 12:37:13 -0700 Subject: [PATCH] remove non releated changes Signed-off-by: Kaushal Kumar --- .../cluster/metadata/ResourceLimitGroup.java | 10 ++-------- .../metadata/ResourceLimitGroupMetadata.java | 19 ++++++++++--------- .../rest/action/search/RestSearchAction.java | 1 - .../org/opensearch/search/SearchService.java | 1 - .../search/builder/SearchSourceBuilder.java | 8 ++++++-- .../AbstractSearchAsyncActionTests.java | 2 +- .../CanMatchPreFilterSearchPhaseTests.java | 12 ++++++------ .../metadata/ResourceLimitGroupTests.java | 16 +++++++++------- 8 files changed, 34 insertions(+), 35 deletions(-) diff --git a/server/src/main/java/org/opensearch/cluster/metadata/ResourceLimitGroup.java b/server/src/main/java/org/opensearch/cluster/metadata/ResourceLimitGroup.java index 0ca48527c9b75..7feee416b8b67 100644 --- a/server/src/main/java/org/opensearch/cluster/metadata/ResourceLimitGroup.java +++ b/server/src/main/java/org/opensearch/cluster/metadata/ResourceLimitGroup.java @@ -71,7 +71,6 @@ public ResourceLimitGroup(StreamInput in) throws IOException { this(in.readString(), in.readString(), ResourceLimitGroupMode.fromName(in.readString()), in.readMap()); } - /** * Write this into the {@linkplain StreamOutput}. * @@ -85,9 +84,8 @@ public void writeTo(StreamOutput out) throws IOException { out.writeMap(resourceLimits); } - private void validateResourceLimits(Map resourceLimits) { - for (Map.Entry resource: resourceLimits.entrySet()) { + for (Map.Entry resource : resourceLimits.entrySet()) { String resourceName = resource.getKey(); Double threshold = (Double) resource.getValue(); Objects.requireNonNull(resourceName, "resourceName can't be null"); @@ -105,7 +103,6 @@ private void validateResourceLimits(Map resourceLimits) { } } - /** * @param builder * @param params @@ -157,7 +154,7 @@ public static ResourceLimitGroup fromXContent(final XContentParser parser) throw } else if (ALLOWED_RESOURCES.contains(fieldName)) { resourceLimitGroup_.put(fieldName, parser.doubleValue()); } else { - throw new IllegalArgumentException("unrecognised [field=" + fieldName +" in ResourceLimitGroup"); + throw new IllegalArgumentException("unrecognised [field=" + fieldName + " in ResourceLimitGroup"); } } } @@ -194,7 +191,6 @@ public Map getResourceLimits() { return resourceLimits; } - /** * builder method for this {@link ResourceLimitGroup} * @return @@ -203,7 +199,6 @@ public static Builder builder() { return new Builder(); } - /** * This enum models the different sandbox modes */ @@ -238,7 +233,6 @@ public static ResourceLimitGroupMode fromName(String s) { } - /** * Builder class for {@link ResourceLimitGroup} */ diff --git a/server/src/main/java/org/opensearch/cluster/metadata/ResourceLimitGroupMetadata.java b/server/src/main/java/org/opensearch/cluster/metadata/ResourceLimitGroupMetadata.java index ab93a073b50f7..6f6be1a1aa940 100644 --- a/server/src/main/java/org/opensearch/cluster/metadata/ResourceLimitGroupMetadata.java +++ b/server/src/main/java/org/opensearch/cluster/metadata/ResourceLimitGroupMetadata.java @@ -23,7 +23,12 @@ import org.opensearch.core.xcontent.XContentParser; import java.io.IOException; -import java.util.*; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; import static org.opensearch.cluster.metadata.Metadata.ALL_CONTEXTS; @@ -54,7 +59,8 @@ public class ResourceLimitGroupMetadata implements Metadata.Custom { PARSER.declareObjectArray( ConstructingObjectParser.constructorArg(), (p, c) -> ResourceLimitGroup.fromXContent(p), - RESOURCE_LIMIT_GROUP_FIELD); + RESOURCE_LIMIT_GROUP_FIELD + ); } private final Set resourceLimitGroups; @@ -174,9 +180,7 @@ static class ResourceLimitGroupMetadataDiff implements NamedDiff toMap(Set resourceLimitGroups) { final Map resourceLimitGroupMap = new HashMap<>(); - resourceLimitGroups.forEach(resourceLimitGroup -> - resourceLimitGroupMap.put(resourceLimitGroup.getName(), resourceLimitGroup) - ); + resourceLimitGroups.forEach(resourceLimitGroup -> resourceLimitGroupMap.put(resourceLimitGroup.getName(), resourceLimitGroup)); return resourceLimitGroupMap; } @@ -206,10 +210,7 @@ public void writeTo(StreamOutput out) throws IOException { @Override public Metadata.Custom apply(Metadata.Custom part) { return new ResourceLimitGroupMetadata( - new HashSet<>( - dataStreamDiff.apply( - toMap( ( (ResourceLimitGroupMetadata) part).resourceLimitGroups) - ).values()) + new HashSet<>(dataStreamDiff.apply(toMap(((ResourceLimitGroupMetadata) part).resourceLimitGroups)).values()) ); } } diff --git a/server/src/main/java/org/opensearch/rest/action/search/RestSearchAction.java b/server/src/main/java/org/opensearch/rest/action/search/RestSearchAction.java index 7b6043fb63735..3a6b45013e892 100644 --- a/server/src/main/java/org/opensearch/rest/action/search/RestSearchAction.java +++ b/server/src/main/java/org/opensearch/rest/action/search/RestSearchAction.java @@ -223,7 +223,6 @@ public static void parseSearchRequest( ); } - searchRequest.setCancelAfterTimeInterval(request.paramAsTime("cancel_after_time_interval", null)); } diff --git a/server/src/main/java/org/opensearch/search/SearchService.java b/server/src/main/java/org/opensearch/search/SearchService.java index 3daa599878d8f..744d3a19f1593 100644 --- a/server/src/main/java/org/opensearch/search/SearchService.java +++ b/server/src/main/java/org/opensearch/search/SearchService.java @@ -158,7 +158,6 @@ import java.util.concurrent.atomic.AtomicLong; import java.util.function.LongSupplier; -import static org.opensearch.action.search.TransportSearchAction.NOT_PROVIDED; import static org.opensearch.common.unit.TimeValue.timeValueHours; import static org.opensearch.common.unit.TimeValue.timeValueMillis; import static org.opensearch.common.unit.TimeValue.timeValueMinutes; diff --git a/server/src/main/java/org/opensearch/search/builder/SearchSourceBuilder.java b/server/src/main/java/org/opensearch/search/builder/SearchSourceBuilder.java index 79f406408dd68..07248a0719c3a 100644 --- a/server/src/main/java/org/opensearch/search/builder/SearchSourceBuilder.java +++ b/server/src/main/java/org/opensearch/search/builder/SearchSourceBuilder.java @@ -77,7 +77,11 @@ import org.opensearch.search.suggest.SuggestBuilder; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Objects; import static org.opensearch.index.query.AbstractQueryBuilder.parseInnerQueryBuilder; import static org.opensearch.search.internal.SearchContext.TRACK_TOTAL_HITS_ACCURATE; @@ -1330,7 +1334,7 @@ public void parseXContent(XContentParser parser, boolean checkTrailingTokens) th searchPipelineSource = parser.mapOrdered(); } else if (DERIVED_FIELDS_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { derivedFieldsObject = parser.map(); - } else { + } else { throw new ParsingException( parser.getTokenLocation(), "Unknown key for a " + token + " in [" + currentFieldName + "].", diff --git a/server/src/test/java/org/opensearch/action/search/AbstractSearchAsyncActionTests.java b/server/src/test/java/org/opensearch/action/search/AbstractSearchAsyncActionTests.java index 3a54d539da023..7dcbf213d6c9d 100644 --- a/server/src/test/java/org/opensearch/action/search/AbstractSearchAsyncActionTests.java +++ b/server/src/test/java/org/opensearch/action/search/AbstractSearchAsyncActionTests.java @@ -180,7 +180,7 @@ private AbstractSearchAsyncAction createAction( new GroupShardsIterator<>(Arrays.asList(shards)), timeProvider, ClusterState.EMPTY_STATE, - new SearchTask(123, null, null, null, null, null), + null, results, request.getMaxConcurrentShardRequests(), SearchResponse.Clusters.EMPTY, diff --git a/server/src/test/java/org/opensearch/action/search/CanMatchPreFilterSearchPhaseTests.java b/server/src/test/java/org/opensearch/action/search/CanMatchPreFilterSearchPhaseTests.java index 6307691fcd5c6..1881c705fe6b3 100644 --- a/server/src/test/java/org/opensearch/action/search/CanMatchPreFilterSearchPhaseTests.java +++ b/server/src/test/java/org/opensearch/action/search/CanMatchPreFilterSearchPhaseTests.java @@ -160,7 +160,7 @@ public void sendCanMatch( shardsIter, timeProvider, ClusterState.EMPTY_STATE, - new SearchTask(1, null, null, null, null, null), + null, (iter) -> new SearchPhase("test") { @Override public void run() throws IOException { @@ -258,7 +258,7 @@ public void sendCanMatch( shardsIter, timeProvider, ClusterState.EMPTY_STATE, - new SearchTask(1, null, null, null, null, null), + null, (iter) -> new SearchPhase("test") { @Override public void run() throws IOException { @@ -346,7 +346,7 @@ public void sendCanMatch( shardsIter, timeProvider, ClusterState.EMPTY_STATE, - new SearchTask(1, null, null, null, null, null), + null, (iter) -> { return new WrappingSearchAsyncActionPhase( new AbstractSearchAsyncAction("test", logger, transportService, (cluster, node) -> { @@ -478,7 +478,7 @@ public void sendCanMatch( shardsIter, timeProvider, ClusterState.EMPTY_STATE, - new SearchTask(1, null, null, null, null, null), + null, (iter) -> new SearchPhase("test") { @Override public void run() { @@ -585,7 +585,7 @@ public void sendCanMatch( shardsIter, timeProvider, ClusterState.EMPTY_STATE, - new SearchTask(1, null, null, null, null, null), + null, (iter) -> new SearchPhase("test") { @Override public void run() { @@ -690,7 +690,7 @@ public void sendCanMatch( shardsIter, timeProvider, ClusterState.EMPTY_STATE, - new SearchTask(1, null, null, null, null, null), + null, (iter) -> { AbstractSearchAsyncAction action = new SearchDfsQueryAsyncAction( logger, diff --git a/server/src/test/java/org/opensearch/cluster/metadata/ResourceLimitGroupTests.java b/server/src/test/java/org/opensearch/cluster/metadata/ResourceLimitGroupTests.java index b403028e55adf..1099c718c313d 100644 --- a/server/src/test/java/org/opensearch/cluster/metadata/ResourceLimitGroupTests.java +++ b/server/src/test/java/org/opensearch/cluster/metadata/ResourceLimitGroupTests.java @@ -78,14 +78,14 @@ public void testNullResourceLimits() { } public void testEmptyResourceLimits() { - assertThrows(IllegalArgumentException.class, () -> new ResourceLimitGroup("analytics", "_id", randomMode(), Collections.emptyMap())); + assertThrows( + IllegalArgumentException.class, + () -> new ResourceLimitGroup("analytics", "_id", randomMode(), Collections.emptyMap()) + ); } public void testIllegalResourceLimitGroupMode() { - assertThrows( - NullPointerException.class, - () -> new ResourceLimitGroup("analytics", "_id", null, Map.of("jvm", (Object) 0.4)) - ); + assertThrows(NullPointerException.class, () -> new ResourceLimitGroup("analytics", "_id", null, Map.of("jvm", (Object) 0.4))); } public void testInvalidResourceLimitWhenInvalidSystemResourceNameIsGiven() { @@ -95,7 +95,8 @@ public void testInvalidResourceLimitWhenInvalidSystemResourceNameIsGiven() { "analytics", "_id", randomMode(), - Map.of("RequestRate", (Object) randomDoubleBetween(0.01, 0.8, false))) + Map.of("RequestRate", (Object) randomDoubleBetween(0.01, 0.8, false)) + ) ); } @@ -106,7 +107,8 @@ public void testInvalidResourceLimitWhenInvalidSystemResourceValueIsGiven() { "analytics", "_id", randomMode(), - Map.of("RequestRate", (Object) randomDoubleBetween(1.1, 1.8, false))) + Map.of("RequestRate", (Object) randomDoubleBetween(1.1, 1.8, false)) + ) ); }