[Feature/extensions] First draft of adding support for dynamically registering actions#4460
Conversation
Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com>
Gradle Check (Jenkins) Run Completed with:
|
Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com>
Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com>
Gradle Check (Jenkins) Run Completed with:
|
Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com>
Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com>
Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com>
|
ChangeLog action failing, I'll wait for #4479 to merge and then rebase. Because it will eventually end up in conflicts. |
Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com>
Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com>
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
|
Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com>
Gradle Check (Jenkins) Run Completed with:
|
|
Gradle check failures: |
| import java.io.IOException; | ||
|
|
||
| public class ExtensionsActionResponse extends ActionResponse implements ToXContentObject { | ||
| String myFirstResponse; |
There was a problem hiding this comment.
Looks like leftover from draft PR?
| actions.put(ValidateQueryAction.INSTANCE, transportAction); | ||
|
|
||
| client.initialize(actions, () -> "local", null, new NamedWriteableRegistry(Collections.emptyList())); | ||
| client.initialize(actions, null, () -> "local", null, new NamedWriteableRegistry(Collections.emptyList())); |
There was a problem hiding this comment.
Can we create a dummy obj of actionsRegistry instead of passing null?
| import org.opensearch.action.ActionType; | ||
|
|
||
| public class ExtensionsAction extends ActionType<ExtensionsActionResponse> { | ||
| public static final String NAME = "cluster:monitor/extension"; |
There was a problem hiding this comment.
Should be keep the action name in the same format as internal...?
There was a problem hiding this comment.
Sure makes sense.
| import java.io.IOException; | ||
|
|
||
| public class ExtensionsActionRequest extends ActionRequest { | ||
| String firstRequest; |
There was a problem hiding this comment.
Or is this a draft PR?
Why is the first request so important to preserve?
There was a problem hiding this comment.
My bad, looks like I missed a commit during the rebase.
This is moved to action which the extension would like to register.
| private <Request extends ActionRequest, Response extends ActionResponse> TransportAction<Request, Response> transportAction( | ||
| ActionType<Response> action | ||
| ) { | ||
| /* TODO add support to read actionsRegistry along with actions */ |
There was a problem hiding this comment.
Do we have an issue to track this TODO?
There was a problem hiding this comment.
Haha I've taken care of this as part of SDK#106.
|
|
||
| final ClusterService clusterService = injector.getInstance(ClusterService.class); | ||
| final ActionModule actionModule = injector.getInstance(ActionModule.class); | ||
| actionModule.registerAction(ExtensionsAction.INSTANCE, TransportExtensionsAction.class); |
There was a problem hiding this comment.
Can we have tests for registerActions?
There was a problem hiding this comment.
Thats a good point.
Sure.
dbwiddis
left a comment
There was a problem hiding this comment.
Looks generally good with comments inline. I'm confused whether this is a draft PR (per subject line) or intended to be merged. Would be helpful to have more comments indicating future functionality.
The word "Action" is overused in the codebase and at least one of these classes (probably ExtensionsAction) should describe just what we are talking about.
| import java.io.IOException; | ||
|
|
||
| public class ExtensionsActionResponse extends ActionResponse implements ToXContentObject { | ||
| String myFirstResponse; |
There was a problem hiding this comment.
In #4519 I merged multiple similar "string response" classes into an ExtensionStringResponse class. This looks very similar in that it's just a basic "string response" but extending ActionResponse rather than TransportResponse.
I don't think the name ExtensionsActionResponse is meaningful for the simplicity of this object.
I am also thinking we need to figure out a consistent naming convention.
I am also seeing that we are very inconsistent in pluralization of Extension in these class names.
|
|
||
| @Override | ||
| public void writeTo(StreamOutput out) throws IOException { | ||
| out.writeString(myFirstResponse); |
There was a problem hiding this comment.
I haven't dug into the implementation details, but when I see a super(in) I expect to see a matching super(out). I know the super is required for transport requests but not responses, and in the latter case the super call is a noop.
All that to say, either add a super(out) here or delete the super(in) above.
|
|
||
| @Override | ||
| public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
| return null; |
There was a problem hiding this comment.
What will eventually go here? I don't like seeing null returns, but a comment suggesting future usage would make me happier.
|
|
||
| public class ExtensionsActionTests extends OpenSearchSingleNodeTestCase { | ||
|
|
||
| public void testExtensionAction() throws ExecutionException, InterruptedException { |
There was a problem hiding this comment.
usually tests contain assertions of some sort. :)
There was a problem hiding this comment.
Yup I just realized I missed a commit :D
| import java.io.IOException; | ||
|
|
||
| public class ExtensionsActionRequest extends ActionRequest { | ||
| String firstRequest; |
There was a problem hiding this comment.
Or is this a draft PR?
Why is the first request so important to preserve?
| private final SettingsFilter settingsFilter; | ||
| private final List<ActionPlugin> actionPlugins; | ||
| private final Map<String, ActionHandler<?, ?>> actions; | ||
| private ActionRegistry actionRegistryMap; |
There was a problem hiding this comment.
Everything around this is final. Should this also be?
There was a problem hiding this comment.
Thats a good point. I was debating but it can be a final because the instance would not change.
Will update.
|
Thanks for the feedback @dbwiddis, @owaiskazi19 ! |
Description
With extensions, we would like to register actions during runtime of OpenSearch and not only during bootstrap.
This PR enables ActionModule in OpenSearch core to register transport actions dynamically.
Issues Resolved
opensearch-project/opensearch-sdk-java#107
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.