Skip to content

Commit ef8945b

Browse files
committed
remove wildcard imports
Signed-off-by: Ruirui Zhang <[email protected]>
1 parent daa8c22 commit ef8945b

File tree

6 files changed

+32
-27
lines changed

6 files changed

+32
-27
lines changed

plugins/workload-management/src/main/java/org/opensearch/plugin/wlm/action/CreateQueryGroupRequest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,17 @@
1212
import org.opensearch.action.ActionRequestValidationException;
1313
import org.opensearch.cluster.metadata.QueryGroup;
1414
import org.opensearch.cluster.metadata.QueryGroup.ResiliencyMode;
15-
1615
import org.opensearch.common.UUIDs;
1716
import org.opensearch.core.common.io.stream.StreamInput;
1817
import org.opensearch.core.common.io.stream.StreamOutput;
1918
import org.opensearch.core.common.io.stream.Writeable;
2019
import org.opensearch.core.xcontent.XContentParser;
21-
import org.joda.time.Instant;
2220
import org.opensearch.search.ResourceType;
21+
import org.joda.time.Instant;
2322

2423
import java.io.IOException;
25-
import java.util.Map;
2624
import java.util.HashMap;
25+
import java.util.Map;
2726

2827
/**
2928
* A request for create QueryGroup

plugins/workload-management/src/main/java/org/opensearch/plugin/wlm/action/service/QueryGroupPersistenceService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public void clusterStateProcessed(String source, ClusterState oldState, ClusterS
129129
* @param resourceLimits - the resource limit from which to get the allocation value for resourceName
130130
*/
131131
private double getResourceLimitValue(String resourceName, final Map<ResourceType, Object> resourceLimits) {
132-
for (ResourceType resourceType: resourceLimits.keySet()) {
132+
for (ResourceType resourceType : resourceLimits.keySet()) {
133133
if (resourceType.getName().equals(resourceName)) {
134134
return (double) resourceLimits.get(resourceType);
135135
}

plugins/workload-management/src/test/java/org/opensearch/plugin/wlm/action/QueryGroupTestUtils.java

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,17 @@
1919
import org.opensearch.search.ResourceType;
2020
import org.opensearch.threadpool.ThreadPool;
2121

22-
import java.util.*;
22+
import java.util.ArrayList;
23+
import java.util.Comparator;
24+
import java.util.List;
25+
import java.util.Map;
2326
import java.util.concurrent.atomic.DoubleAdder;
2427

2528
import static org.opensearch.cluster.metadata.QueryGroup.builder;
29+
import static org.opensearch.search.ResourceType.fromName;
2630
import static org.junit.Assert.assertEquals;
2731
import static org.junit.Assert.assertTrue;
2832
import static org.mockito.Mockito.mock;
29-
import static org.opensearch.search.ResourceType.fromName;
3033

3134
public class QueryGroupTestUtils {
3235
public static final String NAME_ONE = "query_group_one";
@@ -93,19 +96,6 @@ public static List<Object> prepareSandboxPersistenceService(Map<String, QueryGro
9396
return List.of(queryGroupPersistenceService, clusterState);
9497
}
9598

96-
public static void compareResourceTypes(Map<ResourceType, Object> resourceLimitMapOne, Map<ResourceType, Object> resourceLimitMapTwo) {
97-
assertTrue(resourceLimitMapOne.keySet().containsAll(resourceLimitMapTwo.keySet()));
98-
assertTrue(resourceLimitMapOne.values().containsAll(resourceLimitMapTwo.values()));
99-
// for (Map.Entry<ResourceType, Object> entryOne : resourceLimitMapOne.entrySet()) {
100-
// String resourceName = entryOne.getKey().getName();
101-
// Optional<Map.Entry<ResourceType, Object>> entryTwo = resourceLimitMapTwo.entrySet().stream()
102-
// .filter(e -> e.getKey().getName().equals(resourceName))
103-
// .findFirst();
104-
// assertTrue(entryTwo.isPresent());
105-
// assertEquals(entryOne.getValue(), entryTwo.get().getValue());
106-
// }
107-
}
108-
10999
public static void compareResourceLimits(Map<String, Object> resourceLimitMapOne, Map<String, Object> resourceLimitMapTwo) {
110100
assertTrue(resourceLimitMapOne.keySet().containsAll(resourceLimitMapTwo.keySet()));
111101
assertTrue(resourceLimitMapOne.values().containsAll(resourceLimitMapTwo.values()));

plugins/workload-management/src/test/java/org/opensearch/plugin/wlm/action/service/QueryGroupPersistenceServiceTests.java

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,28 @@
1919
import org.opensearch.test.OpenSearchTestCase;
2020
import org.opensearch.threadpool.ThreadPool;
2121

22-
import java.util.*;
22+
import java.util.ArrayList;
23+
import java.util.Collection;
24+
import java.util.HashMap;
25+
import java.util.List;
26+
import java.util.Map;
2327

2428
import static org.opensearch.cluster.metadata.QueryGroup.builder;
25-
import static org.mockito.Mockito.mock;
26-
import static org.opensearch.plugin.wlm.action.QueryGroupTestUtils.*;
29+
import static org.opensearch.plugin.wlm.action.QueryGroupTestUtils.MEMORY_STRING;
30+
import static org.opensearch.plugin.wlm.action.QueryGroupTestUtils.MONITOR_STRING;
31+
import static org.opensearch.plugin.wlm.action.QueryGroupTestUtils.NAME_NONE_EXISTED;
32+
import static org.opensearch.plugin.wlm.action.QueryGroupTestUtils.NAME_ONE;
33+
import static org.opensearch.plugin.wlm.action.QueryGroupTestUtils.NAME_TWO;
34+
import static org.opensearch.plugin.wlm.action.QueryGroupTestUtils._ID_ONE;
35+
import static org.opensearch.plugin.wlm.action.QueryGroupTestUtils.assertInflightValuesAreZero;
36+
import static org.opensearch.plugin.wlm.action.QueryGroupTestUtils.compareQueryGroups;
37+
import static org.opensearch.plugin.wlm.action.QueryGroupTestUtils.prepareSandboxPersistenceService;
38+
import static org.opensearch.plugin.wlm.action.QueryGroupTestUtils.queryGroupList;
39+
import static org.opensearch.plugin.wlm.action.QueryGroupTestUtils.queryGroupOne;
40+
import static org.opensearch.plugin.wlm.action.QueryGroupTestUtils.queryGroupPersistenceService;
41+
import static org.opensearch.plugin.wlm.action.QueryGroupTestUtils.queryGroupTwo;
2742
import static org.opensearch.search.query_group.QueryGroupServiceSettings.QUERY_GROUP_COUNT_SETTING_NAME;
43+
import static org.mockito.Mockito.mock;
2844

2945
public class QueryGroupPersistenceServiceTests extends OpenSearchTestCase {
3046

@@ -63,7 +79,7 @@ public void testCreateQueryGroupDuplicateName() {
6379
QueryGroup toCreate = builder().name(NAME_ONE)
6480
._id("W5iIqHyhgi4K1qIAAAAIHw==")
6581
.mode(MONITOR_STRING)
66-
.resourceLimits(Map.of(ResourceType.fromName(MEMORY_STRING), 0.3))
82+
.resourceLimits(Map.of(ResourceType.fromName(MEMORY_STRING), 0.3))
6783
.updatedAt(1690934400000L)
6884
.build();
6985
assertThrows(RuntimeException.class, () -> queryGroupPersistenceService1.saveQueryGroupInClusterState(toCreate, clusterState));
@@ -74,7 +90,7 @@ public void testCreateQueryGroupOverflowAllocation() {
7490
QueryGroup toCreate = builder().name(NAME_TWO)
7591
._id("W5iIqHyhgi4K1qIAAAAIHw==")
7692
.mode(MONITOR_STRING)
77-
.resourceLimits(Map.of(ResourceType.fromName(MEMORY_STRING), 0.5))
93+
.resourceLimits(Map.of(ResourceType.fromName(MEMORY_STRING), 0.5))
7894
.updatedAt(1690934400000L)
7995
.build();
8096
QueryGroupPersistenceService queryGroupPersistenceService1 = (QueryGroupPersistenceService) setup.get(0);
@@ -86,7 +102,7 @@ public void testCreateQueryGroupOverflowCount() {
86102
QueryGroup toCreate = builder().name(NAME_NONE_EXISTED)
87103
._id("W5iIqHyhgi4K1qIAAAAIHw==")
88104
.mode(MONITOR_STRING)
89-
.resourceLimits(Map.of(ResourceType.fromName(MEMORY_STRING), 0.5))
105+
.resourceLimits(Map.of(ResourceType.fromName(MEMORY_STRING), 0.5))
90106
.updatedAt(1690934400000L)
91107
.build();
92108
Metadata metadata = Metadata.builder().queryGroups(Map.of(NAME_ONE, queryGroupOne, NAME_TWO, queryGroupTwo)).build();

server/src/main/java/org/opensearch/cluster/metadata/QueryGroup.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ public boolean equals(Object o) {
206206
if (o == null || getClass() != o.getClass()) return false;
207207
QueryGroup that = (QueryGroup) o;
208208
return Objects.equals(name, that.name)
209+
&& Objects.equals(resiliencyMode, that.resiliencyMode)
209210
&& Objects.equals(resourceLimits, that.resourceLimits)
210211
&& Objects.equals(_id, that._id)
211212
&& updatedAtInMillis == that.updatedAtInMillis;
@@ -273,7 +274,6 @@ public static ResiliencyMode fromName(String s) {
273274
}
274275
throw new IllegalArgumentException("Invalid value for QueryGroupMode: " + s);
275276
}
276-
277277
}
278278

279279
/**

server/src/main/java/org/opensearch/common/settings/ClusterSettings.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@
157157
import org.opensearch.search.backpressure.settings.SearchBackpressureSettings;
158158
import org.opensearch.search.backpressure.settings.SearchShardTaskSettings;
159159
import org.opensearch.search.backpressure.settings.SearchTaskSettings;
160-
import org.opensearch.search.query_group.QueryGroupServiceSettings;
161160
import org.opensearch.search.fetch.subphase.highlight.FastVectorHighlighter;
161+
import org.opensearch.search.query_group.QueryGroupServiceSettings;
162162
import org.opensearch.snapshots.InternalSnapshotsInfoService;
163163
import org.opensearch.snapshots.SnapshotsService;
164164
import org.opensearch.tasks.TaskCancellationMonitoringSettings;

0 commit comments

Comments
 (0)