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 <zaniu@amazon.com> * Change from CRTAsyncHttpClient to NettyAsyncHttpClient Signed-off-by: zane-neo <zaniu@amazon.com> * Add publisher to request Signed-off-by: zane-neo <zaniu@amazon.com> * Change sync httpclient to async Signed-off-by: zane-neo <zaniu@amazon.com> * Handle error case and return error response in actionLListener Signed-off-by: zane-neo <zaniu@amazon.com> * Fix no response when exception Signed-off-by: zane-neo <zaniu@amazon.com> * Add content type header Signed-off-by: zane-neo <zaniu@amazon.com> * Fix issues found in functional test Signed-off-by: zane-neo <zaniu@amazon.com> * Fix no response issue in functional test Signed-off-by: zane-neo <zaniu@amazon.com> * fix default step size error Signed-off-by: zane-neo <zaniu@amazon.com> * Add track inference duration for async httpclient Signed-off-by: zane-neo <zaniu@amazon.com> * Change client appsec highlight issues implementation for async httpclient Signed-off-by: zane-neo <zaniu@amazon.com> * Add UTs Signed-off-by: zane-neo <zaniu@amazon.com> * Add UTs Signed-off-by: zane-neo <zaniu@amazon.com> * Remove unused file Signed-off-by: zane-neo <zaniu@amazon.com> * Add UTs Signed-off-by: zane-neo <zaniu@amazon.com> * format code Signed-off-by: zane-neo <zaniu@amazon.com> * Change error code to honor remote service error code Signed-off-by: zane-neo <zaniu@amazon.com> * Add more UTs Signed-off-by: zane-neo <zaniu@amazon.com> * Change SSRF code to make it correct for return error stattus Signed-off-by: zane-neo <zaniu@amazon.com> * Fix failure UTs and add more UTs Signed-off-by: zane-neo <zaniu@amazon.com> * Fix failure ITs Signed-off-by: zane-neo <zaniu@amazon.com> * format code Signed-off-by: zane-neo <zaniu@amazon.com> * Fix partial success response not correct issue Signed-off-by: zane-neo <zaniu@amazon.com> * format code Signed-off-by: zane-neo <zaniu@amazon.com> * Fix failure ITs Signed-off-by: zane-neo <zaniu@amazon.com> * Add more UTs to increase code coverage Signed-off-by: zane-neo <zaniu@amazon.com> * Change url regex Signed-off-by: zane-neo <zaniu@amazon.com> * Address comments Signed-off-by: zane-neo <zaniu@amazon.com> * format code Signed-off-by: zane-neo <zaniu@amazon.com> * Fix failure UTs Signed-off-by: zane-neo <zaniu@amazon.com> * Add UT for httpclientFactory throw exception when creating httpclient Signed-off-by: zane-neo <zaniu@amazon.com> * format code Signed-off-by: zane-neo <zaniu@amazon.com> * Address comments and add modelTensor status code Signed-off-by: zane-neo <zaniu@amazon.com> * Address comments Signed-off-by: zane-neo <zaniu@amazon.com> * format code Signed-off-by: zane-neo <zaniu@amazon.com> * Add status code to process error response Signed-off-by: zane-neo <zaniu@amazon.com> * format code Signed-off-by: zane-neo <zaniu@amazon.com> * Rebase main after connector level http parameter support Signed-off-by: zane-neo <zaniu@amazon.com> * Fix UT Signed-off-by: zane-neo <zaniu@amazon.com> * Change error message when remote model return empty and chaange the behavior when one of the requests fails Signed-off-by: zane-neo <zaniu@amazon.com> * Add comments\ Signed-off-by: zane-neo <zaniu@amazon.com> * Remove redundant builder and change the error code check Signed-off-by: zane-neo <zaniu@amazon.com> * format code Signed-off-by: zane-neo <zaniu@amazon.com> * Add more UTs for throw exception cases Signed-off-by: zane-neo <zaniu@amazon.com> * fix failure UTs Signed-off-by: zane-neo <zaniu@amazon.com> * format code Signed-off-by: zane-neo <zaniu@amazon.com> * Fix test cases since the error message change Signed-off-by: zane-neo <zaniu@amazon.com> * Rebase code Signed-off-by: zane-neo <zaniu@amazon.com> * fix failure IT Signed-off-by: zane-neo <zaniu@amazon.com> * Add more UTs Signed-off-by: zane-neo <zaniu@amazon.com> * Fix duplicate response to client issue Signed-off-by: zane-neo <zaniu@amazon.com> * fix duplicate response in channel Signed-off-by: zane-neo <zaniu@amazon.com> * change code for all successfully responses case Signed-off-by: zane-neo <zaniu@amazon.com> * Address comments Signed-off-by: zane-neo <zaniu@amazon.com> * format code Signed-off-by: zane-neo <zaniu@amazon.com> * Increase nio httpclient version to fix vulnerbility Signed-off-by: zane-neo <zaniu@amazon.com> * Change validate localhost logic to same with existing code Signed-off-by: zane-neo <zaniu@amazon.com> * change method signature to private Signed-off-by: zane-neo <zaniu@amazon.com> * format code Signed-off-by: zane-neo <zaniu@amazon.com> --------- Signed-off-by: zane-neo <zaniu@amazon.com>
- 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.