Skip to content

Commit 8ed7141

Browse files
committed
modify based on comment
Signed-off-by: Ruirui Zhang <mariazrr@amazon.com>
1 parent d2bcdf8 commit 8ed7141

23 files changed

+116
-109
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1515
- Introduce SecureHttpTransportParameters experimental API (to complement SecureTransportParameters counterpart) ([#18572](https://github.com/opensearch-project/OpenSearch/issues/18572))
1616
- Create equivalents of JSM's AccessController in the java agent ([#18346](https://github.com/opensearch-project/OpenSearch/issues/18346))
1717
- [WLM] Add WLM mode validation for workload group CRUD requests ([#18346](https://github.com/opensearch-project/OpenSearch/issues/18346))
18-
- Introduced a new cluster-level API to fetch remote store metadata (segments and translogs) for each shard of an index. ([#18652](https://github.com/opensearch-project/OpenSearch/pull/18652))
18+
- Introduced a new cluster-level API to fetch remote store metadata (segments and translogs) for each shard of an index. ([#18257](https://github.com/opensearch-project/OpenSearch/pull/18257))
1919
- Add last index request timestamp columns to the `_cat/indices` API. ([10766](https://github.com/opensearch-project/OpenSearch/issues/10766))
2020
- Introduce a new pull-based ingestion plugin for file-based indexing (for local testing) ([#18591](https://github.com/opensearch-project/OpenSearch/pull/18591))
2121
- Add support for search pipeline in search and msearch template ([#18564](https://github.com/opensearch-project/OpenSearch/pull/18564))
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@
1414
import org.opensearch.wlm.WorkloadManagementSettings;
1515

1616
/**
17-
* Central provider for maintaining and supplying the current values of non-plugin cluster settings.
17+
* Central provider for maintaining and supplying the current values of wlm cluster settings.
1818
* This class listens for updates to relevant settings and provides the latest setting values.
1919
*/
20-
public class NonPluginSettingValuesProvider {
20+
public class WlmClusterSettingValuesProvider {
2121

2222
private volatile WlmMode wlmMode;
2323

2424
/**
25-
* Constructor for NonPluginSettingValuesProvider
25+
* Constructor for WlmClusterSettingValuesProvider
2626
* @param settings OpenSearch settings
2727
* @param clusterSettings Cluster settings to register update listener
2828
*/
29-
public NonPluginSettingValuesProvider(Settings settings, ClusterSettings clusterSettings) {
29+
public WlmClusterSettingValuesProvider(Settings settings, ClusterSettings clusterSettings) {
3030
this.wlmMode = WorkloadManagementSettings.WLM_MODE_SETTING.get(settings);
3131
clusterSettings.addSettingsUpdateConsumer(WorkloadManagementSettings.WLM_MODE_SETTING, this::setWlmMode);
3232
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public class WorkloadManagementPlugin extends Plugin implements ActionPlugin, Sy
9191
private static FeatureType featureType;
9292
private static RulePersistenceService rulePersistenceService;
9393
private static RuleRoutingService ruleRoutingService;
94-
private NonPluginSettingValuesProvider nonPluginSettingValuesProvider;
94+
private WlmClusterSettingValuesProvider wlmClusterSettingValuesProvider;
9595
private AutoTaggingActionFilter autoTaggingActionFilter;
9696

9797
/**
@@ -113,7 +113,7 @@ public Collection<Object> createComponents(
113113
IndexNameExpressionResolver indexNameExpressionResolver,
114114
Supplier<RepositoriesService> repositoriesServiceSupplier
115115
) {
116-
nonPluginSettingValuesProvider = new NonPluginSettingValuesProvider(
116+
wlmClusterSettingValuesProvider = new WlmClusterSettingValuesProvider(
117117
clusterService.getSettings(),
118118
clusterService.getClusterSettings()
119119
);
@@ -140,7 +140,7 @@ public Collection<Object> createComponents(
140140
featureType,
141141
rulePersistenceService,
142142
new RuleEventClassifier(Collections.emptySet(), ruleProcessingService),
143-
nonPluginSettingValuesProvider
143+
wlmClusterSettingValuesProvider
144144
);
145145

146146
autoTaggingActionFilter = new AutoTaggingActionFilter(ruleProcessingService, threadPool);
@@ -184,10 +184,10 @@ public List<RestHandler> getRestHandlers(
184184
Supplier<DiscoveryNodes> nodesInCluster
185185
) {
186186
return List.of(
187-
new RestCreateWorkloadGroupAction(nonPluginSettingValuesProvider),
187+
new RestCreateWorkloadGroupAction(wlmClusterSettingValuesProvider),
188188
new RestGetWorkloadGroupAction(),
189-
new RestDeleteWorkloadGroupAction(nonPluginSettingValuesProvider),
190-
new RestUpdateWorkloadGroupAction(nonPluginSettingValuesProvider)
189+
new RestDeleteWorkloadGroupAction(wlmClusterSettingValuesProvider),
190+
new RestUpdateWorkloadGroupAction(wlmClusterSettingValuesProvider)
191191
);
192192
}
193193

plugins/workload-management/src/main/java/org/opensearch/plugin/wlm/rest/RestCreateWorkloadGroupAction.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import org.opensearch.core.rest.RestStatus;
1212
import org.opensearch.core.xcontent.ToXContent;
1313
import org.opensearch.core.xcontent.XContentParser;
14-
import org.opensearch.plugin.wlm.NonPluginSettingValuesProvider;
14+
import org.opensearch.plugin.wlm.WlmClusterSettingValuesProvider;
1515
import org.opensearch.plugin.wlm.action.CreateWorkloadGroupAction;
1616
import org.opensearch.plugin.wlm.action.CreateWorkloadGroupRequest;
1717
import org.opensearch.plugin.wlm.action.CreateWorkloadGroupResponse;
@@ -36,13 +36,13 @@
3636
*/
3737
public class RestCreateWorkloadGroupAction extends BaseRestHandler {
3838

39-
private final NonPluginSettingValuesProvider nonPluginSettingValuesProvider;
39+
private final WlmClusterSettingValuesProvider nonPluginSettingValuesProvider;
4040

4141
/**
4242
* Constructor for RestCreateWorkloadGroupAction
4343
* @param nonPluginSettingValuesProvider the settings provider to access the current WLM mode
4444
*/
45-
public RestCreateWorkloadGroupAction(NonPluginSettingValuesProvider nonPluginSettingValuesProvider) {
45+
public RestCreateWorkloadGroupAction(WlmClusterSettingValuesProvider nonPluginSettingValuesProvider) {
4646
this.nonPluginSettingValuesProvider = nonPluginSettingValuesProvider;
4747
}
4848

@@ -61,7 +61,7 @@ public List<Route> routes() {
6161

6262
@Override
6363
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
64-
nonPluginSettingValuesProvider.ensureWlmEnabled("create workload group");
64+
nonPluginSettingValuesProvider.ensureWlmEnabled(getName());
6565
try (XContentParser parser = request.contentParser()) {
6666
CreateWorkloadGroupRequest createWorkloadGroupRequest = CreateWorkloadGroupRequest.fromXContent(parser);
6767
return channel -> client.execute(

plugins/workload-management/src/main/java/org/opensearch/plugin/wlm/rest/RestDeleteWorkloadGroupAction.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
package org.opensearch.plugin.wlm.rest;
1010

11-
import org.opensearch.plugin.wlm.NonPluginSettingValuesProvider;
11+
import org.opensearch.plugin.wlm.WlmClusterSettingValuesProvider;
1212
import org.opensearch.plugin.wlm.action.DeleteWorkloadGroupAction;
1313
import org.opensearch.plugin.wlm.action.DeleteWorkloadGroupRequest;
1414
import org.opensearch.rest.BaseRestHandler;
@@ -28,13 +28,13 @@
2828
*/
2929
public class RestDeleteWorkloadGroupAction extends BaseRestHandler {
3030

31-
private final NonPluginSettingValuesProvider nonPluginSettingValuesProvider;
31+
private final WlmClusterSettingValuesProvider nonPluginSettingValuesProvider;
3232

3333
/**
3434
* Constructor for RestDeleteWorkloadGroupAction
3535
* @param nonPluginSettingValuesProvider the settings provider to access the current WLM mode
3636
*/
37-
public RestDeleteWorkloadGroupAction(NonPluginSettingValuesProvider nonPluginSettingValuesProvider) {
37+
public RestDeleteWorkloadGroupAction(WlmClusterSettingValuesProvider nonPluginSettingValuesProvider) {
3838
this.nonPluginSettingValuesProvider = nonPluginSettingValuesProvider;
3939
}
4040

@@ -53,7 +53,7 @@ public List<Route> routes() {
5353

5454
@Override
5555
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
56-
nonPluginSettingValuesProvider.ensureWlmEnabled("delete workload group");
56+
nonPluginSettingValuesProvider.ensureWlmEnabled(getName());
5757
DeleteWorkloadGroupRequest deleteWorkloadGroupRequest = new DeleteWorkloadGroupRequest(request.param("name"));
5858
deleteWorkloadGroupRequest.clusterManagerNodeTimeout(
5959
request.paramAsTime("cluster_manager_timeout", deleteWorkloadGroupRequest.clusterManagerNodeTimeout())

plugins/workload-management/src/main/java/org/opensearch/plugin/wlm/rest/RestUpdateWorkloadGroupAction.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import org.opensearch.core.rest.RestStatus;
1212
import org.opensearch.core.xcontent.ToXContent;
1313
import org.opensearch.core.xcontent.XContentParser;
14-
import org.opensearch.plugin.wlm.NonPluginSettingValuesProvider;
14+
import org.opensearch.plugin.wlm.WlmClusterSettingValuesProvider;
1515
import org.opensearch.plugin.wlm.action.UpdateWorkloadGroupAction;
1616
import org.opensearch.plugin.wlm.action.UpdateWorkloadGroupRequest;
1717
import org.opensearch.plugin.wlm.action.UpdateWorkloadGroupResponse;
@@ -36,13 +36,13 @@
3636
*/
3737
public class RestUpdateWorkloadGroupAction extends BaseRestHandler {
3838

39-
private final NonPluginSettingValuesProvider nonPluginSettingValuesProvider;
39+
private final WlmClusterSettingValuesProvider nonPluginSettingValuesProvider;
4040

4141
/**
4242
* Constructor for RestUpdateWorkloadGroupAction
4343
* @param nonPluginSettingValuesProvider the settings provider to access the current WLM mode
4444
*/
45-
public RestUpdateWorkloadGroupAction(NonPluginSettingValuesProvider nonPluginSettingValuesProvider) {
45+
public RestUpdateWorkloadGroupAction(WlmClusterSettingValuesProvider nonPluginSettingValuesProvider) {
4646
this.nonPluginSettingValuesProvider = nonPluginSettingValuesProvider;
4747
}
4848

@@ -61,7 +61,7 @@ public List<Route> routes() {
6161

6262
@Override
6363
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
64-
nonPluginSettingValuesProvider.ensureWlmEnabled("update workload group");
64+
nonPluginSettingValuesProvider.ensureWlmEnabled(getName());
6565
try (XContentParser parser = request.contentParser()) {
6666
UpdateWorkloadGroupRequest updateWorkloadGroupRequest = UpdateWorkloadGroupRequest.fromXContent(parser, request.param("name"));
6767
return channel -> client.execute(

plugins/workload-management/src/main/java/org/opensearch/plugin/wlm/rule/sync/RefreshBasedSyncMechanism.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import org.opensearch.common.settings.Settings;
1616
import org.opensearch.common.unit.TimeValue;
1717
import org.opensearch.core.action.ActionListener;
18-
import org.opensearch.plugin.wlm.NonPluginSettingValuesProvider;
18+
import org.opensearch.plugin.wlm.WlmClusterSettingValuesProvider;
1919
import org.opensearch.plugin.wlm.rule.sync.detect.RuleEvent;
2020
import org.opensearch.plugin.wlm.rule.sync.detect.RuleEventClassifier;
2121
import org.opensearch.rule.RulePersistenceService;
@@ -65,7 +65,7 @@ public class RefreshBasedSyncMechanism extends AbstractLifecycleComponent {
6565
private final RulePersistenceService rulePersistenceService;
6666
private final RuleEventClassifier ruleEventClassifier;
6767
private final FeatureType featureType;
68-
private final NonPluginSettingValuesProvider nonPluginSettingValuesProvider;
68+
private final WlmClusterSettingValuesProvider nonPluginSettingValuesProvider;
6969
// This var keeps the Rules which were present during last run of this service
7070
private Set<Rule> lastRunIndexedRules;
7171
private static final Logger logger = LogManager.getLogger(RefreshBasedSyncMechanism.class);
@@ -86,7 +86,7 @@ public RefreshBasedSyncMechanism(
8686
FeatureType featureType,
8787
RulePersistenceService rulePersistenceService,
8888
RuleEventClassifier ruleEventClassifier,
89-
NonPluginSettingValuesProvider nonPluginSettingValuesProvider
89+
WlmClusterSettingValuesProvider nonPluginSettingValuesProvider
9090
) {
9191
this.threadPool = threadPool;
9292
refreshInterval = RULE_SYNC_REFRESH_INTERVAL_SETTING.get(settings);
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818

1919
import java.util.HashSet;
2020

21-
public class NonPluginSettingValuesProviderTests extends OpenSearchTestCase {
21+
public class WlmClusterSettingValuesProviderTests extends OpenSearchTestCase {
2222

23-
private NonPluginSettingValuesProvider provider;
23+
private WlmClusterSettingValuesProvider provider;
2424
private ClusterSettings clusterSettings;
2525

2626
@Before
@@ -33,7 +33,7 @@ public void setUp() throws Exception {
3333
.build();
3434
clusterSettings = new ClusterSettings(Settings.EMPTY, new HashSet<>(plugin.getSettings()));
3535
clusterSettings.registerSetting(WorkloadManagementSettings.WLM_MODE_SETTING);
36-
provider = new NonPluginSettingValuesProvider(settings, clusterSettings);
36+
provider = new WlmClusterSettingValuesProvider(settings, clusterSettings);
3737
}
3838
}
3939

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
import static org.junit.Assert.assertTrue;
4141
import static org.mockito.Mockito.mock;
4242

43-
public class WorkloadGroupTestUtils {
43+
public class WorkloadManagementTestUtils {
4444
public static final String NAME_ONE = "workload_group_one";
4545
public static final String NAME_TWO = "workload_group_two";
4646
public static final String _ID_ONE = "AgfUO5Ja9yfsYlONlYi3TQ==";
@@ -168,15 +168,15 @@ public static void assertEqualWorkloadGroups(
168168
}
169169
}
170170

171-
public static NonPluginSettingValuesProvider setUpNonPluginSettingValuesProvider(String wlmMode) throws Exception {
171+
public static WlmClusterSettingValuesProvider setUpNonPluginSettingValuesProvider(String wlmMode) throws Exception {
172172
try (WorkloadManagementPlugin plugin = new WorkloadManagementPlugin()) {
173173
Settings settings = Settings.builder()
174174
.put(RefreshBasedSyncMechanism.RULE_SYNC_REFRESH_INTERVAL_SETTING_NAME, 1000)
175175
.put(WorkloadManagementSettings.WLM_MODE_SETTING_NAME, wlmMode)
176176
.build();
177177
ClusterSettings clusterSettings = new ClusterSettings(Settings.EMPTY, new HashSet<>(plugin.getSettings()));
178178
clusterSettings.registerSetting(WorkloadManagementSettings.WLM_MODE_SETTING);
179-
return new NonPluginSettingValuesProvider(settings, clusterSettings);
179+
return new WlmClusterSettingValuesProvider(settings, clusterSettings);
180180
}
181181
}
182182
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
import java.util.ArrayList;
1818
import java.util.List;
1919

20-
import static org.opensearch.plugin.wlm.WorkloadGroupTestUtils.assertEqualWorkloadGroups;
21-
import static org.opensearch.plugin.wlm.WorkloadGroupTestUtils.workloadGroupOne;
20+
import static org.opensearch.plugin.wlm.WorkloadManagementTestUtils.assertEqualWorkloadGroups;
21+
import static org.opensearch.plugin.wlm.WorkloadManagementTestUtils.workloadGroupOne;
2222

2323
public class CreateWorkloadGroupRequestTests extends OpenSearchTestCase {
2424

0 commit comments

Comments
 (0)