-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature/extensions] Adding Transport Actions support for extensions (#…
…4598) * Adding Transport Actions support for extensions Signed-off-by: Sarat Vemulapalli <[email protected]> * Adding changelog Signed-off-by: Sarat Vemulapalli <[email protected]> * Fixing precommit and tests Signed-off-by: Sarat Vemulapalli <[email protected]> * Adding Transport Actions support for extensions Signed-off-by: Sarat Vemulapalli <[email protected]> * Fixing tests Signed-off-by: Sarat Vemulapalli <[email protected]> * Close client which is leaking threads Signed-off-by: Sarat Vemulapalli <[email protected]> * Fixing spotless Signed-off-by: Sarat Vemulapalli <[email protected]> * Few more tests Signed-off-by: Sarat Vemulapalli <[email protected]> * Adding tests Signed-off-by: Sarat Vemulapalli <[email protected]> * Addressing comments Signed-off-by: Sarat Vemulapalli <[email protected]> * Addressing comments and fixing spotless Signed-off-by: Sarat Vemulapalli <[email protected]> * Addressing comments Signed-off-by: Sarat Vemulapalli <[email protected]> Signed-off-by: Sarat Vemulapalli <[email protected]>
- Loading branch information
1 parent
be4d337
commit eee59c5
Showing
25 changed files
with
1,163 additions
and
75 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
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
76 changes: 76 additions & 0 deletions
76
server/src/main/java/org/opensearch/extensions/action/ExtensionActionRequest.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,76 @@ | ||
/* | ||
* 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.ActionRequest; | ||
import org.opensearch.action.ActionRequestValidationException; | ||
import org.opensearch.common.io.stream.StreamInput; | ||
import org.opensearch.common.io.stream.StreamOutput; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* This class translates Extension transport request to ActionRequest | ||
* which is internally used to make transport action call. | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class ExtensionActionRequest extends ActionRequest { | ||
/** | ||
* action is the transport action intended to be invoked which is registered by an extension via {@link ExtensionTransportActionsHandler}. | ||
*/ | ||
private final String action; | ||
/** | ||
* requestBytes is the raw bytes being transported between extensions. | ||
*/ | ||
private final byte[] requestBytes; | ||
|
||
/** | ||
* ExtensionActionRequest constructor. | ||
* | ||
* @param action is the transport action intended to be invoked which is registered by an extension via {@link ExtensionTransportActionsHandler}. | ||
* @param requestBytes is the raw bytes being transported between extensions. | ||
*/ | ||
public ExtensionActionRequest(String action, byte[] requestBytes) { | ||
this.action = action; | ||
this.requestBytes = requestBytes; | ||
} | ||
|
||
/** | ||
* ExtensionActionRequest constructor from {@link StreamInput}. | ||
* | ||
* @param in bytes stream input used to de-serialize the message. | ||
* @throws IOException when message de-serialization fails. | ||
*/ | ||
ExtensionActionRequest(StreamInput in) throws IOException { | ||
super(in); | ||
action = in.readString(); | ||
requestBytes = in.readByteArray(); | ||
} | ||
|
||
public String getAction() { | ||
return action; | ||
} | ||
|
||
public byte[] getRequestBytes() { | ||
return requestBytes; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
out.writeString(action); | ||
out.writeByteArray(requestBytes); | ||
} | ||
|
||
@Override | ||
public ActionRequestValidationException validate() { | ||
return null; | ||
} | ||
} |
Oops, something went wrong.