-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Meta] [FEATURE] Add getSettings support for AD #79
Comments
Taking a stab at this.
|
getSettings support is required for creating a detector. During For ADTaskManager, the required settings are :
For SearchFeatureDao, the required settings are :
For AnomalyDetectionIndices, the required settings are :
All of these settings are registered within opensearch via Note : Settings that are not used for creating a detector should also be removed from For information on how these settings are used during create components is documented here : #78 (comment) |
We're going to have to re-order something in the Node / SettingsModule / ExtensionsOrchestrator initialization sequence. In Node.java constructor:
Can we delay initializing SettingsModule until after start at line 1174? No: the plugin settings (indexScopedSettings) and settings filters are used extensively in other objects.
Can we move ExtensionsOrchestrator initialization steps before line 492 (best) or 651 (where settings first used)? No: it needs other services initialized, which get the settings! Solution requires updating settings after initialization. This requires also updating settings on all other modules. This is simply not part of the design; settings are assumed not to change after initialization. Attempting to hack a change into all these would be error-prone. Possibility: Create a new module designed to get extension settings after initialization. Pass the (empty) module object around to other modules where it is needed. Add settings to it after initialization. When looking up settings, use the existing stored settings first and if the settings aren't there, try the extension settings module as a backup. |
To register settings dynamically after the bootstrap @saratvemulapalli worked on opensearch-project/OpenSearch#3753. |
And I even reviewed that PR! 🤦♂️ That solves the problem. |
Your good set of questions, my poor memory and Sarat's vision to foresee the future! |
OK, so we still have a significant issue.
It looks like there are a few approaches to this, including Java Serialization (yuck) that I'll have to look into. Suggestions welcome. |
OK, the good news is the The transport request can use a switch/case based on There are a few extra things with nested/recursive settings objects (fallback settings, group settings, etc.) needed for a complete implementation, but the simple ones with no fallback handle all the use cases in |
FYI @joshpalis and @owaiskazi19 I will be creating a helper/wrapper class to implement the Setting-to-stream and stream-to-Setting code described in the previous comment. Name may change (because naming things is hard) but expect something along the lines of: class WriteableSettings implements Writeable {
private Settings<?> settings;
WriteableSettings(Settings<?> settings) {
this.settings = settings;
}
@Override
public void writeTo(StreamOutput out) {
// switch/case based on the known types
}
@Override
Settings<?> read(StreamInput in) {
// switch/case based on the known types
}
} |
Getting the type isn't as easy as I thought.... default values for the win! public class WriteableSetting implements Writeable {
private Setting<?> setting;
public WriteableSetting(Setting<?> setting) {
this.setting = setting;
}
@Override
public void writeTo(StreamOutput out) throws IOException {
}
private String getTypeOfSetting() {
return setting.getDefault(null).getClass().getName();
}
public static void main(String[] args) {
Setting<Integer> s = Setting.intSetting("foo", 42, 0, Setting.Property.IndexScope);
WriteableSetting ws = new WriteableSetting(s);
System.out.println(ws.getTypeOfSetting());
Setting<ByteSizeValue> bs = Setting.memorySizeSetting("bar", new ByteSizeValue(8, ByteSizeUnit.GB), Setting.Property.IndexScope);
WriteableSetting wbs = new WriteableSetting(bs);
System.out.println(wbs.getTypeOfSetting());
}
}
|
|
Initial work for (draft) review in opensearch-project/OpenSearch#4519 @joshpalis @owaiskazi19 @saratvemulapalli |
This issue is to register custom settings support for extensions.
We can split this into 3 issues:
The text was updated successfully, but these errors were encountered: