-
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.
Browse files
Browse the repository at this point in the history
This change extends the remote reindex SPI to allow adding a custom interceptor. This interceptor can be plugged in to perform any processing on the request or response. Signed-off-by: Sooraj Sinha <soosinha@amazon.com> Co-authored-by: Sooraj Sinha <81695996+soosinha@users.noreply.github.com>
- Loading branch information
Showing
6 changed files
with
140 additions
and
5 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
20 changes: 20 additions & 0 deletions
20
...eindex/src/main/java/org/opensearch/index/reindex/spi/ReindexRestInterceptorProvider.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,20 @@ | ||
/* | ||
* Copyright OpenSearch Contributors. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.index.reindex.spi; | ||
|
||
import java.util.Optional; | ||
import org.apache.http.HttpRequestInterceptor; | ||
import org.opensearch.common.util.concurrent.ThreadContext; | ||
import org.opensearch.index.reindex.ReindexRequest; | ||
|
||
public interface ReindexRestInterceptorProvider { | ||
/** | ||
* @param request Reindex request. | ||
* @param threadContext Current thread context. | ||
* @return HttpRequestInterceptor object. | ||
*/ | ||
Optional<HttpRequestInterceptor> getRestInterceptor(ReindexRequest request, ThreadContext threadContext); | ||
} |
34 changes: 34 additions & 0 deletions
34
modules/reindex/src/main/java/org/opensearch/index/reindex/spi/RemoteReindexExtension.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,34 @@ | ||
/* | ||
* Copyright OpenSearch Contributors. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.index.reindex.spi; | ||
|
||
import org.opensearch.action.ActionListener; | ||
import org.opensearch.index.reindex.BulkByScrollResponse; | ||
import org.opensearch.index.reindex.ReindexRequest; | ||
|
||
/** | ||
* This interface provides an extension point for {@link org.opensearch.index.reindex.ReindexPlugin}. | ||
* This interface can be implemented to provide a custom Rest interceptor and {@link ActionListener} | ||
* The Rest interceptor can be used to pre-process any reindex request and perform any action | ||
* on the response. The ActionListener listens to the success and failure events on every reindex request | ||
* and can be used to take any actions based on the success or failure. | ||
*/ | ||
public interface RemoteReindexExtension { | ||
/** | ||
* Get an InterceptorProvider. | ||
* @return ReindexRestInterceptorProvider implementation. | ||
*/ | ||
ReindexRestInterceptorProvider getInterceptorProvider(); | ||
|
||
/** | ||
* Get a wrapper of ActionListener which is can used to perform any action based on | ||
* the success/failure of the remote reindex call. | ||
* @return ActionListener wrapper implementation. | ||
*/ | ||
ActionListener<BulkByScrollResponse> getRemoteReindexActionListener(ActionListener<BulkByScrollResponse> listener, | ||
ReindexRequest reindexRequest); | ||
} | ||
|