-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cluster setting to control ppl execution (#344)
* Add cluster setting to control ppl execution Signed-off-by: zane-neo <[email protected]> * format code Signed-off-by: zane-neo <[email protected]> * format code Signed-off-by: zane-neo <[email protected]> * Add debug log to indicate the ppl execution settings Signed-off-by: zane-neo <[email protected]> * format code Signed-off-by: zane-neo <[email protected]> --------- Signed-off-by: zane-neo <[email protected]> (cherry picked from commit 14d9ef2) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
5340662
commit 48f6f8d
Showing
7 changed files
with
172 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/org/opensearch/agent/common/SkillSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.agent.common; | ||
|
||
import org.opensearch.common.settings.Setting; | ||
|
||
/** | ||
* Settings for skills plugin | ||
*/ | ||
public final class SkillSettings { | ||
|
||
private SkillSettings() {} | ||
|
||
/** | ||
* This setting controls whether PPL execution is enabled or not | ||
*/ | ||
public static final Setting<Boolean> PPL_EXECUTION_ENABLED = Setting | ||
.boolSetting("plugins.skills.ppl_execution_enabled", false, Setting.Property.NodeScope, Setting.Property.Dynamic); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/main/java/org/opensearch/agent/tools/utils/ClusterSettingHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.agent.tools.utils; | ||
|
||
import java.util.Optional; | ||
|
||
import org.opensearch.cluster.service.ClusterService; | ||
import org.opensearch.common.settings.Setting; | ||
import org.opensearch.common.settings.Settings; | ||
|
||
import lombok.AllArgsConstructor; | ||
|
||
/** | ||
* This class is to encapsulate the {@link Settings} and {@link ClusterService} and provide a general method to retrieve dynamical cluster settings conveniently. | ||
*/ | ||
@AllArgsConstructor | ||
public class ClusterSettingHelper { | ||
|
||
private Settings settings; | ||
|
||
private ClusterService clusterService; | ||
|
||
/** | ||
* Retrieves the cluster settings for the specified setting. | ||
* | ||
* @param setting the setting to retrieve cluster settings for | ||
* @return the cluster setting value, or the default setting value if not found | ||
*/ | ||
public <T> T getClusterSettings(Setting<T> setting) { | ||
return Optional.ofNullable(clusterService.getClusterSettings().get(setting)).orElse(setting.get(settings)); | ||
} | ||
} |
Oops, something went wrong.