Skip to content

Commit d8217dc

Browse files
committed
Add Settings related to Workload Management feature (opensearch-project#15028)
Signed-off-by: Ruirui Zhang <[email protected]>
1 parent 6b8ccb2 commit d8217dc

File tree

4 files changed

+509
-2
lines changed

4 files changed

+509
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55

66
## [Unreleased 2.x]
77
### Added
8+
89
- Add fingerprint ingest processor ([#13724](https://github.com/opensearch-project/OpenSearch/pull/13724))
910
- [Remote Store] Rate limiter for remote store low priority uploads ([#14374](https://github.com/opensearch-project/OpenSearch/pull/14374/))
1011
- Apply the date histogram rewrite optimization to range aggregation ([#13865](https://github.com/opensearch-project/OpenSearch/pull/13865))
1112
- [Writable Warm] Add composite directory implementation and integrate it with FileCache ([12782](https://github.com/opensearch-project/OpenSearch/pull/12782))
1213
- [Workload Management] Add QueryGroup schema ([13669](https://github.com/opensearch-project/OpenSearch/pull/13669))
14+
- [Workload Management] Add Settings for Workload Management feature ([#15028](https://github.com/opensearch-project/OpenSearch/pull/15028))
1315
- Add batching supported processor base type AbstractBatchingProcessor ([#14554](https://github.com/opensearch-project/OpenSearch/pull/14554))
1416
- Fix race condition while parsing derived fields from search definition ([14445](https://github.com/opensearch-project/OpenSearch/pull/14445))
1517
- Add allowlist setting for ingest-common and search-pipeline-common processors ([#14439](https://github.com/opensearch-project/OpenSearch/issues/14439))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,256 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
9+
package org.opensearch.wlm;
10+
11+
import org.opensearch.common.settings.ClusterSettings;
12+
import org.opensearch.common.settings.Setting;
13+
import org.opensearch.common.settings.Settings;
14+
15+
/**
16+
* Main class to declare Workload Management related settings
17+
*/
18+
public class WorkloadManagementSettings {
19+
private static final Double DEFAULT_NODE_LEVEL_MEMORY_REJECTION_THRESHOLD = 0.8;
20+
private static final Double DEFAULT_NODE_LEVEL_MEMORY_CANCELLATION_THRESHOLD = 0.9;
21+
private static final Double DEFAULT_NODE_LEVEL_CPU_REJECTION_THRESHOLD = 0.8;
22+
private static final Double DEFAULT_NODE_LEVEL_CPU_CANCELLATION_THRESHOLD = 0.9;
23+
public static final double NODE_LEVEL_MEMORY_CANCELLATION_THRESHOLD_MAX_VALUE = 0.95;
24+
public static final double NODE_LEVEL_MEMORY_REJECTION_THRESHOLD_MAX_VALUE = 0.9;
25+
public static final double NODE_LEVEL_CPU_CANCELLATION_THRESHOLD_MAX_VALUE = 0.95;
26+
public static final double NODE_LEVEL_CPU_REJECTION_THRESHOLD_MAX_VALUE = 0.9;
27+
28+
private Double nodeLevelMemoryCancellationThreshold;
29+
private Double nodeLevelMemoryRejectionThreshold;
30+
private Double nodeLevelCpuCancellationThreshold;
31+
private Double nodeLevelCpuRejectionThreshold;
32+
33+
/**
34+
* Setting name for node level memory based rejection threshold for QueryGroup service
35+
*/
36+
public static final String NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME = "wlm.query_group.node.memory_rejection_threshold";
37+
/**
38+
* Setting to control the memory based rejection threshold
39+
*/
40+
public static final Setting<Double> NODE_LEVEL_MEMORY_REJECTION_THRESHOLD = Setting.doubleSetting(
41+
NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME,
42+
DEFAULT_NODE_LEVEL_MEMORY_REJECTION_THRESHOLD,
43+
Setting.Property.Dynamic,
44+
Setting.Property.NodeScope
45+
);
46+
/**
47+
* Setting name for node level cpu based rejection threshold for QueryGroup service
48+
*/
49+
public static final String NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME = "wlm.query_group.node.cpu_rejection_threshold";
50+
/**
51+
* Setting to control the cpu based rejection threshold
52+
*/
53+
public static final Setting<Double> NODE_LEVEL_CPU_REJECTION_THRESHOLD = Setting.doubleSetting(
54+
NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME,
55+
DEFAULT_NODE_LEVEL_CPU_REJECTION_THRESHOLD,
56+
Setting.Property.Dynamic,
57+
Setting.Property.NodeScope
58+
);
59+
/**
60+
* Setting name for node level memory based cancellation threshold for QueryGroup service
61+
*/
62+
public static final String NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME = "wlm.query_group.node.memory_cancellation_threshold";
63+
/**
64+
* Setting to control the memory based cancellation threshold
65+
*/
66+
public static final Setting<Double> NODE_LEVEL_MEMORY_CANCELLATION_THRESHOLD = Setting.doubleSetting(
67+
NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME,
68+
DEFAULT_NODE_LEVEL_MEMORY_CANCELLATION_THRESHOLD,
69+
Setting.Property.Dynamic,
70+
Setting.Property.NodeScope
71+
);
72+
/**
73+
* Setting name for node level cpu based cancellation threshold for QueryGroup service
74+
*/
75+
public static final String NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME = "wlm.query_group.node.cpu_cancellation_threshold";
76+
/**
77+
* Setting to control the cpu based cancellation threshold
78+
*/
79+
public static final Setting<Double> NODE_LEVEL_CPU_CANCELLATION_THRESHOLD = Setting.doubleSetting(
80+
NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME,
81+
DEFAULT_NODE_LEVEL_CPU_CANCELLATION_THRESHOLD,
82+
Setting.Property.Dynamic,
83+
Setting.Property.NodeScope
84+
);
85+
86+
/**
87+
* QueryGroup service settings constructor
88+
* @param settings - QueryGroup service settings
89+
* @param clusterSettings - QueryGroup cluster settings
90+
*/
91+
public WorkloadManagementSettings(Settings settings, ClusterSettings clusterSettings) {
92+
nodeLevelMemoryCancellationThreshold = NODE_LEVEL_MEMORY_CANCELLATION_THRESHOLD.get(settings);
93+
nodeLevelMemoryRejectionThreshold = NODE_LEVEL_MEMORY_REJECTION_THRESHOLD.get(settings);
94+
nodeLevelCpuCancellationThreshold = NODE_LEVEL_CPU_CANCELLATION_THRESHOLD.get(settings);
95+
nodeLevelCpuRejectionThreshold = NODE_LEVEL_CPU_REJECTION_THRESHOLD.get(settings);
96+
97+
ensureRejectionThresholdIsLessThanCancellation(
98+
nodeLevelMemoryRejectionThreshold,
99+
nodeLevelMemoryCancellationThreshold,
100+
NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME,
101+
NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME
102+
);
103+
ensureRejectionThresholdIsLessThanCancellation(
104+
nodeLevelCpuRejectionThreshold,
105+
nodeLevelCpuCancellationThreshold,
106+
NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME,
107+
NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME
108+
);
109+
110+
clusterSettings.addSettingsUpdateConsumer(NODE_LEVEL_MEMORY_CANCELLATION_THRESHOLD, this::setNodeLevelMemoryCancellationThreshold);
111+
clusterSettings.addSettingsUpdateConsumer(NODE_LEVEL_MEMORY_REJECTION_THRESHOLD, this::setNodeLevelMemoryRejectionThreshold);
112+
clusterSettings.addSettingsUpdateConsumer(NODE_LEVEL_CPU_CANCELLATION_THRESHOLD, this::setNodeLevelCpuCancellationThreshold);
113+
clusterSettings.addSettingsUpdateConsumer(NODE_LEVEL_CPU_REJECTION_THRESHOLD, this::setNodeLevelCpuRejectionThreshold);
114+
}
115+
116+
/**
117+
* Method to get the node level memory based cancellation threshold
118+
* @return current node level memory based cancellation threshold
119+
*/
120+
public Double getNodeLevelMemoryCancellationThreshold() {
121+
return nodeLevelMemoryCancellationThreshold;
122+
}
123+
124+
/**
125+
* Method to set the node level memory based cancellation threshold
126+
* @param nodeLevelMemoryCancellationThreshold sets the new node level memory based cancellation threshold
127+
* @throws IllegalArgumentException if the value is &gt; 0.95 and cancellation &lt; rejection threshold
128+
*/
129+
public void setNodeLevelMemoryCancellationThreshold(Double nodeLevelMemoryCancellationThreshold) {
130+
if (Double.compare(nodeLevelMemoryCancellationThreshold, NODE_LEVEL_MEMORY_CANCELLATION_THRESHOLD_MAX_VALUE) > 0) {
131+
throw new IllegalArgumentException(
132+
NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME + " value cannot be greater than 0.95 as it can result in a node drop"
133+
);
134+
}
135+
136+
ensureRejectionThresholdIsLessThanCancellation(
137+
nodeLevelMemoryRejectionThreshold,
138+
nodeLevelMemoryCancellationThreshold,
139+
NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME,
140+
NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME
141+
);
142+
143+
this.nodeLevelMemoryCancellationThreshold = nodeLevelMemoryCancellationThreshold;
144+
}
145+
146+
/**
147+
* Method to get the node level cpu based cancellation threshold
148+
* @return current node level cpu based cancellation threshold
149+
*/
150+
public Double getNodeLevelCpuCancellationThreshold() {
151+
return nodeLevelCpuCancellationThreshold;
152+
}
153+
154+
/**
155+
* Method to set the node level cpu based cancellation threshold
156+
* @param nodeLevelCpuCancellationThreshold sets the new node level cpu based cancellation threshold
157+
* @throws IllegalArgumentException if the value is &gt; 0.95 and cancellation &lt; rejection threshold
158+
*/
159+
public void setNodeLevelCpuCancellationThreshold(Double nodeLevelCpuCancellationThreshold) {
160+
if (Double.compare(nodeLevelCpuCancellationThreshold, NODE_LEVEL_CPU_CANCELLATION_THRESHOLD_MAX_VALUE) > 0) {
161+
throw new IllegalArgumentException(
162+
NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME + " value cannot be greater than 0.95 as it can result in a node drop"
163+
);
164+
}
165+
166+
ensureRejectionThresholdIsLessThanCancellation(
167+
nodeLevelCpuRejectionThreshold,
168+
nodeLevelCpuCancellationThreshold,
169+
NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME,
170+
NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME
171+
);
172+
173+
this.nodeLevelCpuCancellationThreshold = nodeLevelCpuCancellationThreshold;
174+
}
175+
176+
/**
177+
* Method to get the memory based node level rejection threshold
178+
* @return the current memory based node level rejection threshold
179+
*/
180+
public Double getNodeLevelMemoryRejectionThreshold() {
181+
return nodeLevelMemoryRejectionThreshold;
182+
}
183+
184+
/**
185+
* Method to set the node level memory based rejection threshold
186+
* @param nodeLevelMemoryRejectionThreshold sets the new memory based rejection threshold
187+
* @throws IllegalArgumentException if rejection &gt; 0.90 and rejection &lt; cancellation threshold
188+
*/
189+
public void setNodeLevelMemoryRejectionThreshold(Double nodeLevelMemoryRejectionThreshold) {
190+
if (Double.compare(nodeLevelMemoryRejectionThreshold, NODE_LEVEL_MEMORY_REJECTION_THRESHOLD_MAX_VALUE) > 0) {
191+
throw new IllegalArgumentException(
192+
NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME + " value cannot be greater than 0.90 as it can result in a node drop"
193+
);
194+
}
195+
196+
ensureRejectionThresholdIsLessThanCancellation(
197+
nodeLevelMemoryRejectionThreshold,
198+
nodeLevelMemoryCancellationThreshold,
199+
NODE_MEMORY_REJECTION_THRESHOLD_SETTING_NAME,
200+
NODE_MEMORY_CANCELLATION_THRESHOLD_SETTING_NAME
201+
);
202+
203+
this.nodeLevelMemoryRejectionThreshold = nodeLevelMemoryRejectionThreshold;
204+
}
205+
206+
/**
207+
* Method to get the cpu based node level rejection threshold
208+
* @return the current cpu based node level rejection threshold
209+
*/
210+
public Double getNodeLevelCpuRejectionThreshold() {
211+
return nodeLevelCpuRejectionThreshold;
212+
}
213+
214+
/**
215+
* Method to set the node level cpu based rejection threshold
216+
* @param nodeLevelCpuRejectionThreshold sets the new cpu based rejection threshold
217+
* @throws IllegalArgumentException if rejection &gt; 0.90 and rejection &lt; cancellation threshold
218+
*/
219+
public void setNodeLevelCpuRejectionThreshold(Double nodeLevelCpuRejectionThreshold) {
220+
if (Double.compare(nodeLevelCpuRejectionThreshold, NODE_LEVEL_CPU_REJECTION_THRESHOLD_MAX_VALUE) > 0) {
221+
throw new IllegalArgumentException(
222+
NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME + " value cannot be greater than 0.90 as it can result in a node drop"
223+
);
224+
}
225+
226+
ensureRejectionThresholdIsLessThanCancellation(
227+
nodeLevelCpuRejectionThreshold,
228+
nodeLevelCpuCancellationThreshold,
229+
NODE_CPU_REJECTION_THRESHOLD_SETTING_NAME,
230+
NODE_CPU_CANCELLATION_THRESHOLD_SETTING_NAME
231+
);
232+
233+
this.nodeLevelCpuRejectionThreshold = nodeLevelCpuRejectionThreshold;
234+
}
235+
236+
/**
237+
* Method to validate that the cancellation threshold is greater than or equal to rejection threshold
238+
* @param nodeLevelRejectionThreshold rejection threshold to be compared
239+
* @param nodeLevelCancellationThreshold cancellation threshold to be compared
240+
* @param rejectionThresholdSettingName name of the rejection threshold setting
241+
* @param cancellationThresholdSettingName name of the cancellation threshold setting
242+
* @throws IllegalArgumentException if cancellation threshold is less than rejection threshold
243+
*/
244+
private void ensureRejectionThresholdIsLessThanCancellation(
245+
Double nodeLevelRejectionThreshold,
246+
Double nodeLevelCancellationThreshold,
247+
String rejectionThresholdSettingName,
248+
String cancellationThresholdSettingName
249+
) {
250+
if (Double.compare(nodeLevelCancellationThreshold, nodeLevelRejectionThreshold) < 0) {
251+
throw new IllegalArgumentException(
252+
cancellationThresholdSettingName + " value should not be less than " + rejectionThresholdSettingName
253+
);
254+
}
255+
}
256+
}

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@
172172
import org.opensearch.transport.SniffConnectionStrategy;
173173
import org.opensearch.transport.TransportSettings;
174174
import org.opensearch.watcher.ResourceWatcherService;
175+
import org.opensearch.wlm.WorkloadManagementSettings;
175176

176177
import java.util.Arrays;
177178
import java.util.Collections;
@@ -731,7 +732,7 @@ public void apply(Settings value, Settings current, Settings previous) {
731732
RemoteStoreNodeService.MIGRATION_DIRECTION_SETTING,
732733

733734
IndicesService.CLUSTER_REMOTE_INDEX_RESTRICT_ASYNC_DURABILITY_SETTING,
734-
IndicesService.CLUSTER_INDEX_RESTRICT_REPLICATION_TYPE_SETTING,
735+
IndiceisService.CLUSTER_INDEX_RESTRICT_REPLICATION_TYPE_SETTING,
735736
InternalRemoteRoutingTableService.REMOTE_ROUTING_TABLE_PATH_TYPE_SETTING,
736737
InternalRemoteRoutingTableService.REMOTE_ROUTING_TABLE_PATH_HASH_ALGO_SETTING,
737738

@@ -756,7 +757,14 @@ public void apply(Settings value, Settings current, Settings previous) {
756757
RemoteStoreSettings.CLUSTER_REMOTE_STORE_PATH_HASH_ALGORITHM_SETTING,
757758
RemoteStoreSettings.CLUSTER_REMOTE_MAX_TRANSLOG_READERS,
758759
RemoteStoreSettings.CLUSTER_REMOTE_STORE_TRANSLOG_METADATA,
759-
SearchService.CLUSTER_ALLOW_DERIVED_FIELD_SETTING
760+
SearchService.CLUSTER_ALLOW_DERIVED_FIELD_SETTING,
761+
SystemTemplatesService.SETTING_APPLICATION_BASED_CONFIGURATION_TEMPLATES_ENABLED,
762+
763+
// WorkloadManagement settings
764+
WorkloadManagementSettings.NODE_LEVEL_CPU_REJECTION_THRESHOLD,
765+
WorkloadManagementSettings.NODE_LEVEL_CPU_CANCELLATION_THRESHOLD,
766+
WorkloadManagementSettings.NODE_LEVEL_MEMORY_REJECTION_THRESHOLD,
767+
WorkloadManagementSettings.NODE_LEVEL_MEMORY_CANCELLATION_THRESHOLD
760768
)
761769
)
762770
);

0 commit comments

Comments
 (0)