From 289abd5caf8c89a4ddd47257fd6108f879d94fda Mon Sep 17 00:00:00 2001 From: Ruirui Zhang Date: Tue, 30 Jul 2024 15:19:28 -0700 Subject: [PATCH 1/7] add QeryGroup Service tests Signed-off-by: Ruirui Zhang --- .../common/settings/ClusterSettings.java | 10 +- .../QueryGroupServiceSettings.java | 316 ++++++++++++++++++ .../search/query_group/package-info.java | 12 + .../QueryGroupServiceSettingsTests.java | 214 ++++++++++++ 4 files changed, 551 insertions(+), 1 deletion(-) create mode 100644 server/src/main/java/org/opensearch/search/query_group/QueryGroupServiceSettings.java create mode 100644 server/src/main/java/org/opensearch/search/query_group/package-info.java create mode 100644 test/framework/src/main/java/org/opensearch/search/query_group/QueryGroupServiceSettingsTests.java diff --git a/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java b/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java index d5e8e90458390..d628e1b2d3b6a 100644 --- a/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java +++ b/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java @@ -159,6 +159,7 @@ import org.opensearch.search.backpressure.settings.SearchShardTaskSettings; import org.opensearch.search.backpressure.settings.SearchTaskSettings; import org.opensearch.search.fetch.subphase.highlight.FastVectorHighlighter; +import org.opensearch.search.query_group.QueryGroupServiceSettings; import org.opensearch.snapshots.InternalSnapshotsInfoService; import org.opensearch.snapshots.SnapshotsService; import org.opensearch.tasks.TaskCancellationMonitoringSettings; @@ -766,7 +767,14 @@ public void apply(Settings value, Settings current, Settings previous) { // Composite index settings CompositeIndexSettings.STAR_TREE_INDEX_ENABLED_SETTING, - SystemTemplatesService.SETTING_APPLICATION_BASED_CONFIGURATION_TEMPLATES_ENABLED + SystemTemplatesService.SETTING_APPLICATION_BASED_CONFIGURATION_TEMPLATES_ENABLED, + + // QueryGroup settings + QueryGroupServiceSettings.MAX_QUERY_GROUP_COUNT, + QueryGroupServiceSettings.NODE_LEVEL_CPU_REJECTION_THRESHOLD, + QueryGroupServiceSettings.NODE_LEVEL_CPU_CANCELLATION_THRESHOLD, + QueryGroupServiceSettings.NODE_LEVEL_MEMORY_REJECTION_THRESHOLD, + QueryGroupServiceSettings.NODE_LEVEL_MEMORY_CANCELLATION_THRESHOLD ) ) ); diff --git a/server/src/main/java/org/opensearch/search/query_group/QueryGroupServiceSettings.java b/server/src/main/java/org/opensearch/search/query_group/QueryGroupServiceSettings.java new file mode 100644 index 0000000000000..7a00855f609a7 --- /dev/null +++ b/server/src/main/java/org/opensearch/search/query_group/QueryGroupServiceSettings.java @@ -0,0 +1,316 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.search.query_group; + +import org.opensearch.common.settings.ClusterSettings; +import org.opensearch.common.settings.Setting; +import org.opensearch.common.settings.Settings; +import org.opensearch.common.unit.TimeValue; + +/** + * Main class to declare the QueryGroup feature related settings + */ +public class QueryGroupServiceSettings { + private static final Long DEFAULT_RUN_INTERVAL_MILLIS = 1000l; + private static final Double DEFAULT_NODE_LEVEL_MEMORY_REJECTION_THRESHOLD = 0.8; + private static final Double DEFAULT_NODE_LEVEL_MEMORY_CANCELLATION_THRESHOLD = 0.9; + private static final Double DEFAULT_NODE_LEVEL_CPU_REJECTION_THRESHOLD = 0.8; + private static final Double DEFAULT_NODE_LEVEL_CPU_CANCELLATION_THRESHOLD = 0.9; + /** + * default max queryGroup count on any node at any given point in time + */ + public static final int DEFAULT_MAX_QUERY_GROUP_COUNT_VALUE = 100; + public static final String QUERY_GROUP_COUNT_SETTING_NAME = "node.query_group.max_count"; + public static final double NODE_LEVEL_MEMORY_CANCELLATION_THRESHOLD_MAX_VALUE = 0.95; + public static final double NODE_LEVEL_MEMORY_REJECTION_THRESHOLD_MAX_VALUE = 0.90; + public static final double NODE_LEVEL_CPU_CANCELLATION_THRESHOLD_MAX_VALUE = 0.95; + public static final double NODE_LEVEL_CPU_REJECTION_THRESHOLD_MAX_VALUE = 0.90; + + private TimeValue runIntervalMillis; + private Double nodeLevelMemoryCancellationThreshold; + private Double nodeLevelMemoryRejectionThreshold; + private Double nodeLevelCpuCancellationThreshold; + private Double nodeLevelCpuRejectionThreshold; + private volatile int maxQueryGroupCount; + /** + * max QueryGroup count setting + */ + public static final Setting MAX_QUERY_GROUP_COUNT = Setting.intSetting( + QUERY_GROUP_COUNT_SETTING_NAME, + DEFAULT_MAX_QUERY_GROUP_COUNT_VALUE, + 0, + (newVal) -> { + if (newVal > 100 || newVal < 1) throw new IllegalArgumentException( + QUERY_GROUP_COUNT_SETTING_NAME + " should be in range [1-100]" + ); + }, + Setting.Property.Dynamic, + Setting.Property.NodeScope + ); + /** + * Setting name for default QueryGroup count + */ + public static final String SERVICE_RUN_INTERVAL_MILLIS_SETTING_NAME = "query_group.service.run_interval_millis"; + /** + * Setting to control the run interval of QSB service + */ + private static final Setting QUERY_GROUP_RUN_INTERVAL_SETTING = Setting.longSetting( + SERVICE_RUN_INTERVAL_MILLIS_SETTING_NAME, + DEFAULT_RUN_INTERVAL_MILLIS, + 1, + Setting.Property.Dynamic, + Setting.Property.NodeScope + ); + + /** + * Setting name for node level memory rejection threshold for QSB + */ + public static final String NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME = "query_group.node.memory_rejection_threshold"; + /** + * Setting to control the memory rejection threshold + */ + public static final Setting NODE_LEVEL_MEMORY_REJECTION_THRESHOLD = Setting.doubleSetting( + NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME, + DEFAULT_NODE_LEVEL_MEMORY_REJECTION_THRESHOLD, + Setting.Property.Dynamic, + Setting.Property.NodeScope + ); + /** + * Setting name for node level cpu rejection threshold for QSB + */ + public static final String NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME = "query_group.node.cpu_rejection_threshold"; + /** + * Setting to control the cpu rejection threshold + */ + public static final Setting NODE_LEVEL_CPU_REJECTION_THRESHOLD = Setting.doubleSetting( + NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME, + DEFAULT_NODE_LEVEL_CPU_REJECTION_THRESHOLD, + Setting.Property.Dynamic, + Setting.Property.NodeScope + ); + /** + * Setting name for node level memory cancellation threshold + */ + public static final String NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME = "query_group.node.memory_cancellation_threshold"; + /** + * Setting name for node level memory cancellation threshold + */ + public static final Setting NODE_LEVEL_MEMORY_CANCELLATION_THRESHOLD = Setting.doubleSetting( + NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME, + DEFAULT_NODE_LEVEL_MEMORY_CANCELLATION_THRESHOLD, + Setting.Property.Dynamic, + Setting.Property.NodeScope + ); + /** + * Setting name for node level cpu cancellation threshold + */ + public static final String NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME = "query_group.node.cpu_cancellation_threshold"; + /** + * Setting name for node level cpu cancellation threshold + */ + public static final Setting NODE_LEVEL_CPU_CANCELLATION_THRESHOLD = Setting.doubleSetting( + NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME, + DEFAULT_NODE_LEVEL_CPU_CANCELLATION_THRESHOLD, + Setting.Property.Dynamic, + Setting.Property.NodeScope + ); + + /** + * QueryGroup service settings constructor + * @param settings - QueryGroup service settings + * @param clusterSettings - QueryGroup cluster settings + */ + public QueryGroupServiceSettings(Settings settings, ClusterSettings clusterSettings) { + runIntervalMillis = new TimeValue(QUERY_GROUP_RUN_INTERVAL_SETTING.get(settings)); + nodeLevelMemoryCancellationThreshold = NODE_LEVEL_MEMORY_CANCELLATION_THRESHOLD.get(settings); + nodeLevelMemoryRejectionThreshold = NODE_LEVEL_MEMORY_REJECTION_THRESHOLD.get(settings); + nodeLevelCpuCancellationThreshold = NODE_LEVEL_CPU_CANCELLATION_THRESHOLD.get(settings); + nodeLevelCpuRejectionThreshold = NODE_LEVEL_CPU_REJECTION_THRESHOLD.get(settings); + maxQueryGroupCount = MAX_QUERY_GROUP_COUNT.get(settings); + + ensureRejectionThresholdIsLessThanCancellation( + nodeLevelMemoryRejectionThreshold, + nodeLevelMemoryCancellationThreshold, + NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME, + NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME + ); + ensureRejectionThresholdIsLessThanCancellation( + nodeLevelCpuRejectionThreshold, + nodeLevelCpuCancellationThreshold, + NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME, + NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME + ); + + clusterSettings.addSettingsUpdateConsumer(MAX_QUERY_GROUP_COUNT, this::setMaxQueryGroupCount); + clusterSettings.addSettingsUpdateConsumer(NODE_LEVEL_MEMORY_CANCELLATION_THRESHOLD, this::setNodeLevelMemoryCancellationThreshold); + clusterSettings.addSettingsUpdateConsumer(NODE_LEVEL_MEMORY_REJECTION_THRESHOLD, this::setNodeLevelMemoryRejectionThreshold); + clusterSettings.addSettingsUpdateConsumer(NODE_LEVEL_CPU_CANCELLATION_THRESHOLD, this::setNodeLevelCpuCancellationThreshold); + clusterSettings.addSettingsUpdateConsumer(NODE_LEVEL_CPU_REJECTION_THRESHOLD, this::setNodeLevelCpuRejectionThreshold); + } + + /** + * Method to get runInterval for QSB + * @return runInterval in milliseconds for QSB Service + */ + public TimeValue getRunIntervalMillis() { + return runIntervalMillis; + } + + /** + * Method to set the new QueryGroup count + * @param newMaxQueryGroupCount is the new maxQueryGroupCount per node + */ + public void setMaxQueryGroupCount(int newMaxQueryGroupCount) { + if (newMaxQueryGroupCount < 0) { + throw new IllegalArgumentException("node.node.query_group.max_count can't be negative"); + } + this.maxQueryGroupCount = newMaxQueryGroupCount; + } + + /** + * Method to get the node level memory cancellation threshold + * @return current node level memory cancellation threshold + */ + public Double getNodeLevelMemoryCancellationThreshold() { + return nodeLevelMemoryCancellationThreshold; + } + + /** + * Method to set the node level memory cancellation threshold + * @param nodeLevelMemoryCancellationThreshold sets the new node level memory cancellation threshold + * @throws IllegalArgumentException if the value is > 0.95 and cancellation < rejection threshold + */ + public void setNodeLevelMemoryCancellationThreshold(Double nodeLevelMemoryCancellationThreshold) { + if (Double.compare(nodeLevelMemoryCancellationThreshold, NODE_LEVEL_MEMORY_CANCELLATION_THRESHOLD_MAX_VALUE) > 0) { + throw new IllegalArgumentException( + NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME + " value should not be greater than 0.95 as it pose a threat of node drop" + ); + } + + ensureRejectionThresholdIsLessThanCancellation( + nodeLevelMemoryRejectionThreshold, + nodeLevelMemoryCancellationThreshold, + NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME, + NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME + ); + + this.nodeLevelMemoryCancellationThreshold = nodeLevelMemoryCancellationThreshold; + } + + /** + * Method to get the node level cpu cancellation threshold + * @return current node level cpu cancellation threshold + */ + public Double getNodeLevelCpuCancellationThreshold() { + return nodeLevelCpuCancellationThreshold; + } + + /** + * Method to set the node level cpu cancellation threshold + * @param nodeLevelCpuCancellationThreshold sets the new node level cpu cancellation threshold + * @throws IllegalArgumentException if the value is > 0.95 and cancellation < rejection threshold + */ + public void setNodeLevelCpuCancellationThreshold(Double nodeLevelCpuCancellationThreshold) { + if (Double.compare(nodeLevelCpuCancellationThreshold, NODE_LEVEL_CPU_CANCELLATION_THRESHOLD_MAX_VALUE) > 0) { + throw new IllegalArgumentException( + NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME + " value should not be greater than 0.95 as it pose a threat of node drop" + ); + } + + ensureRejectionThresholdIsLessThanCancellation( + nodeLevelCpuRejectionThreshold, + nodeLevelCpuCancellationThreshold, + NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME, + NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME + ); + + this.nodeLevelCpuCancellationThreshold = nodeLevelCpuCancellationThreshold; + } + + /** + * Method to get the memory node level rejection threshold + * @return the current memory node level rejection threshold + */ + public Double getNodeLevelMemoryRejectionThreshold() { + return nodeLevelMemoryRejectionThreshold; + } + + /** + * Method to set the node level memory rejection threshold + * @param nodeLevelMemoryRejectionThreshold sets the new memory rejection threshold + * @throws IllegalArgumentException if rejection > 0.90 and rejection < cancellation threshold + */ + public void setNodeLevelMemoryRejectionThreshold(Double nodeLevelMemoryRejectionThreshold) { + if (Double.compare(nodeLevelMemoryRejectionThreshold, NODE_LEVEL_MEMORY_REJECTION_THRESHOLD_MAX_VALUE) > 0) { + throw new IllegalArgumentException( + NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME + " value not be greater than 0.90 as it pose a threat of node drop" + ); + } + + ensureRejectionThresholdIsLessThanCancellation( + nodeLevelMemoryRejectionThreshold, + nodeLevelMemoryCancellationThreshold, + NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME, + NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME + ); + + this.nodeLevelMemoryRejectionThreshold = nodeLevelMemoryRejectionThreshold; + } + + /** + * Method to get the cpu node level rejection threshold + * @return the current cpu node level rejection threshold + */ + public Double getNodeLevelCpuRejectionThreshold() { + return nodeLevelCpuRejectionThreshold; + } + + /** + * Method to set the node level cpu rejection threshold + * @param nodeLevelCpuRejectionThreshold sets the new cpu rejection threshold + * @throws IllegalArgumentException if rejection > 0.90 and rejection < cancellation threshold + */ + public void setNodeLevelCpuRejectionThreshold(Double nodeLevelCpuRejectionThreshold) { + if (Double.compare(nodeLevelCpuRejectionThreshold, NODE_LEVEL_CPU_REJECTION_THRESHOLD_MAX_VALUE) > 0) { + throw new IllegalArgumentException( + NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME + " value not be greater than 0.90 as it pose a threat of node drop" + ); + } + + ensureRejectionThresholdIsLessThanCancellation( + nodeLevelCpuRejectionThreshold, + nodeLevelCpuCancellationThreshold, + NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME, + NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME + ); + + this.nodeLevelCpuRejectionThreshold = nodeLevelCpuRejectionThreshold; + } + + private void ensureRejectionThresholdIsLessThanCancellation( + Double nodeLevelRejectionThreshold, + Double nodeLevelCancellationThreshold, + String rejectionThresholdSettingName, + String cancellationThresholdSettingName + ) { + if (Double.compare(nodeLevelCancellationThreshold, nodeLevelRejectionThreshold) < 0) { + throw new IllegalArgumentException( + cancellationThresholdSettingName + " value should not be less than " + rejectionThresholdSettingName + ); + } + } + + /** + * Method to get the current QueryGroup count + * @return the current max QueryGroup count + */ + public int getMaxQueryGroupCount() { + return maxQueryGroupCount; + } +} diff --git a/server/src/main/java/org/opensearch/search/query_group/package-info.java b/server/src/main/java/org/opensearch/search/query_group/package-info.java new file mode 100644 index 0000000000000..ee6c5692f32c7 --- /dev/null +++ b/server/src/main/java/org/opensearch/search/query_group/package-info.java @@ -0,0 +1,12 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +/** + * QueryGroup related settings + */ +package org.opensearch.search.query_group; diff --git a/test/framework/src/main/java/org/opensearch/search/query_group/QueryGroupServiceSettingsTests.java b/test/framework/src/main/java/org/opensearch/search/query_group/QueryGroupServiceSettingsTests.java new file mode 100644 index 0000000000000..db5148afbc80f --- /dev/null +++ b/test/framework/src/main/java/org/opensearch/search/query_group/QueryGroupServiceSettingsTests.java @@ -0,0 +1,214 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.search.query_group; + +import org.opensearch.common.settings.ClusterSettings; +import org.opensearch.common.settings.Settings; +import org.opensearch.test.OpenSearchTestCase; + +import static org.opensearch.search.query_group.QueryGroupServiceSettings.NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME; +import static org.opensearch.search.query_group.QueryGroupServiceSettings.NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME; +import static org.opensearch.search.query_group.QueryGroupServiceSettings.NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME; +import static org.opensearch.search.query_group.QueryGroupServiceSettings.NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME; +import static org.opensearch.search.query_group.QueryGroupServiceSettings.QUERY_GROUP_COUNT_SETTING_NAME; + +public class QueryGroupServiceSettingsTests extends OpenSearchTestCase { + + /** + * Tests the valid value of {@code node.query_group.max_count} + */ + public void testValidMaxSandboxCountSetting() { + Settings settings = Settings.builder().put(QUERY_GROUP_COUNT_SETTING_NAME, 100).build(); + ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); + QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); + assertEquals(100, queryGroupServiceSettings.getMaxQueryGroupCount()); + } + + /** + * test the invalid value of {@code node.query_group.max_count} + */ + public void testInValidMaxSandboxCountSetting() { + Settings settings = Settings.builder().put(QUERY_GROUP_COUNT_SETTING_NAME, -100).build(); + ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); + assertThrows(IllegalArgumentException.class, () -> new QueryGroupServiceSettings(settings, cs)); + } + + /** + * Tests the valid value for {@code query_group.node.memory_rejection_threshold} + */ + public void testValidNodeLevelMemoryRejectionThreshold() { + Settings settings = Settings.builder().put(NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME, 0.80).build(); + ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); + QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); + assertEquals(0.80, queryGroupServiceSettings.getNodeLevelMemoryRejectionThreshold(), 1e-9); + } + + /** + * Tests the valid value for {@code query_group.node.cpu__rejection_threshold} + */ + public void testValidNodeLevelCpuRejectionThreshold() { + Settings settings = Settings.builder().put(NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME, 0.80).build(); + ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); + QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); + assertEquals(0.80, queryGroupServiceSettings.getNodeLevelCpuRejectionThreshold(), 1e-9); + } + + /** + * Tests the invalid value for {@code query_group.node.memory_rejection_threshold} + * When the value is set more than {@literal 0.90} + */ + public void testInValidNodeLevelMemoryRejectionThresholdCase1() { + Settings settings = Settings.builder().put(NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME, 0.80).build(); + ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); + QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); + assertThrows(IllegalArgumentException.class, () -> queryGroupServiceSettings.setNodeLevelMemoryRejectionThreshold(0.95)); + } + + /** + * Tests the invalid value for {@code query_group.node.cpu_rejection_threshold} + * When the value is set more than {@literal 0.90} + */ + public void testInValidNodeLevelCpuRejectionThresholdCase1() { + Settings settings = Settings.builder().put(NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME, 0.80).build(); + ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); + QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); + assertThrows(IllegalArgumentException.class, () -> queryGroupServiceSettings.setNodeLevelCpuRejectionThreshold(0.95)); + } + + /** + * Tests the invalid value for {@code query_group.node.memory_rejection_threshold} + * When the value is set more than {@code query_group.node.memory_cancellation_threshold} + */ + public void testInValidNodeLevelMemoryRejectionThresholdCase2() { + Settings settings = Settings.builder() + .put(NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME, 0.70) + .put(NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME, 0.80) + .build(); + ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); + QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); + assertThrows(IllegalArgumentException.class, () -> queryGroupServiceSettings.setNodeLevelMemoryRejectionThreshold(0.85)); + } + + /** + * Tests the invalid value for {@code query_group.node.cpu_rejection_threshold} + * When the value is set more than {@code query_group.node.cpu_cancellation_threshold} + */ + public void testInValidNodeLevelCpuRejectionThresholdCase2() { + Settings settings = Settings.builder() + .put(NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME, 0.70) + .put(NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME, 0.80) + .build(); + ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); + QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); + assertThrows(IllegalArgumentException.class, () -> queryGroupServiceSettings.setNodeLevelCpuRejectionThreshold(0.85)); + } + + /** + * Tests the invalid value for {@code query_group.node.memory_rejection_threshold} + * When the value is set more than {@code query_group.node.memory_cancellation_threshold} accidentally during + * new feature development. This test is to ensure that {@link QueryGroupServiceSettings} holds the + * invariant {@code nodeLevelRejectionThreshold < nodeLevelCancellationThreshold} + */ + public void testInValidMemoryInstantiationOfQueryGroupServiceSettings() { + Settings settings = Settings.builder() + .put(NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME, 0.80) + .put(NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME, 0.70) + .build(); + ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); + + assertThrows(IllegalArgumentException.class, () -> new QueryGroupServiceSettings(settings, cs)); + } + + /** + * Tests the invalid value for {@code query_group.node.cpu_rejection_threshold} + * When the value is set more than {@code query_group.node.cpu_cancellation_threshold} accidentally during + * new feature development. This test is to ensure that {@link QueryGroupServiceSettings} holds the + * invariant {@code nodeLevelRejectionThreshold < nodeLevelCancellationThreshold} + */ + public void testInValidCpuInstantiationOfQueryGroupServiceSettings() { + Settings settings = Settings.builder() + .put(NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME, 0.80) + .put(NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME, 0.70) + .build(); + ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); + + assertThrows(IllegalArgumentException.class, () -> new QueryGroupServiceSettings(settings, cs)); + } + + /** + * Tests the valid value for {@code query_group.node.memory_cancellation_threshold} + */ + public void testValidNodeLevelMemoryCancellationThreshold() { + Settings settings = Settings.builder().put(NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME, 0.80).build(); + ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); + QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); + assertEquals(0.80, queryGroupServiceSettings.getNodeLevelMemoryRejectionThreshold(), 1e-9); + } + + /** + * Tests the valid value for {@code query_group.node.cpu_cancellation_threshold} + */ + public void testValidNodeLevelCpuCancellationThreshold() { + Settings settings = Settings.builder().put(NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME, 0.80).build(); + ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); + QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); + assertEquals(0.80, queryGroupServiceSettings.getNodeLevelCpuRejectionThreshold(), 1e-9); + } + + /** + * Tests the invalid value for {@code query_group.node.memory_cancellation_threshold} + * When the value is set more than {@literal 0.95} + */ + public void testInValidNodeLevelMemoryCancellationThresholdCase1() { + Settings settings = Settings.builder().put(NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME, 0.80).build(); + ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); + QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); + assertThrows(IllegalArgumentException.class, () -> queryGroupServiceSettings.setNodeLevelMemoryRejectionThreshold(0.96)); + } + + /** + * Tests the invalid value for {@code query_group.node.memory_cancellation_threshold} + * When the value is set more than {@literal 0.95} + */ + public void testInValidNodeLevelCpuCancellationThresholdCase1() { + Settings settings = Settings.builder().put(NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME, 0.80).build(); + ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); + QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); + assertThrows(IllegalArgumentException.class, () -> queryGroupServiceSettings.setNodeLevelCpuRejectionThreshold(0.96)); + } + + /** + * Tests the invalid value for {@code query_group.node.memory_cancellation_threshold} + * When the value is set less than {@code query_group.node.memory_rejection_threshold} + */ + public void testInValidNodeLevelMemoryCancellationThresholdCase2() { + Settings settings = Settings.builder() + .put(NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME, 0.70) + .put(NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME, 0.80) + .build(); + ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); + QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); + assertThrows(IllegalArgumentException.class, () -> queryGroupServiceSettings.setNodeLevelMemoryRejectionThreshold(0.85)); + } + + /** + * Tests the invalid value for {@code query_group.node.cpu_cancellation_threshold} + * When the value is set less than {@code query_group.node.cpu_rejection_threshold} + */ + public void testInValidNodeLevelCpuCancellationThresholdCase2() { + Settings settings = Settings.builder() + .put(NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME, 0.70) + .put(NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME, 0.80) + .build(); + ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); + QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); + assertThrows(IllegalArgumentException.class, () -> queryGroupServiceSettings.setNodeLevelCpuRejectionThreshold(0.85)); + } + +} From a182fbd89500b657549e199c8254bd1ba7426bea Mon Sep 17 00:00:00 2001 From: Ruirui Zhang Date: Tue, 30 Jul 2024 15:24:25 -0700 Subject: [PATCH 2/7] add PR to changelog Signed-off-by: Ruirui Zhang --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c49f506f94bf1..6d0e37cd1d829 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Add `rangeQuery` and `regexpQuery` for `constant_keyword` field type ([#14711](https://github.com/opensearch-project/OpenSearch/pull/14711)) - Add took time to request nodes stats ([#15054](https://github.com/opensearch-project/OpenSearch/pull/15054)) - [Workload Management] Add Get QueryGroup API Logic ([14709](https://github.com/opensearch-project/OpenSearch/pull/14709)) +- [Workload Management] Add QueryGroupServiceSettings ([#15028](https://github.com/opensearch-project/OpenSearch/pull/15028)) - [Workload Management] QueryGroup resource tracking framework changes ([#13897](https://github.com/opensearch-project/OpenSearch/pull/13897)) - Support filtering on a large list encoded by bitmap ([#14774](https://github.com/opensearch-project/OpenSearch/pull/14774)) - Add slice execution listeners to SearchOperationListener interface ([#15153](https://github.com/opensearch-project/OpenSearch/pull/15153)) From 81964566226a3f956a02392631f656c1282781ea Mon Sep 17 00:00:00 2001 From: Ruirui Zhang Date: Tue, 30 Jul 2024 15:51:08 -0700 Subject: [PATCH 3/7] change the test directory Signed-off-by: Ruirui Zhang --- .../search/query_group/QueryGroupServiceSettingsTests.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {test/framework/src/main => server/src/test}/java/org/opensearch/search/query_group/QueryGroupServiceSettingsTests.java (100%) diff --git a/test/framework/src/main/java/org/opensearch/search/query_group/QueryGroupServiceSettingsTests.java b/server/src/test/java/org/opensearch/search/query_group/QueryGroupServiceSettingsTests.java similarity index 100% rename from test/framework/src/main/java/org/opensearch/search/query_group/QueryGroupServiceSettingsTests.java rename to server/src/test/java/org/opensearch/search/query_group/QueryGroupServiceSettingsTests.java From 9b3dce9a46f01afdcbc1ee088c044cb03af13dde Mon Sep 17 00:00:00 2001 From: Ruirui Zhang Date: Tue, 30 Jul 2024 16:43:35 -0700 Subject: [PATCH 4/7] modify comments to be more specific Signed-off-by: Ruirui Zhang --- .../common/settings/ClusterSettings.java | 1 - .../QueryGroupServiceSettings.java | 70 +++++-------------- .../QueryGroupServiceSettingsTests.java | 20 ------ 3 files changed, 18 insertions(+), 73 deletions(-) diff --git a/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java b/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java index d628e1b2d3b6a..6efb3b4febcb4 100644 --- a/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java +++ b/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java @@ -770,7 +770,6 @@ public void apply(Settings value, Settings current, Settings previous) { SystemTemplatesService.SETTING_APPLICATION_BASED_CONFIGURATION_TEMPLATES_ENABLED, // QueryGroup settings - QueryGroupServiceSettings.MAX_QUERY_GROUP_COUNT, QueryGroupServiceSettings.NODE_LEVEL_CPU_REJECTION_THRESHOLD, QueryGroupServiceSettings.NODE_LEVEL_CPU_CANCELLATION_THRESHOLD, QueryGroupServiceSettings.NODE_LEVEL_MEMORY_REJECTION_THRESHOLD, diff --git a/server/src/main/java/org/opensearch/search/query_group/QueryGroupServiceSettings.java b/server/src/main/java/org/opensearch/search/query_group/QueryGroupServiceSettings.java index 7a00855f609a7..5f6ee0be53fdd 100644 --- a/server/src/main/java/org/opensearch/search/query_group/QueryGroupServiceSettings.java +++ b/server/src/main/java/org/opensearch/search/query_group/QueryGroupServiceSettings.java @@ -22,11 +22,6 @@ public class QueryGroupServiceSettings { private static final Double DEFAULT_NODE_LEVEL_MEMORY_CANCELLATION_THRESHOLD = 0.9; private static final Double DEFAULT_NODE_LEVEL_CPU_REJECTION_THRESHOLD = 0.8; private static final Double DEFAULT_NODE_LEVEL_CPU_CANCELLATION_THRESHOLD = 0.9; - /** - * default max queryGroup count on any node at any given point in time - */ - public static final int DEFAULT_MAX_QUERY_GROUP_COUNT_VALUE = 100; - public static final String QUERY_GROUP_COUNT_SETTING_NAME = "node.query_group.max_count"; public static final double NODE_LEVEL_MEMORY_CANCELLATION_THRESHOLD_MAX_VALUE = 0.95; public static final double NODE_LEVEL_MEMORY_REJECTION_THRESHOLD_MAX_VALUE = 0.90; public static final double NODE_LEVEL_CPU_CANCELLATION_THRESHOLD_MAX_VALUE = 0.95; @@ -37,28 +32,12 @@ public class QueryGroupServiceSettings { private Double nodeLevelMemoryRejectionThreshold; private Double nodeLevelCpuCancellationThreshold; private Double nodeLevelCpuRejectionThreshold; - private volatile int maxQueryGroupCount; - /** - * max QueryGroup count setting - */ - public static final Setting MAX_QUERY_GROUP_COUNT = Setting.intSetting( - QUERY_GROUP_COUNT_SETTING_NAME, - DEFAULT_MAX_QUERY_GROUP_COUNT_VALUE, - 0, - (newVal) -> { - if (newVal > 100 || newVal < 1) throw new IllegalArgumentException( - QUERY_GROUP_COUNT_SETTING_NAME + " should be in range [1-100]" - ); - }, - Setting.Property.Dynamic, - Setting.Property.NodeScope - ); /** - * Setting name for default QueryGroup count + * Setting name for the run interval of QueryGroup service */ public static final String SERVICE_RUN_INTERVAL_MILLIS_SETTING_NAME = "query_group.service.run_interval_millis"; /** - * Setting to control the run interval of QSB service + * Setting to control the run interval of QueryGroup service */ private static final Setting QUERY_GROUP_RUN_INTERVAL_SETTING = Setting.longSetting( SERVICE_RUN_INTERVAL_MILLIS_SETTING_NAME, @@ -69,7 +48,7 @@ public class QueryGroupServiceSettings { ); /** - * Setting name for node level memory rejection threshold for QSB + * Setting name for node level memory rejection threshold for QueryGroup service */ public static final String NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME = "query_group.node.memory_rejection_threshold"; /** @@ -82,7 +61,7 @@ public class QueryGroupServiceSettings { Setting.Property.NodeScope ); /** - * Setting name for node level cpu rejection threshold for QSB + * Setting name for node level cpu rejection threshold for QueryGroup service */ public static final String NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME = "query_group.node.cpu_rejection_threshold"; /** @@ -95,11 +74,11 @@ public class QueryGroupServiceSettings { Setting.Property.NodeScope ); /** - * Setting name for node level memory cancellation threshold + * Setting name for node level memory cancellation threshold for QueryGroup service */ public static final String NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME = "query_group.node.memory_cancellation_threshold"; /** - * Setting name for node level memory cancellation threshold + * Setting to control the memory cancellation threshold */ public static final Setting NODE_LEVEL_MEMORY_CANCELLATION_THRESHOLD = Setting.doubleSetting( NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME, @@ -108,11 +87,11 @@ public class QueryGroupServiceSettings { Setting.Property.NodeScope ); /** - * Setting name for node level cpu cancellation threshold + * Setting name for node level cpu cancellation threshold for QueryGroup service */ public static final String NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME = "query_group.node.cpu_cancellation_threshold"; /** - * Setting name for node level cpu cancellation threshold + * Setting to control the cpu cancellation threshold */ public static final Setting NODE_LEVEL_CPU_CANCELLATION_THRESHOLD = Setting.doubleSetting( NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME, @@ -132,7 +111,6 @@ public QueryGroupServiceSettings(Settings settings, ClusterSettings clusterSetti nodeLevelMemoryRejectionThreshold = NODE_LEVEL_MEMORY_REJECTION_THRESHOLD.get(settings); nodeLevelCpuCancellationThreshold = NODE_LEVEL_CPU_CANCELLATION_THRESHOLD.get(settings); nodeLevelCpuRejectionThreshold = NODE_LEVEL_CPU_REJECTION_THRESHOLD.get(settings); - maxQueryGroupCount = MAX_QUERY_GROUP_COUNT.get(settings); ensureRejectionThresholdIsLessThanCancellation( nodeLevelMemoryRejectionThreshold, @@ -147,7 +125,6 @@ public QueryGroupServiceSettings(Settings settings, ClusterSettings clusterSetti NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME ); - clusterSettings.addSettingsUpdateConsumer(MAX_QUERY_GROUP_COUNT, this::setMaxQueryGroupCount); clusterSettings.addSettingsUpdateConsumer(NODE_LEVEL_MEMORY_CANCELLATION_THRESHOLD, this::setNodeLevelMemoryCancellationThreshold); clusterSettings.addSettingsUpdateConsumer(NODE_LEVEL_MEMORY_REJECTION_THRESHOLD, this::setNodeLevelMemoryRejectionThreshold); clusterSettings.addSettingsUpdateConsumer(NODE_LEVEL_CPU_CANCELLATION_THRESHOLD, this::setNodeLevelCpuCancellationThreshold); @@ -155,24 +132,13 @@ public QueryGroupServiceSettings(Settings settings, ClusterSettings clusterSetti } /** - * Method to get runInterval for QSB - * @return runInterval in milliseconds for QSB Service + * Method to get runInterval for QueryGroup service + * @return runInterval in milliseconds for QueryGroup service */ public TimeValue getRunIntervalMillis() { return runIntervalMillis; } - /** - * Method to set the new QueryGroup count - * @param newMaxQueryGroupCount is the new maxQueryGroupCount per node - */ - public void setMaxQueryGroupCount(int newMaxQueryGroupCount) { - if (newMaxQueryGroupCount < 0) { - throw new IllegalArgumentException("node.node.query_group.max_count can't be negative"); - } - this.maxQueryGroupCount = newMaxQueryGroupCount; - } - /** * Method to get the node level memory cancellation threshold * @return current node level memory cancellation threshold @@ -293,6 +259,14 @@ public void setNodeLevelCpuRejectionThreshold(Double nodeLevelCpuRejectionThresh this.nodeLevelCpuRejectionThreshold = nodeLevelCpuRejectionThreshold; } + /** + * Method to validate that the cancellation threshold is greater than or equal to rejection threshold + * @param nodeLevelRejectionThreshold rejection threshold to be compared + * @param nodeLevelCancellationThreshold cancellation threshold to be compared + * @param rejectionThresholdSettingName name of the rejection threshold setting + * @param cancellationThresholdSettingName name of the cancellation threshold setting + * @throws IllegalArgumentException if cancellation threshold is less than rejection threshold + */ private void ensureRejectionThresholdIsLessThanCancellation( Double nodeLevelRejectionThreshold, Double nodeLevelCancellationThreshold, @@ -305,12 +279,4 @@ private void ensureRejectionThresholdIsLessThanCancellation( ); } } - - /** - * Method to get the current QueryGroup count - * @return the current max QueryGroup count - */ - public int getMaxQueryGroupCount() { - return maxQueryGroupCount; - } } diff --git a/server/src/test/java/org/opensearch/search/query_group/QueryGroupServiceSettingsTests.java b/server/src/test/java/org/opensearch/search/query_group/QueryGroupServiceSettingsTests.java index db5148afbc80f..9124d23ebd062 100644 --- a/server/src/test/java/org/opensearch/search/query_group/QueryGroupServiceSettingsTests.java +++ b/server/src/test/java/org/opensearch/search/query_group/QueryGroupServiceSettingsTests.java @@ -16,29 +16,9 @@ import static org.opensearch.search.query_group.QueryGroupServiceSettings.NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME; import static org.opensearch.search.query_group.QueryGroupServiceSettings.NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME; import static org.opensearch.search.query_group.QueryGroupServiceSettings.NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME; -import static org.opensearch.search.query_group.QueryGroupServiceSettings.QUERY_GROUP_COUNT_SETTING_NAME; public class QueryGroupServiceSettingsTests extends OpenSearchTestCase { - /** - * Tests the valid value of {@code node.query_group.max_count} - */ - public void testValidMaxSandboxCountSetting() { - Settings settings = Settings.builder().put(QUERY_GROUP_COUNT_SETTING_NAME, 100).build(); - ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); - QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); - assertEquals(100, queryGroupServiceSettings.getMaxQueryGroupCount()); - } - - /** - * test the invalid value of {@code node.query_group.max_count} - */ - public void testInValidMaxSandboxCountSetting() { - Settings settings = Settings.builder().put(QUERY_GROUP_COUNT_SETTING_NAME, -100).build(); - ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); - assertThrows(IllegalArgumentException.class, () -> new QueryGroupServiceSettings(settings, cs)); - } - /** * Tests the valid value for {@code query_group.node.memory_rejection_threshold} */ From 1905f3148d52aa2eb13dd5bda48a92b58fa0369f Mon Sep 17 00:00:00 2001 From: Ruirui Zhang Date: Wed, 31 Jul 2024 14:44:43 -0700 Subject: [PATCH 5/7] add test coverage Signed-off-by: Ruirui Zhang --- .../QueryGroupServiceSettings.java | 4 +- .../QueryGroupServiceSettingsTests.java | 205 +++++++++++------- 2 files changed, 128 insertions(+), 81 deletions(-) diff --git a/server/src/main/java/org/opensearch/search/query_group/QueryGroupServiceSettings.java b/server/src/main/java/org/opensearch/search/query_group/QueryGroupServiceSettings.java index 5f6ee0be53fdd..00740acbd1d99 100644 --- a/server/src/main/java/org/opensearch/search/query_group/QueryGroupServiceSettings.java +++ b/server/src/main/java/org/opensearch/search/query_group/QueryGroupServiceSettings.java @@ -23,9 +23,9 @@ public class QueryGroupServiceSettings { private static final Double DEFAULT_NODE_LEVEL_CPU_REJECTION_THRESHOLD = 0.8; private static final Double DEFAULT_NODE_LEVEL_CPU_CANCELLATION_THRESHOLD = 0.9; public static final double NODE_LEVEL_MEMORY_CANCELLATION_THRESHOLD_MAX_VALUE = 0.95; - public static final double NODE_LEVEL_MEMORY_REJECTION_THRESHOLD_MAX_VALUE = 0.90; + public static final double NODE_LEVEL_MEMORY_REJECTION_THRESHOLD_MAX_VALUE = 0.9; public static final double NODE_LEVEL_CPU_CANCELLATION_THRESHOLD_MAX_VALUE = 0.95; - public static final double NODE_LEVEL_CPU_REJECTION_THRESHOLD_MAX_VALUE = 0.90; + public static final double NODE_LEVEL_CPU_REJECTION_THRESHOLD_MAX_VALUE = 0.9; private TimeValue runIntervalMillis; private Double nodeLevelMemoryCancellationThreshold; diff --git a/server/src/test/java/org/opensearch/search/query_group/QueryGroupServiceSettingsTests.java b/server/src/test/java/org/opensearch/search/query_group/QueryGroupServiceSettingsTests.java index 9124d23ebd062..021b399d8c87a 100644 --- a/server/src/test/java/org/opensearch/search/query_group/QueryGroupServiceSettingsTests.java +++ b/server/src/test/java/org/opensearch/search/query_group/QueryGroupServiceSettingsTests.java @@ -20,69 +20,78 @@ public class QueryGroupServiceSettingsTests extends OpenSearchTestCase { /** - * Tests the valid value for {@code query_group.node.memory_rejection_threshold} + * Tests the invalid value for {@code query_group.node.memory_rejection_threshold} + * When the value is set more than {@code query_group.node.memory_cancellation_threshold} accidentally during + * new feature development. This test is to ensure that {@link QueryGroupServiceSettings} holds the + * invariant {@code nodeLevelRejectionThreshold < nodeLevelCancellationThreshold} */ - public void testValidNodeLevelMemoryRejectionThreshold() { - Settings settings = Settings.builder().put(NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME, 0.80).build(); + public void testInvalidMemoryInstantiationOfQueryGroupServiceSettings() { + Settings settings = Settings.builder() + .put(NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME, 0.8) + .put(NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME, 0.7) + .build(); ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); - QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); - assertEquals(0.80, queryGroupServiceSettings.getNodeLevelMemoryRejectionThreshold(), 1e-9); + + assertThrows(IllegalArgumentException.class, () -> new QueryGroupServiceSettings(settings, cs)); } /** - * Tests the valid value for {@code query_group.node.cpu__rejection_threshold} + * Tests the invalid value for {@code query_group.node.cpu_rejection_threshold} + * When the value is set more than {@code query_group.node.cpu_cancellation_threshold} accidentally during + * new feature development. This test is to ensure that {@link QueryGroupServiceSettings} holds the + * invariant {@code nodeLevelRejectionThreshold < nodeLevelCancellationThreshold} */ - public void testValidNodeLevelCpuRejectionThreshold() { - Settings settings = Settings.builder().put(NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME, 0.80).build(); + public void testInvalidCpuInstantiationOfQueryGroupServiceSettings() { + Settings settings = Settings.builder() + .put(NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME, 0.8) + .put(NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME, 0.7) + .build(); ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); - QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); - assertEquals(0.80, queryGroupServiceSettings.getNodeLevelCpuRejectionThreshold(), 1e-9); + + assertThrows(IllegalArgumentException.class, () -> new QueryGroupServiceSettings(settings, cs)); } /** - * Tests the invalid value for {@code query_group.node.memory_rejection_threshold} - * When the value is set more than {@literal 0.90} + * Tests the valid value for {@code query_group.node.cpu_rejection_threshold} + * Using setNodeLevelCpuRejectionThreshold function */ - public void testInValidNodeLevelMemoryRejectionThresholdCase1() { - Settings settings = Settings.builder().put(NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME, 0.80).build(); + public void testValidNodeLevelCpuRejectionThresholdCase1() { + Settings settings = Settings.builder().put(NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME, 0.8).build(); ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); - assertThrows(IllegalArgumentException.class, () -> queryGroupServiceSettings.setNodeLevelMemoryRejectionThreshold(0.95)); + queryGroupServiceSettings.setNodeLevelCpuRejectionThreshold(0.7); + assertEquals(0.7, queryGroupServiceSettings.getNodeLevelCpuRejectionThreshold(), 1e-9); } /** - * Tests the invalid value for {@code query_group.node.cpu_rejection_threshold} - * When the value is set more than {@literal 0.90} + * Tests the valid value for {@code query_group.node.cpu_rejection_threshold} */ - public void testInValidNodeLevelCpuRejectionThresholdCase1() { - Settings settings = Settings.builder().put(NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME, 0.80).build(); + public void testValidNodeLevelCpuRejectionThresholdCase2() { + Settings settings = Settings.builder().put(NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME, 0.79).build(); ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); - assertThrows(IllegalArgumentException.class, () -> queryGroupServiceSettings.setNodeLevelCpuRejectionThreshold(0.95)); + assertEquals(0.79, queryGroupServiceSettings.getNodeLevelCpuRejectionThreshold(), 1e-9); } /** - * Tests the invalid value for {@code query_group.node.memory_rejection_threshold} - * When the value is set more than {@code query_group.node.memory_cancellation_threshold} + * Tests the invalid value for {@code query_group.node.cpu_rejection_threshold} + * When the value is set more than {@literal 0.9} */ - public void testInValidNodeLevelMemoryRejectionThresholdCase2() { - Settings settings = Settings.builder() - .put(NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME, 0.70) - .put(NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME, 0.80) - .build(); + public void testInvalidNodeLevelCpuRejectionThresholdCase1() { + Settings settings = Settings.builder().put(NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME, 0.8).build(); ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); - assertThrows(IllegalArgumentException.class, () -> queryGroupServiceSettings.setNodeLevelMemoryRejectionThreshold(0.85)); + assertThrows(IllegalArgumentException.class, () -> queryGroupServiceSettings.setNodeLevelCpuRejectionThreshold(0.95)); } /** * Tests the invalid value for {@code query_group.node.cpu_rejection_threshold} * When the value is set more than {@code query_group.node.cpu_cancellation_threshold} */ - public void testInValidNodeLevelCpuRejectionThresholdCase2() { + public void testInvalidNodeLevelCpuRejectionThresholdCase2() { Settings settings = Settings.builder() - .put(NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME, 0.70) - .put(NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME, 0.80) + .put(NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME, 0.7) + .put(NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME, 0.8) .build(); ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); @@ -90,105 +99,143 @@ public void testInValidNodeLevelCpuRejectionThresholdCase2() { } /** - * Tests the invalid value for {@code query_group.node.memory_rejection_threshold} - * When the value is set more than {@code query_group.node.memory_cancellation_threshold} accidentally during - * new feature development. This test is to ensure that {@link QueryGroupServiceSettings} holds the - * invariant {@code nodeLevelRejectionThreshold < nodeLevelCancellationThreshold} + * Tests the valid value for {@code query_group.node.cpu_cancellation_threshold} */ - public void testInValidMemoryInstantiationOfQueryGroupServiceSettings() { - Settings settings = Settings.builder() - .put(NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME, 0.80) - .put(NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME, 0.70) - .build(); + public void testValidNodeLevelCpuCancellationThresholdCase1() { + Settings settings = Settings.builder().put(NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME, 0.8).build(); ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); - - assertThrows(IllegalArgumentException.class, () -> new QueryGroupServiceSettings(settings, cs)); + QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); + assertEquals(0.8, queryGroupServiceSettings.getNodeLevelCpuRejectionThreshold(), 1e-9); } /** - * Tests the invalid value for {@code query_group.node.cpu_rejection_threshold} - * When the value is set more than {@code query_group.node.cpu_cancellation_threshold} accidentally during - * new feature development. This test is to ensure that {@link QueryGroupServiceSettings} holds the - * invariant {@code nodeLevelRejectionThreshold < nodeLevelCancellationThreshold} + * Tests the valid value for {@code query_group.node.cpu_cancellation_threshold} + * Using setNodeLevelCpuCancellationThreshold function */ - public void testInValidCpuInstantiationOfQueryGroupServiceSettings() { - Settings settings = Settings.builder() - .put(NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME, 0.80) - .put(NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME, 0.70) - .build(); + public void testValidNodeLevelCpuCancellationThresholdCase2() { + Settings settings = Settings.builder().put(NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME, 0.8).build(); ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); + QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); + queryGroupServiceSettings.setNodeLevelCpuCancellationThreshold(0.83); + assertEquals(0.83, queryGroupServiceSettings.getNodeLevelCpuCancellationThreshold(), 1e-9); + } - assertThrows(IllegalArgumentException.class, () -> new QueryGroupServiceSettings(settings, cs)); + /** + * Tests the invalid value for {@code query_group.node.cpu_cancellation_threshold} + * When the value is set more than {@literal 0.95} + */ + public void testInvalidNodeLevelCpuCancellationThresholdCase1() { + Settings settings = Settings.builder().put(NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME, 0.9).build(); + ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); + QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); + assertThrows(IllegalArgumentException.class, () -> queryGroupServiceSettings.setNodeLevelCpuCancellationThreshold(0.96)); } /** - * Tests the valid value for {@code query_group.node.memory_cancellation_threshold} + * Tests the invalid value for {@code query_group.node.cpu_cancellation_threshold} + * When the value is set less than {@code query_group.node.cpu_rejection_threshold} */ - public void testValidNodeLevelMemoryCancellationThreshold() { - Settings settings = Settings.builder().put(NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME, 0.80).build(); + public void testInvalidNodeLevelCpuCancellationThresholdCase2() { + Settings settings = Settings.builder() + .put(NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME, 0.7) + .put(NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME, 0.8) + .build(); ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); - assertEquals(0.80, queryGroupServiceSettings.getNodeLevelMemoryRejectionThreshold(), 1e-9); + assertThrows(IllegalArgumentException.class, () -> queryGroupServiceSettings.setNodeLevelCpuCancellationThreshold(0.65)); } /** - * Tests the valid value for {@code query_group.node.cpu_cancellation_threshold} + * Tests the valid value for {@code query_group.node.memory_cancellation_threshold} */ - public void testValidNodeLevelCpuCancellationThreshold() { - Settings settings = Settings.builder().put(NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME, 0.80).build(); + public void testValidNodeLevelMemoryCancellationThresholdCase1() { + Settings settings = Settings.builder().put(NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME, 0.8).build(); ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); - assertEquals(0.80, queryGroupServiceSettings.getNodeLevelCpuRejectionThreshold(), 1e-9); + assertEquals(0.8, queryGroupServiceSettings.getNodeLevelMemoryCancellationThreshold(), 1e-9); } /** - * Tests the invalid value for {@code query_group.node.memory_cancellation_threshold} - * When the value is set more than {@literal 0.95} + * Tests the valid value for {@code query_group.node.memory_cancellation_threshold} + * Using setNodeLevelMemoryCancellationThreshold function */ - public void testInValidNodeLevelMemoryCancellationThresholdCase1() { - Settings settings = Settings.builder().put(NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME, 0.80).build(); + public void testValidNodeLevelMemoryCancellationThresholdCase2() { + Settings settings = Settings.builder().put(NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME, 0.8).build(); ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); - assertThrows(IllegalArgumentException.class, () -> queryGroupServiceSettings.setNodeLevelMemoryRejectionThreshold(0.96)); + queryGroupServiceSettings.setNodeLevelMemoryCancellationThreshold(0.83); + assertEquals(0.83, queryGroupServiceSettings.getNodeLevelMemoryCancellationThreshold(), 1e-9); } /** * Tests the invalid value for {@code query_group.node.memory_cancellation_threshold} * When the value is set more than {@literal 0.95} */ - public void testInValidNodeLevelCpuCancellationThresholdCase1() { - Settings settings = Settings.builder().put(NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME, 0.80).build(); + public void testInvalidNodeLevelMemoryCancellationThresholdCase1() { + Settings settings = Settings.builder().put(NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME, 0.9).build(); ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); - assertThrows(IllegalArgumentException.class, () -> queryGroupServiceSettings.setNodeLevelCpuRejectionThreshold(0.96)); + assertThrows(IllegalArgumentException.class, () -> queryGroupServiceSettings.setNodeLevelMemoryCancellationThreshold(0.96)); } /** * Tests the invalid value for {@code query_group.node.memory_cancellation_threshold} * When the value is set less than {@code query_group.node.memory_rejection_threshold} */ - public void testInValidNodeLevelMemoryCancellationThresholdCase2() { + public void testInvalidNodeLevelMemoryCancellationThresholdCase2() { Settings settings = Settings.builder() - .put(NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME, 0.70) - .put(NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME, 0.80) + .put(NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME, 0.7) + .put(NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME, 0.8) .build(); ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); - assertThrows(IllegalArgumentException.class, () -> queryGroupServiceSettings.setNodeLevelMemoryRejectionThreshold(0.85)); + assertThrows(IllegalArgumentException.class, () -> queryGroupServiceSettings.setNodeLevelMemoryCancellationThreshold(0.65)); } /** - * Tests the invalid value for {@code query_group.node.cpu_cancellation_threshold} - * When the value is set less than {@code query_group.node.cpu_rejection_threshold} + * Tests the valid value for {@code query_group.node.memory_rejection_threshold} */ - public void testInValidNodeLevelCpuCancellationThresholdCase2() { + public void testValidNodeLevelMemoryRejectionThresholdCase1() { + Settings settings = Settings.builder().put(NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME, 0.79).build(); + ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); + QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); + assertEquals(0.79, queryGroupServiceSettings.getNodeLevelMemoryRejectionThreshold(), 1e-9); + } + + /** + * Tests the valid value for {@code query_group.node.memory_rejection_threshold} + * Using setNodeLevelMemoryRejectionThreshold function + */ + public void testValidNodeLevelMemoryRejectionThresholdCase2() { + Settings settings = Settings.builder().put(NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME, 0.9).build(); + ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); + QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); + queryGroupServiceSettings.setNodeLevelMemoryRejectionThreshold(0.86); + assertEquals(0.86, queryGroupServiceSettings.getNodeLevelMemoryRejectionThreshold(), 1e-9); + } + + /** + * Tests the invalid value for {@code query_group.node.memory_rejection_threshold} + * When the value is set more than {@literal 0.9} + */ + public void testInvalidNodeLevelMemoryRejectionThresholdCase1() { + Settings settings = Settings.builder().put(NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME, 0.9).build(); + ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); + QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); + assertThrows(IllegalArgumentException.class, () -> queryGroupServiceSettings.setNodeLevelMemoryRejectionThreshold(0.92)); + } + + /** + * Tests the invalid value for {@code query_group.node.memory_rejection_threshold} + * When the value is set more than {@code query_group.node.memory_cancellation_threshold} + */ + public void testInvalidNodeLevelMemoryRejectionThresholdCase2() { Settings settings = Settings.builder() - .put(NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME, 0.70) - .put(NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME, 0.80) + .put(NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME, 0.7) + .put(NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME, 0.8) .build(); ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); - assertThrows(IllegalArgumentException.class, () -> queryGroupServiceSettings.setNodeLevelCpuRejectionThreshold(0.85)); + assertThrows(IllegalArgumentException.class, () -> queryGroupServiceSettings.setNodeLevelMemoryRejectionThreshold(0.85)); } - } From dc8a8f623e5476264a33ae96b4b630200b9c3aca Mon Sep 17 00:00:00 2001 From: Ruirui Zhang Date: Wed, 31 Jul 2024 17:31:33 -0700 Subject: [PATCH 6/7] remove QUERY_GROUP_RUN_INTERVAL_SETTING as we'll define it in QueryGroupService Signed-off-by: Ruirui Zhang --- .../QueryGroupServiceSettings.java | 74 ++++++------------- 1 file changed, 24 insertions(+), 50 deletions(-) diff --git a/server/src/main/java/org/opensearch/search/query_group/QueryGroupServiceSettings.java b/server/src/main/java/org/opensearch/search/query_group/QueryGroupServiceSettings.java index 00740acbd1d99..396887a3fffc9 100644 --- a/server/src/main/java/org/opensearch/search/query_group/QueryGroupServiceSettings.java +++ b/server/src/main/java/org/opensearch/search/query_group/QueryGroupServiceSettings.java @@ -11,13 +11,11 @@ import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.settings.Setting; import org.opensearch.common.settings.Settings; -import org.opensearch.common.unit.TimeValue; /** * Main class to declare the QueryGroup feature related settings */ public class QueryGroupServiceSettings { - private static final Long DEFAULT_RUN_INTERVAL_MILLIS = 1000l; private static final Double DEFAULT_NODE_LEVEL_MEMORY_REJECTION_THRESHOLD = 0.8; private static final Double DEFAULT_NODE_LEVEL_MEMORY_CANCELLATION_THRESHOLD = 0.9; private static final Double DEFAULT_NODE_LEVEL_CPU_REJECTION_THRESHOLD = 0.8; @@ -27,32 +25,17 @@ public class QueryGroupServiceSettings { public static final double NODE_LEVEL_CPU_CANCELLATION_THRESHOLD_MAX_VALUE = 0.95; public static final double NODE_LEVEL_CPU_REJECTION_THRESHOLD_MAX_VALUE = 0.9; - private TimeValue runIntervalMillis; private Double nodeLevelMemoryCancellationThreshold; private Double nodeLevelMemoryRejectionThreshold; private Double nodeLevelCpuCancellationThreshold; private Double nodeLevelCpuRejectionThreshold; - /** - * Setting name for the run interval of QueryGroup service - */ - public static final String SERVICE_RUN_INTERVAL_MILLIS_SETTING_NAME = "query_group.service.run_interval_millis"; - /** - * Setting to control the run interval of QueryGroup service - */ - private static final Setting QUERY_GROUP_RUN_INTERVAL_SETTING = Setting.longSetting( - SERVICE_RUN_INTERVAL_MILLIS_SETTING_NAME, - DEFAULT_RUN_INTERVAL_MILLIS, - 1, - Setting.Property.Dynamic, - Setting.Property.NodeScope - ); /** - * Setting name for node level memory rejection threshold for QueryGroup service + * Setting name for node level memory based rejection threshold for QueryGroup service */ public static final String NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME = "query_group.node.memory_rejection_threshold"; /** - * Setting to control the memory rejection threshold + * Setting to control the memory based rejection threshold */ public static final Setting NODE_LEVEL_MEMORY_REJECTION_THRESHOLD = Setting.doubleSetting( NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME, @@ -61,11 +44,11 @@ public class QueryGroupServiceSettings { Setting.Property.NodeScope ); /** - * Setting name for node level cpu rejection threshold for QueryGroup service + * Setting name for node level cpu based rejection threshold for QueryGroup service */ public static final String NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME = "query_group.node.cpu_rejection_threshold"; /** - * Setting to control the cpu rejection threshold + * Setting to control the cpu based rejection threshold */ public static final Setting NODE_LEVEL_CPU_REJECTION_THRESHOLD = Setting.doubleSetting( NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME, @@ -74,11 +57,11 @@ public class QueryGroupServiceSettings { Setting.Property.NodeScope ); /** - * Setting name for node level memory cancellation threshold for QueryGroup service + * Setting name for node level memory based cancellation threshold for QueryGroup service */ public static final String NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME = "query_group.node.memory_cancellation_threshold"; /** - * Setting to control the memory cancellation threshold + * Setting to control the memory based cancellation threshold */ public static final Setting NODE_LEVEL_MEMORY_CANCELLATION_THRESHOLD = Setting.doubleSetting( NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME, @@ -87,11 +70,11 @@ public class QueryGroupServiceSettings { Setting.Property.NodeScope ); /** - * Setting name for node level cpu cancellation threshold for QueryGroup service + * Setting name for node level cpu based cancellation threshold for QueryGroup service */ public static final String NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME = "query_group.node.cpu_cancellation_threshold"; /** - * Setting to control the cpu cancellation threshold + * Setting to control the cpu based cancellation threshold */ public static final Setting NODE_LEVEL_CPU_CANCELLATION_THRESHOLD = Setting.doubleSetting( NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME, @@ -106,7 +89,6 @@ public class QueryGroupServiceSettings { * @param clusterSettings - QueryGroup cluster settings */ public QueryGroupServiceSettings(Settings settings, ClusterSettings clusterSettings) { - runIntervalMillis = new TimeValue(QUERY_GROUP_RUN_INTERVAL_SETTING.get(settings)); nodeLevelMemoryCancellationThreshold = NODE_LEVEL_MEMORY_CANCELLATION_THRESHOLD.get(settings); nodeLevelMemoryRejectionThreshold = NODE_LEVEL_MEMORY_REJECTION_THRESHOLD.get(settings); nodeLevelCpuCancellationThreshold = NODE_LEVEL_CPU_CANCELLATION_THRESHOLD.get(settings); @@ -132,24 +114,16 @@ public QueryGroupServiceSettings(Settings settings, ClusterSettings clusterSetti } /** - * Method to get runInterval for QueryGroup service - * @return runInterval in milliseconds for QueryGroup service - */ - public TimeValue getRunIntervalMillis() { - return runIntervalMillis; - } - - /** - * Method to get the node level memory cancellation threshold - * @return current node level memory cancellation threshold + * Method to get the node level memory based cancellation threshold + * @return current node level memory based cancellation threshold */ public Double getNodeLevelMemoryCancellationThreshold() { return nodeLevelMemoryCancellationThreshold; } /** - * Method to set the node level memory cancellation threshold - * @param nodeLevelMemoryCancellationThreshold sets the new node level memory cancellation threshold + * Method to set the node level memory based cancellation threshold + * @param nodeLevelMemoryCancellationThreshold sets the new node level memory based cancellation threshold * @throws IllegalArgumentException if the value is > 0.95 and cancellation < rejection threshold */ public void setNodeLevelMemoryCancellationThreshold(Double nodeLevelMemoryCancellationThreshold) { @@ -170,16 +144,16 @@ public void setNodeLevelMemoryCancellationThreshold(Double nodeLevelMemoryCancel } /** - * Method to get the node level cpu cancellation threshold - * @return current node level cpu cancellation threshold + * Method to get the node level cpu based cancellation threshold + * @return current node level cpu based cancellation threshold */ public Double getNodeLevelCpuCancellationThreshold() { return nodeLevelCpuCancellationThreshold; } /** - * Method to set the node level cpu cancellation threshold - * @param nodeLevelCpuCancellationThreshold sets the new node level cpu cancellation threshold + * Method to set the node level cpu based cancellation threshold + * @param nodeLevelCpuCancellationThreshold sets the new node level cpu based cancellation threshold * @throws IllegalArgumentException if the value is > 0.95 and cancellation < rejection threshold */ public void setNodeLevelCpuCancellationThreshold(Double nodeLevelCpuCancellationThreshold) { @@ -200,16 +174,16 @@ public void setNodeLevelCpuCancellationThreshold(Double nodeLevelCpuCancellation } /** - * Method to get the memory node level rejection threshold - * @return the current memory node level rejection threshold + * Method to get the memory based node level rejection threshold + * @return the current memory based node level rejection threshold */ public Double getNodeLevelMemoryRejectionThreshold() { return nodeLevelMemoryRejectionThreshold; } /** - * Method to set the node level memory rejection threshold - * @param nodeLevelMemoryRejectionThreshold sets the new memory rejection threshold + * Method to set the node level memory based rejection threshold + * @param nodeLevelMemoryRejectionThreshold sets the new memory based rejection threshold * @throws IllegalArgumentException if rejection > 0.90 and rejection < cancellation threshold */ public void setNodeLevelMemoryRejectionThreshold(Double nodeLevelMemoryRejectionThreshold) { @@ -230,16 +204,16 @@ public void setNodeLevelMemoryRejectionThreshold(Double nodeLevelMemoryRejection } /** - * Method to get the cpu node level rejection threshold - * @return the current cpu node level rejection threshold + * Method to get the cpu based node level rejection threshold + * @return the current cpu based node level rejection threshold */ public Double getNodeLevelCpuRejectionThreshold() { return nodeLevelCpuRejectionThreshold; } /** - * Method to set the node level cpu rejection threshold - * @param nodeLevelCpuRejectionThreshold sets the new cpu rejection threshold + * Method to set the node level cpu based rejection threshold + * @param nodeLevelCpuRejectionThreshold sets the new cpu based rejection threshold * @throws IllegalArgumentException if rejection > 0.90 and rejection < cancellation threshold */ public void setNodeLevelCpuRejectionThreshold(Double nodeLevelCpuRejectionThreshold) { From 47b91d65148cddfe9b24de202e91bfbc2bd1f494 Mon Sep 17 00:00:00 2001 From: Ruirui Zhang Date: Tue, 20 Aug 2024 13:39:23 -0700 Subject: [PATCH 7/7] address comments Signed-off-by: Ruirui Zhang --- CHANGELOG.md | 2 +- .../common/settings/ClusterSettings.java | 12 +- .../search/query_group/package-info.java | 12 -- .../WorkloadManagementSettings.java} | 24 +-- .../WorkloadManagementSettingsTests.java} | 144 +++++++++--------- 5 files changed, 91 insertions(+), 103 deletions(-) delete mode 100644 server/src/main/java/org/opensearch/search/query_group/package-info.java rename server/src/main/java/org/opensearch/{search/query_group/QueryGroupServiceSettings.java => wlm/WorkloadManagementSettings.java} (93%) rename server/src/test/java/org/opensearch/{search/query_group/QueryGroupServiceSettingsTests.java => wlm/WorkloadManagementSettingsTests.java} (51%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d0e37cd1d829..8970993b55632 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Add `rangeQuery` and `regexpQuery` for `constant_keyword` field type ([#14711](https://github.com/opensearch-project/OpenSearch/pull/14711)) - Add took time to request nodes stats ([#15054](https://github.com/opensearch-project/OpenSearch/pull/15054)) - [Workload Management] Add Get QueryGroup API Logic ([14709](https://github.com/opensearch-project/OpenSearch/pull/14709)) -- [Workload Management] Add QueryGroupServiceSettings ([#15028](https://github.com/opensearch-project/OpenSearch/pull/15028)) +- [Workload Management] Add Settings for Workload Management feature ([#15028](https://github.com/opensearch-project/OpenSearch/pull/15028)) - [Workload Management] QueryGroup resource tracking framework changes ([#13897](https://github.com/opensearch-project/OpenSearch/pull/13897)) - Support filtering on a large list encoded by bitmap ([#14774](https://github.com/opensearch-project/OpenSearch/pull/14774)) - Add slice execution listeners to SearchOperationListener interface ([#15153](https://github.com/opensearch-project/OpenSearch/pull/15153)) diff --git a/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java b/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java index 6efb3b4febcb4..49ef87838ed2e 100644 --- a/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java +++ b/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java @@ -159,7 +159,6 @@ import org.opensearch.search.backpressure.settings.SearchShardTaskSettings; import org.opensearch.search.backpressure.settings.SearchTaskSettings; import org.opensearch.search.fetch.subphase.highlight.FastVectorHighlighter; -import org.opensearch.search.query_group.QueryGroupServiceSettings; import org.opensearch.snapshots.InternalSnapshotsInfoService; import org.opensearch.snapshots.SnapshotsService; import org.opensearch.tasks.TaskCancellationMonitoringSettings; @@ -174,6 +173,7 @@ import org.opensearch.transport.SniffConnectionStrategy; import org.opensearch.transport.TransportSettings; import org.opensearch.watcher.ResourceWatcherService; +import org.opensearch.wlm.WorkloadManagementSettings; import java.util.Arrays; import java.util.Collections; @@ -769,11 +769,11 @@ public void apply(Settings value, Settings current, Settings previous) { SystemTemplatesService.SETTING_APPLICATION_BASED_CONFIGURATION_TEMPLATES_ENABLED, - // QueryGroup settings - QueryGroupServiceSettings.NODE_LEVEL_CPU_REJECTION_THRESHOLD, - QueryGroupServiceSettings.NODE_LEVEL_CPU_CANCELLATION_THRESHOLD, - QueryGroupServiceSettings.NODE_LEVEL_MEMORY_REJECTION_THRESHOLD, - QueryGroupServiceSettings.NODE_LEVEL_MEMORY_CANCELLATION_THRESHOLD + // WorkloadManagement settings + WorkloadManagementSettings.NODE_LEVEL_CPU_REJECTION_THRESHOLD, + WorkloadManagementSettings.NODE_LEVEL_CPU_CANCELLATION_THRESHOLD, + WorkloadManagementSettings.NODE_LEVEL_MEMORY_REJECTION_THRESHOLD, + WorkloadManagementSettings.NODE_LEVEL_MEMORY_CANCELLATION_THRESHOLD ) ) ); diff --git a/server/src/main/java/org/opensearch/search/query_group/package-info.java b/server/src/main/java/org/opensearch/search/query_group/package-info.java deleted file mode 100644 index ee6c5692f32c7..0000000000000 --- a/server/src/main/java/org/opensearch/search/query_group/package-info.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/** - * QueryGroup related settings - */ -package org.opensearch.search.query_group; diff --git a/server/src/main/java/org/opensearch/search/query_group/QueryGroupServiceSettings.java b/server/src/main/java/org/opensearch/wlm/WorkloadManagementSettings.java similarity index 93% rename from server/src/main/java/org/opensearch/search/query_group/QueryGroupServiceSettings.java rename to server/src/main/java/org/opensearch/wlm/WorkloadManagementSettings.java index 396887a3fffc9..b104925df77b3 100644 --- a/server/src/main/java/org/opensearch/search/query_group/QueryGroupServiceSettings.java +++ b/server/src/main/java/org/opensearch/wlm/WorkloadManagementSettings.java @@ -6,16 +6,16 @@ * compatible open source license. */ -package org.opensearch.search.query_group; +package org.opensearch.wlm; import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.settings.Setting; import org.opensearch.common.settings.Settings; /** - * Main class to declare the QueryGroup feature related settings + * Main class to declare Workload Management related settings */ -public class QueryGroupServiceSettings { +public class WorkloadManagementSettings { private static final Double DEFAULT_NODE_LEVEL_MEMORY_REJECTION_THRESHOLD = 0.8; private static final Double DEFAULT_NODE_LEVEL_MEMORY_CANCELLATION_THRESHOLD = 0.9; private static final Double DEFAULT_NODE_LEVEL_CPU_REJECTION_THRESHOLD = 0.8; @@ -33,7 +33,7 @@ public class QueryGroupServiceSettings { /** * Setting name for node level memory based rejection threshold for QueryGroup service */ - public static final String NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME = "query_group.node.memory_rejection_threshold"; + public static final String NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME = "wlm.query_group.node.memory_rejection_threshold"; /** * Setting to control the memory based rejection threshold */ @@ -46,7 +46,7 @@ public class QueryGroupServiceSettings { /** * Setting name for node level cpu based rejection threshold for QueryGroup service */ - public static final String NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME = "query_group.node.cpu_rejection_threshold"; + public static final String NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME = "wlm.query_group.node.cpu_rejection_threshold"; /** * Setting to control the cpu based rejection threshold */ @@ -59,7 +59,7 @@ public class QueryGroupServiceSettings { /** * Setting name for node level memory based cancellation threshold for QueryGroup service */ - public static final String NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME = "query_group.node.memory_cancellation_threshold"; + public static final String NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME = "wlm.query_group.node.memory_cancellation_threshold"; /** * Setting to control the memory based cancellation threshold */ @@ -72,7 +72,7 @@ public class QueryGroupServiceSettings { /** * Setting name for node level cpu based cancellation threshold for QueryGroup service */ - public static final String NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME = "query_group.node.cpu_cancellation_threshold"; + public static final String NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME = "wlm.query_group.node.cpu_cancellation_threshold"; /** * Setting to control the cpu based cancellation threshold */ @@ -88,7 +88,7 @@ public class QueryGroupServiceSettings { * @param settings - QueryGroup service settings * @param clusterSettings - QueryGroup cluster settings */ - public QueryGroupServiceSettings(Settings settings, ClusterSettings clusterSettings) { + public WorkloadManagementSettings(Settings settings, ClusterSettings clusterSettings) { nodeLevelMemoryCancellationThreshold = NODE_LEVEL_MEMORY_CANCELLATION_THRESHOLD.get(settings); nodeLevelMemoryRejectionThreshold = NODE_LEVEL_MEMORY_REJECTION_THRESHOLD.get(settings); nodeLevelCpuCancellationThreshold = NODE_LEVEL_CPU_CANCELLATION_THRESHOLD.get(settings); @@ -129,7 +129,7 @@ public Double getNodeLevelMemoryCancellationThreshold() { public void setNodeLevelMemoryCancellationThreshold(Double nodeLevelMemoryCancellationThreshold) { if (Double.compare(nodeLevelMemoryCancellationThreshold, NODE_LEVEL_MEMORY_CANCELLATION_THRESHOLD_MAX_VALUE) > 0) { throw new IllegalArgumentException( - NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME + " value should not be greater than 0.95 as it pose a threat of node drop" + NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME + " value cannot be greater than 0.95 as it can result in a node drop" ); } @@ -159,7 +159,7 @@ public Double getNodeLevelCpuCancellationThreshold() { public void setNodeLevelCpuCancellationThreshold(Double nodeLevelCpuCancellationThreshold) { if (Double.compare(nodeLevelCpuCancellationThreshold, NODE_LEVEL_CPU_CANCELLATION_THRESHOLD_MAX_VALUE) > 0) { throw new IllegalArgumentException( - NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME + " value should not be greater than 0.95 as it pose a threat of node drop" + NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME + " value cannot be greater than 0.95 as it can result in a node drop" ); } @@ -189,7 +189,7 @@ public Double getNodeLevelMemoryRejectionThreshold() { public void setNodeLevelMemoryRejectionThreshold(Double nodeLevelMemoryRejectionThreshold) { if (Double.compare(nodeLevelMemoryRejectionThreshold, NODE_LEVEL_MEMORY_REJECTION_THRESHOLD_MAX_VALUE) > 0) { throw new IllegalArgumentException( - NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME + " value not be greater than 0.90 as it pose a threat of node drop" + NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME + " value cannot be greater than 0.90 as it can result in a node drop" ); } @@ -219,7 +219,7 @@ public Double getNodeLevelCpuRejectionThreshold() { public void setNodeLevelCpuRejectionThreshold(Double nodeLevelCpuRejectionThreshold) { if (Double.compare(nodeLevelCpuRejectionThreshold, NODE_LEVEL_CPU_REJECTION_THRESHOLD_MAX_VALUE) > 0) { throw new IllegalArgumentException( - NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME + " value not be greater than 0.90 as it pose a threat of node drop" + NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME + " value cannot be greater than 0.90 as it can result in a node drop" ); } diff --git a/server/src/test/java/org/opensearch/search/query_group/QueryGroupServiceSettingsTests.java b/server/src/test/java/org/opensearch/wlm/WorkloadManagementSettingsTests.java similarity index 51% rename from server/src/test/java/org/opensearch/search/query_group/QueryGroupServiceSettingsTests.java rename to server/src/test/java/org/opensearch/wlm/WorkloadManagementSettingsTests.java index 021b399d8c87a..0f183555781d3 100644 --- a/server/src/test/java/org/opensearch/search/query_group/QueryGroupServiceSettingsTests.java +++ b/server/src/test/java/org/opensearch/wlm/WorkloadManagementSettingsTests.java @@ -6,87 +6,87 @@ * compatible open source license. */ -package org.opensearch.search.query_group; +package org.opensearch.wlm; import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.settings.Settings; import org.opensearch.test.OpenSearchTestCase; -import static org.opensearch.search.query_group.QueryGroupServiceSettings.NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME; -import static org.opensearch.search.query_group.QueryGroupServiceSettings.NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME; -import static org.opensearch.search.query_group.QueryGroupServiceSettings.NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME; -import static org.opensearch.search.query_group.QueryGroupServiceSettings.NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME; +import static org.opensearch.wlm.WorkloadManagementSettings.NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME; +import static org.opensearch.wlm.WorkloadManagementSettings.NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME; +import static org.opensearch.wlm.WorkloadManagementSettings.NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME; +import static org.opensearch.wlm.WorkloadManagementSettings.NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME; -public class QueryGroupServiceSettingsTests extends OpenSearchTestCase { +public class WorkloadManagementSettingsTests extends OpenSearchTestCase { /** - * Tests the invalid value for {@code query_group.node.memory_rejection_threshold} - * When the value is set more than {@code query_group.node.memory_cancellation_threshold} accidentally during - * new feature development. This test is to ensure that {@link QueryGroupServiceSettings} holds the + * Tests the invalid value for {@code wlm.query_group.node.memory_rejection_threshold} + * When the value is set more than {@code wlm.query_group.node.memory_cancellation_threshold} accidentally during + * new feature development. This test is to ensure that {@link WorkloadManagementSettings} holds the * invariant {@code nodeLevelRejectionThreshold < nodeLevelCancellationThreshold} */ - public void testInvalidMemoryInstantiationOfQueryGroupServiceSettings() { + public void testInvalidMemoryInstantiationOfWorkloadManagementSettings() { Settings settings = Settings.builder() .put(NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME, 0.8) .put(NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME, 0.7) .build(); ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); - assertThrows(IllegalArgumentException.class, () -> new QueryGroupServiceSettings(settings, cs)); + assertThrows(IllegalArgumentException.class, () -> new WorkloadManagementSettings(settings, cs)); } /** - * Tests the invalid value for {@code query_group.node.cpu_rejection_threshold} - * When the value is set more than {@code query_group.node.cpu_cancellation_threshold} accidentally during - * new feature development. This test is to ensure that {@link QueryGroupServiceSettings} holds the + * Tests the invalid value for {@code wlm.query_group.node.cpu_rejection_threshold} + * When the value is set more than {@code wlm.query_group.node.cpu_cancellation_threshold} accidentally during + * new feature development. This test is to ensure that {@link WorkloadManagementSettings} holds the * invariant {@code nodeLevelRejectionThreshold < nodeLevelCancellationThreshold} */ - public void testInvalidCpuInstantiationOfQueryGroupServiceSettings() { + public void testInvalidCpuInstantiationOfWorkloadManagementSettings() { Settings settings = Settings.builder() .put(NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME, 0.8) .put(NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME, 0.7) .build(); ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); - assertThrows(IllegalArgumentException.class, () -> new QueryGroupServiceSettings(settings, cs)); + assertThrows(IllegalArgumentException.class, () -> new WorkloadManagementSettings(settings, cs)); } /** - * Tests the valid value for {@code query_group.node.cpu_rejection_threshold} + * Tests the valid value for {@code wlm.query_group.node.cpu_rejection_threshold} * Using setNodeLevelCpuRejectionThreshold function */ public void testValidNodeLevelCpuRejectionThresholdCase1() { Settings settings = Settings.builder().put(NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME, 0.8).build(); ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); - QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); - queryGroupServiceSettings.setNodeLevelCpuRejectionThreshold(0.7); - assertEquals(0.7, queryGroupServiceSettings.getNodeLevelCpuRejectionThreshold(), 1e-9); + WorkloadManagementSettings workloadManagementSettings = new WorkloadManagementSettings(settings, cs); + workloadManagementSettings.setNodeLevelCpuRejectionThreshold(0.7); + assertEquals(0.7, workloadManagementSettings.getNodeLevelCpuRejectionThreshold(), 1e-9); } /** - * Tests the valid value for {@code query_group.node.cpu_rejection_threshold} + * Tests the valid value for {@code wlm.query_group.node.cpu_rejection_threshold} */ public void testValidNodeLevelCpuRejectionThresholdCase2() { Settings settings = Settings.builder().put(NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME, 0.79).build(); ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); - QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); - assertEquals(0.79, queryGroupServiceSettings.getNodeLevelCpuRejectionThreshold(), 1e-9); + WorkloadManagementSettings workloadManagementSettings = new WorkloadManagementSettings(settings, cs); + assertEquals(0.79, workloadManagementSettings.getNodeLevelCpuRejectionThreshold(), 1e-9); } /** - * Tests the invalid value for {@code query_group.node.cpu_rejection_threshold} + * Tests the invalid value for {@code wlm.query_group.node.cpu_rejection_threshold} * When the value is set more than {@literal 0.9} */ public void testInvalidNodeLevelCpuRejectionThresholdCase1() { Settings settings = Settings.builder().put(NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME, 0.8).build(); ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); - QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); - assertThrows(IllegalArgumentException.class, () -> queryGroupServiceSettings.setNodeLevelCpuRejectionThreshold(0.95)); + WorkloadManagementSettings workloadManagementSettings = new WorkloadManagementSettings(settings, cs); + assertThrows(IllegalArgumentException.class, () -> workloadManagementSettings.setNodeLevelCpuRejectionThreshold(0.95)); } /** - * Tests the invalid value for {@code query_group.node.cpu_rejection_threshold} - * When the value is set more than {@code query_group.node.cpu_cancellation_threshold} + * Tests the invalid value for {@code wlm.query_group.node.cpu_rejection_threshold} + * When the value is set more than {@code wlm.query_group.node.cpu_cancellation_threshold} */ public void testInvalidNodeLevelCpuRejectionThresholdCase2() { Settings settings = Settings.builder() @@ -94,46 +94,46 @@ public void testInvalidNodeLevelCpuRejectionThresholdCase2() { .put(NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME, 0.8) .build(); ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); - QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); - assertThrows(IllegalArgumentException.class, () -> queryGroupServiceSettings.setNodeLevelCpuRejectionThreshold(0.85)); + WorkloadManagementSettings workloadManagementSettings = new WorkloadManagementSettings(settings, cs); + assertThrows(IllegalArgumentException.class, () -> workloadManagementSettings.setNodeLevelCpuRejectionThreshold(0.85)); } /** - * Tests the valid value for {@code query_group.node.cpu_cancellation_threshold} + * Tests the valid value for {@code wlm.query_group.node.cpu_cancellation_threshold} */ public void testValidNodeLevelCpuCancellationThresholdCase1() { Settings settings = Settings.builder().put(NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME, 0.8).build(); ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); - QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); - assertEquals(0.8, queryGroupServiceSettings.getNodeLevelCpuRejectionThreshold(), 1e-9); + WorkloadManagementSettings workloadManagementSettings = new WorkloadManagementSettings(settings, cs); + assertEquals(0.8, workloadManagementSettings.getNodeLevelCpuRejectionThreshold(), 1e-9); } /** - * Tests the valid value for {@code query_group.node.cpu_cancellation_threshold} + * Tests the valid value for {@code wlm.query_group.node.cpu_cancellation_threshold} * Using setNodeLevelCpuCancellationThreshold function */ public void testValidNodeLevelCpuCancellationThresholdCase2() { Settings settings = Settings.builder().put(NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME, 0.8).build(); ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); - QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); - queryGroupServiceSettings.setNodeLevelCpuCancellationThreshold(0.83); - assertEquals(0.83, queryGroupServiceSettings.getNodeLevelCpuCancellationThreshold(), 1e-9); + WorkloadManagementSettings workloadManagementSettings = new WorkloadManagementSettings(settings, cs); + workloadManagementSettings.setNodeLevelCpuCancellationThreshold(0.83); + assertEquals(0.83, workloadManagementSettings.getNodeLevelCpuCancellationThreshold(), 1e-9); } /** - * Tests the invalid value for {@code query_group.node.cpu_cancellation_threshold} + * Tests the invalid value for {@code wlm.query_group.node.cpu_cancellation_threshold} * When the value is set more than {@literal 0.95} */ public void testInvalidNodeLevelCpuCancellationThresholdCase1() { Settings settings = Settings.builder().put(NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME, 0.9).build(); ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); - QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); - assertThrows(IllegalArgumentException.class, () -> queryGroupServiceSettings.setNodeLevelCpuCancellationThreshold(0.96)); + WorkloadManagementSettings workloadManagementSettings = new WorkloadManagementSettings(settings, cs); + assertThrows(IllegalArgumentException.class, () -> workloadManagementSettings.setNodeLevelCpuCancellationThreshold(0.96)); } /** - * Tests the invalid value for {@code query_group.node.cpu_cancellation_threshold} - * When the value is set less than {@code query_group.node.cpu_rejection_threshold} + * Tests the invalid value for {@code wlm.query_group.node.cpu_cancellation_threshold} + * When the value is set less than {@code wlm.query_group.node.cpu_rejection_threshold} */ public void testInvalidNodeLevelCpuCancellationThresholdCase2() { Settings settings = Settings.builder() @@ -141,46 +141,46 @@ public void testInvalidNodeLevelCpuCancellationThresholdCase2() { .put(NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME, 0.8) .build(); ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); - QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); - assertThrows(IllegalArgumentException.class, () -> queryGroupServiceSettings.setNodeLevelCpuCancellationThreshold(0.65)); + WorkloadManagementSettings workloadManagementSettings = new WorkloadManagementSettings(settings, cs); + assertThrows(IllegalArgumentException.class, () -> workloadManagementSettings.setNodeLevelCpuCancellationThreshold(0.65)); } /** - * Tests the valid value for {@code query_group.node.memory_cancellation_threshold} + * Tests the valid value for {@code wlm.query_group.node.memory_cancellation_threshold} */ public void testValidNodeLevelMemoryCancellationThresholdCase1() { Settings settings = Settings.builder().put(NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME, 0.8).build(); ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); - QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); - assertEquals(0.8, queryGroupServiceSettings.getNodeLevelMemoryCancellationThreshold(), 1e-9); + WorkloadManagementSettings workloadManagementSettings = new WorkloadManagementSettings(settings, cs); + assertEquals(0.8, workloadManagementSettings.getNodeLevelMemoryCancellationThreshold(), 1e-9); } /** - * Tests the valid value for {@code query_group.node.memory_cancellation_threshold} + * Tests the valid value for {@code wlm.query_group.node.memory_cancellation_threshold} * Using setNodeLevelMemoryCancellationThreshold function */ public void testValidNodeLevelMemoryCancellationThresholdCase2() { Settings settings = Settings.builder().put(NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME, 0.8).build(); ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); - QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); - queryGroupServiceSettings.setNodeLevelMemoryCancellationThreshold(0.83); - assertEquals(0.83, queryGroupServiceSettings.getNodeLevelMemoryCancellationThreshold(), 1e-9); + WorkloadManagementSettings workloadManagementSettings = new WorkloadManagementSettings(settings, cs); + workloadManagementSettings.setNodeLevelMemoryCancellationThreshold(0.83); + assertEquals(0.83, workloadManagementSettings.getNodeLevelMemoryCancellationThreshold(), 1e-9); } /** - * Tests the invalid value for {@code query_group.node.memory_cancellation_threshold} + * Tests the invalid value for {@code wlm.query_group.node.memory_cancellation_threshold} * When the value is set more than {@literal 0.95} */ public void testInvalidNodeLevelMemoryCancellationThresholdCase1() { Settings settings = Settings.builder().put(NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME, 0.9).build(); ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); - QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); - assertThrows(IllegalArgumentException.class, () -> queryGroupServiceSettings.setNodeLevelMemoryCancellationThreshold(0.96)); + WorkloadManagementSettings workloadManagementSettings = new WorkloadManagementSettings(settings, cs); + assertThrows(IllegalArgumentException.class, () -> workloadManagementSettings.setNodeLevelMemoryCancellationThreshold(0.96)); } /** - * Tests the invalid value for {@code query_group.node.memory_cancellation_threshold} - * When the value is set less than {@code query_group.node.memory_rejection_threshold} + * Tests the invalid value for {@code wlm.query_group.node.memory_cancellation_threshold} + * When the value is set less than {@code wlm.query_group.node.memory_rejection_threshold} */ public void testInvalidNodeLevelMemoryCancellationThresholdCase2() { Settings settings = Settings.builder() @@ -188,46 +188,46 @@ public void testInvalidNodeLevelMemoryCancellationThresholdCase2() { .put(NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME, 0.8) .build(); ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); - QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); - assertThrows(IllegalArgumentException.class, () -> queryGroupServiceSettings.setNodeLevelMemoryCancellationThreshold(0.65)); + WorkloadManagementSettings workloadManagementSettings = new WorkloadManagementSettings(settings, cs); + assertThrows(IllegalArgumentException.class, () -> workloadManagementSettings.setNodeLevelMemoryCancellationThreshold(0.65)); } /** - * Tests the valid value for {@code query_group.node.memory_rejection_threshold} + * Tests the valid value for {@code wlm.query_group.node.memory_rejection_threshold} */ public void testValidNodeLevelMemoryRejectionThresholdCase1() { Settings settings = Settings.builder().put(NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME, 0.79).build(); ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); - QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); - assertEquals(0.79, queryGroupServiceSettings.getNodeLevelMemoryRejectionThreshold(), 1e-9); + WorkloadManagementSettings workloadManagementSettings = new WorkloadManagementSettings(settings, cs); + assertEquals(0.79, workloadManagementSettings.getNodeLevelMemoryRejectionThreshold(), 1e-9); } /** - * Tests the valid value for {@code query_group.node.memory_rejection_threshold} + * Tests the valid value for {@code wlm.query_group.node.memory_rejection_threshold} * Using setNodeLevelMemoryRejectionThreshold function */ public void testValidNodeLevelMemoryRejectionThresholdCase2() { Settings settings = Settings.builder().put(NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME, 0.9).build(); ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); - QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); - queryGroupServiceSettings.setNodeLevelMemoryRejectionThreshold(0.86); - assertEquals(0.86, queryGroupServiceSettings.getNodeLevelMemoryRejectionThreshold(), 1e-9); + WorkloadManagementSettings workloadManagementSettings = new WorkloadManagementSettings(settings, cs); + workloadManagementSettings.setNodeLevelMemoryRejectionThreshold(0.86); + assertEquals(0.86, workloadManagementSettings.getNodeLevelMemoryRejectionThreshold(), 1e-9); } /** - * Tests the invalid value for {@code query_group.node.memory_rejection_threshold} + * Tests the invalid value for {@code wlm.query_group.node.memory_rejection_threshold} * When the value is set more than {@literal 0.9} */ public void testInvalidNodeLevelMemoryRejectionThresholdCase1() { Settings settings = Settings.builder().put(NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME, 0.9).build(); ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); - QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); - assertThrows(IllegalArgumentException.class, () -> queryGroupServiceSettings.setNodeLevelMemoryRejectionThreshold(0.92)); + WorkloadManagementSettings workloadManagementSettings = new WorkloadManagementSettings(settings, cs); + assertThrows(IllegalArgumentException.class, () -> workloadManagementSettings.setNodeLevelMemoryRejectionThreshold(0.92)); } /** - * Tests the invalid value for {@code query_group.node.memory_rejection_threshold} - * When the value is set more than {@code query_group.node.memory_cancellation_threshold} + * Tests the invalid value for {@code wlm.query_group.node.memory_rejection_threshold} + * When the value is set more than {@code wlm.query_group.node.memory_cancellation_threshold} */ public void testInvalidNodeLevelMemoryRejectionThresholdCase2() { Settings settings = Settings.builder() @@ -235,7 +235,7 @@ public void testInvalidNodeLevelMemoryRejectionThresholdCase2() { .put(NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME, 0.8) .build(); ClusterSettings cs = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); - QueryGroupServiceSettings queryGroupServiceSettings = new QueryGroupServiceSettings(settings, cs); - assertThrows(IllegalArgumentException.class, () -> queryGroupServiceSettings.setNodeLevelMemoryRejectionThreshold(0.85)); + WorkloadManagementSettings workloadManagementSettings = new WorkloadManagementSettings(settings, cs); + assertThrows(IllegalArgumentException.class, () -> workloadManagementSettings.setNodeLevelMemoryRejectionThreshold(0.85)); } }