forked from opensearch-project/ml-commons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change httpclient to async (opensearch-project#1958)
* Change httpclient from sync to async Signed-off-by: zane-neo <[email protected]> * Change from CRTAsyncHttpClient to NettyAsyncHttpClient Signed-off-by: zane-neo <[email protected]> * Add publisher to request Signed-off-by: zane-neo <[email protected]> * Change sync httpclient to async Signed-off-by: zane-neo <[email protected]> * Handle error case and return error response in actionLListener Signed-off-by: zane-neo <[email protected]> * Fix no response when exception Signed-off-by: zane-neo <[email protected]> * Add content type header Signed-off-by: zane-neo <[email protected]> * Fix issues found in functional test Signed-off-by: zane-neo <[email protected]> * Fix no response issue in functional test Signed-off-by: zane-neo <[email protected]> * fix default step size error Signed-off-by: zane-neo <[email protected]> * Add track inference duration for async httpclient Signed-off-by: zane-neo <[email protected]> * Change client appsec highlight issues implementation for async httpclient Signed-off-by: zane-neo <[email protected]> * Add UTs Signed-off-by: zane-neo <[email protected]> * Add UTs Signed-off-by: zane-neo <[email protected]> * Remove unused file Signed-off-by: zane-neo <[email protected]> * Add UTs Signed-off-by: zane-neo <[email protected]> * format code Signed-off-by: zane-neo <[email protected]> * Change error code to honor remote service error code Signed-off-by: zane-neo <[email protected]> * Add more UTs Signed-off-by: zane-neo <[email protected]> * Change SSRF code to make it correct for return error stattus Signed-off-by: zane-neo <[email protected]> * Fix failure UTs and add more UTs Signed-off-by: zane-neo <[email protected]> * Fix failure ITs Signed-off-by: zane-neo <[email protected]> * format code Signed-off-by: zane-neo <[email protected]> * Fix partial success response not correct issue Signed-off-by: zane-neo <[email protected]> * format code Signed-off-by: zane-neo <[email protected]> * Fix failure ITs Signed-off-by: zane-neo <[email protected]> * Add more UTs to increase code coverage Signed-off-by: zane-neo <[email protected]> * Change url regex Signed-off-by: zane-neo <[email protected]> * Address comments Signed-off-by: zane-neo <[email protected]> * format code Signed-off-by: zane-neo <[email protected]> * Fix failure UTs Signed-off-by: zane-neo <[email protected]> * Add UT for httpclientFactory throw exception when creating httpclient Signed-off-by: zane-neo <[email protected]> * format code Signed-off-by: zane-neo <[email protected]> * Address comments and add modelTensor status code Signed-off-by: zane-neo <[email protected]> * Address comments Signed-off-by: zane-neo <[email protected]> * format code Signed-off-by: zane-neo <[email protected]> * Add status code to process error response Signed-off-by: zane-neo <[email protected]> * format code Signed-off-by: zane-neo <[email protected]> * Rebase main after connector level http parameter support Signed-off-by: zane-neo <[email protected]> * Fix UT Signed-off-by: zane-neo <[email protected]> * Change error message when remote model return empty and chaange the behavior when one of the requests fails Signed-off-by: zane-neo <[email protected]> * Add comments\ Signed-off-by: zane-neo <[email protected]> * Remove redundant builder and change the error code check Signed-off-by: zane-neo <[email protected]> * format code Signed-off-by: zane-neo <[email protected]> * Add more UTs for throw exception cases Signed-off-by: zane-neo <[email protected]> * fix failure UTs Signed-off-by: zane-neo <[email protected]> * format code Signed-off-by: zane-neo <[email protected]> * Fix test cases since the error message change Signed-off-by: zane-neo <[email protected]> * Rebase code Signed-off-by: zane-neo <[email protected]> * fix failure IT Signed-off-by: zane-neo <[email protected]> * Add more UTs Signed-off-by: zane-neo <[email protected]> * Fix duplicate response to client issue Signed-off-by: zane-neo <[email protected]> * fix duplicate response in channel Signed-off-by: zane-neo <[email protected]> * change code for all successfully responses case Signed-off-by: zane-neo <[email protected]> * Address comments Signed-off-by: zane-neo <[email protected]> * format code Signed-off-by: zane-neo <[email protected]> * Increase nio httpclient version to fix vulnerbility Signed-off-by: zane-neo <[email protected]> * Change validate localhost logic to same with existing code Signed-off-by: zane-neo <[email protected]> * change method signature to private Signed-off-by: zane-neo <[email protected]> * format code Signed-off-by: zane-neo <[email protected]> --------- Signed-off-by: zane-neo <[email protected]>
- Loading branch information
Showing
21 changed files
with
1,298 additions
and
759 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
32 changes: 32 additions & 0 deletions
32
ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/remote/ExecutionContext.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,32 @@ | ||
/* | ||
* | ||
* * Copyright OpenSearch Contributors | ||
* * SPDX-License-Identifier: Apache-2.0 | ||
* | ||
*/ | ||
|
||
package org.opensearch.ml.engine.algorithms.remote; | ||
|
||
import java.util.concurrent.CountDownLatch; | ||
import java.util.concurrent.atomic.AtomicReference; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
|
||
/** | ||
* This class encapsulates several parameters that are used in a split-batch request case. | ||
* A batch request is that in neural-search side multiple fields are send in one request to ml-commons, | ||
* but the remote model doesn't accept list of string inputs so in ml-commons the request needs split. | ||
* sequence is used to identify the index of the split request. | ||
* countDownLatch is used to wait for all the split requests to finish. | ||
* exceptionHolder is used to hold any exception thrown in a split-batch request. | ||
*/ | ||
@Data | ||
@AllArgsConstructor | ||
public class ExecutionContext { | ||
// Should never be null | ||
private int sequence; | ||
private CountDownLatch countDownLatch; | ||
// This is to hold any exception thrown in a split-batch request | ||
private AtomicReference<Exception> exceptionHolder; | ||
} |
Oops, something went wrong.