-
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.
Browse files
Browse the repository at this point in the history
* Add dynamic action registry to ActionModule * Update registration of transport actions * Generate transport actions dynamically * Refactor to combine registry internals * Finally figured out the generics (or lack thereof) * ExtensionProxyAction is dead! Long live ExtensionAction! * Simplify ExtensionTransportActionHandler, fix compile issues * Maybe tests will pass with this commit * I guess you can't use null as a key in a map * Lazy test setup, but this should finally work * Add Tests * Fix TransportActionRequestFromExtension inheritance * Fix return type for transport actions from extensions * Fix ParametersInWrongOrderError and add some preemptive null handling * NPE is not expected result if params are in correct order * Remove redundant class and string parsing, add success boolean * Last fix of params out of order. Working test case! * Code worked, tests didn't. This is finally done (I think) * Add more detail to comments on immutable vs. dynamic maps * Add StreamInput getter to ExtensionActionResponse * Generalize dynamic action registration * Comment and naming fixes * Register method renaming * Add generic type parameters * Improve/simplify which parameter types get passed * Revert removal of ProxyAction and changes to transport and requests * Wrap ExtensionTransportResponse in a class denoting success * Remove generic types as they are incompatible with Guice injection * Fix response handling, it works (again) * Fix up comments and remove debug logging --------- (cherry picked from commit 9febe10) Signed-off-by: Daniel Widdis <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
2bb68aa
commit ac79a63
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.