forked from opensearch-project/opensearch-sdk-java
-
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.
Add ActionListener onFailure to ExtensionsRunner (opensearch-project#87)
* Add ActionListener onFailure to ExtensionsRunner Signed-off-by: Ryan Bogan <rbogan@amazon.com> * Addressed PR Comments Signed-off-by: Ryan Bogan <rbogan@amazon.com> * Addressed PR Comments Signed-off-by: Ryan Bogan <rbogan@amazon.com> * Addressed PR Comments Signed-off-by: Ryan Bogan <rbogan@amazon.com> * Removed test failure Signed-off-by: Ryan Bogan <rbogan@amazon.com> Signed-off-by: Ryan Bogan <rbogan@amazon.com>
- Loading branch information
Showing
3 changed files
with
82 additions
and
1 deletion.
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
47 changes: 47 additions & 0 deletions
47
src/main/java/org/opensearch/sdk/handlers/ActionListenerOnFailureResponseHandler.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,47 @@ | ||
/* | ||
* 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.sdk.handlers; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.opensearch.extensions.ExtensionBooleanResponse; | ||
import org.opensearch.common.io.stream.StreamInput; | ||
import org.opensearch.sdk.ExtensionsRunner; | ||
import org.opensearch.threadpool.ThreadPool; | ||
import org.opensearch.transport.TransportException; | ||
import org.opensearch.transport.TransportResponseHandler; | ||
import org.opensearch.transport.TransportService; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* This class handles the response from OpenSearch to a {@link ExtensionsRunner#sendActionListenerOnFailureRequest(TransportService, Exception)} call. | ||
*/ | ||
public class ActionListenerOnFailureResponseHandler implements TransportResponseHandler<ExtensionBooleanResponse> { | ||
private static final Logger logger = LogManager.getLogger(ActionListenerOnFailureResponseHandler.class); | ||
|
||
@Override | ||
public void handleResponse(ExtensionBooleanResponse response) { | ||
logger.info("received {}", response); | ||
} | ||
|
||
@Override | ||
public void handleException(TransportException exp) { | ||
logger.info("ActionListenerOnFailureRequest failed", exp); | ||
} | ||
|
||
@Override | ||
public String executor() { | ||
return ThreadPool.Names.GENERIC; | ||
} | ||
|
||
@Override | ||
public ExtensionBooleanResponse read(StreamInput in) throws IOException { | ||
return new ExtensionBooleanResponse(in); | ||
} | ||
} |
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