-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Extensions] Add DynamicActionRegistry to ActionModule (#6734)
* Add dynamic action registry to ActionModule Signed-off-by: Daniel Widdis <[email protected]> * Update registration of transport actions Signed-off-by: Daniel Widdis <[email protected]> * Generate transport actions dynamically Signed-off-by: Daniel Widdis <[email protected]> * Refactor to combine registry internals Signed-off-by: Daniel Widdis <[email protected]> * Finally figured out the generics (or lack thereof) Signed-off-by: Daniel Widdis <[email protected]> * ExtensionProxyAction is dead! Long live ExtensionAction! Signed-off-by: Daniel Widdis <[email protected]> * Simplify ExtensionTransportActionHandler, fix compile issues Signed-off-by: Daniel Widdis <[email protected]> * Maybe tests will pass with this commit Signed-off-by: Daniel Widdis <[email protected]> * I guess you can't use null as a key in a map Signed-off-by: Daniel Widdis <[email protected]> * Lazy test setup, but this should finally work Signed-off-by: Daniel Widdis <[email protected]> * Add Tests Signed-off-by: Daniel Widdis <[email protected]> * Fix TransportActionRequestFromExtension inheritance Signed-off-by: Daniel Widdis <[email protected]> * Fix return type for transport actions from extensions Signed-off-by: Daniel Widdis <[email protected]> * Fix ParametersInWrongOrderError and add some preemptive null handling Signed-off-by: Daniel Widdis <[email protected]> * NPE is not expected result if params are in correct order Signed-off-by: Daniel Widdis <[email protected]> * Remove redundant class and string parsing, add success boolean Signed-off-by: Daniel Widdis <[email protected]> * Last fix of params out of order. Working test case! Signed-off-by: Daniel Widdis <[email protected]> * Code worked, tests didn't. This is finally done (I think) Signed-off-by: Daniel Widdis <[email protected]> * Add more detail to comments on immutable vs. dynamic maps Signed-off-by: Daniel Widdis <[email protected]> * Add StreamInput getter to ExtensionActionResponse Signed-off-by: Daniel Widdis <[email protected]> * Generalize dynamic action registration Signed-off-by: Daniel Widdis <[email protected]> * Comment and naming fixes Signed-off-by: Daniel Widdis <[email protected]> * Register method renaming Signed-off-by: Daniel Widdis <[email protected]> * Add generic type parameters Signed-off-by: Daniel Widdis <[email protected]> * Improve/simplify which parameter types get passed Signed-off-by: Daniel Widdis <[email protected]> * Revert removal of ProxyAction and changes to transport and requests Signed-off-by: Daniel Widdis <[email protected]> * Wrap ExtensionTransportResponse in a class denoting success Signed-off-by: Daniel Widdis <[email protected]> * Remove generic types as they are incompatible with Guice injection Signed-off-by: Daniel Widdis <[email protected]> * Fix response handling, it works (again) Signed-off-by: Daniel Widdis <[email protected]> * Fix up comments and remove debug logging Signed-off-by: Daniel Widdis <[email protected]> --------- Signed-off-by: Daniel Widdis <[email protected]> (cherry picked from commit 9febe10) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
b33f735
commit 72585c2
Showing
21 changed files
with
645 additions
and
158 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
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
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
60 changes: 60 additions & 0 deletions
60
server/src/main/java/org/opensearch/extensions/action/ExtensionAction.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,60 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.extensions.action; | ||
|
||
import org.opensearch.action.ActionType; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* An {@link ActionType} to be used in extension action transport handling. | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class ExtensionAction extends ActionType<RemoteExtensionActionResponse> { | ||
|
||
private final String uniqueId; | ||
|
||
/** | ||
* Create an instance of this action to register in the dynamic actions map. | ||
* | ||
* @param uniqueId The uniqueId of the extension which will run this action. | ||
* @param name The fully qualified class name of the extension's action to execute. | ||
*/ | ||
public ExtensionAction(String uniqueId, String name) { | ||
super(name, RemoteExtensionActionResponse::new); | ||
this.uniqueId = uniqueId; | ||
} | ||
|
||
/** | ||
* Gets the uniqueId of the extension which will run this action. | ||
* | ||
* @return the uniqueId | ||
*/ | ||
public String uniqueId() { | ||
return this.uniqueId; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
final int prime = 31; | ||
int result = super.hashCode(); | ||
result = prime * result + Objects.hash(uniqueId); | ||
return result; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) return true; | ||
if (!super.equals(obj)) return false; | ||
if (getClass() != obj.getClass()) return false; | ||
ExtensionAction other = (ExtensionAction) obj; | ||
return Objects.equals(uniqueId, other.uniqueId); | ||
} | ||
} |
Oops, something went wrong.