Package org.opensearch.index.reindex
Class AbstractAsyncBulkByScrollAction<Request extends AbstractBulkByScrollRequest<Request>,Action extends TransportAction<Request,?>>
java.lang.Object
org.opensearch.index.reindex.AbstractAsyncBulkByScrollAction<Request,Action>
- Direct Known Subclasses:
AsyncDeleteByQueryAction
public abstract class AbstractAsyncBulkByScrollAction<Request extends AbstractBulkByScrollRequest<Request>,Action extends TransportAction<Request,?>>
extends Object
Abstract base for scrolling across a search and executing bulk actions on all results. All package private methods are package private so
their tests can use them. Most methods run in the listener thread pool because the are meant to be fast and don't expect to block.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic enumstatic interfaceWrapper for theDocWriteRequestthat are used in this action class.static classApply aScriptto aAbstractAsyncBulkByScrollAction.RequestWrapper -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Optional<org.apache.http.HttpRequestInterceptor> protected final org.apache.logging.log4j.Loggerprotected final RequestThe request for this action.protected final ScriptServiceprotected final org.opensearch.index.reindex.ReindexSslConfigprotected final BulkByScrollTaskprotected final ThreadPoolprotected final WorkerBulkByScrollTaskState -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanUsed to accept or ignore a search hit.protected abstract AbstractAsyncBulkByScrollAction.RequestWrapper<?> Build theAbstractAsyncBulkByScrollAction.RequestWrapperfor a single search hit.protected BulkByScrollResponsebuildResponse(TimeValue took, List<BulkItemResponse.Failure> indexingFailures, List<ScrollableHitSource.SearchFailure> searchFailures, boolean timedOut) Build the response for reindex actions.BiFunction<AbstractAsyncBulkByScrollAction.RequestWrapper<?>, ScrollableHitSource.Hit, AbstractAsyncBulkByScrollAction.RequestWrapper<?>> Build theBiFunctionto apply to allAbstractAsyncBulkByScrollAction.RequestWrapper.protected ScrollableHitSourcebuildScrollableResultSource(BackoffPolicy backoffPolicy) protected AbstractAsyncBulkByScrollAction.RequestWrapper<?> copyMetadata(AbstractAsyncBulkByScrollAction.RequestWrapper<?> request, ScrollableHitSource.Hit doc) Copies the metadata from a hit to the request.protected voidcopyRouting(AbstractAsyncBulkByScrollAction.RequestWrapper<?> request, String routing) Copy the routing from a search hit to the request.protected voidFinish the request.protected voidfinishHim(Exception failure, List<BulkItemResponse.Failure> indexingFailures, List<ScrollableHitSource.SearchFailure> searchFailures, boolean timedOut) Finish the request.voidstart()Start the action by firing the initial search request.wrap(DeleteRequest request) wrap(IndexRequest request)
-
Field Details
-
logger
protected final org.apache.logging.log4j.Logger logger -
task
-
worker
-
threadPool
-
scriptService
-
sslConfig
-
interceptor
-
mainRequest
The request for this action. Named mainRequest because we create lots ofrequestvariables all representing child requests of this mainRequest.
-
-
Method Details
-
buildScriptApplier
public BiFunction<AbstractAsyncBulkByScrollAction.RequestWrapper<?>,ScrollableHitSource.Hit, buildScriptApplier()AbstractAsyncBulkByScrollAction.RequestWrapper<?>> Build theBiFunctionto apply to allAbstractAsyncBulkByScrollAction.RequestWrapper.Public for testings....
-
buildRequest
protected abstract AbstractAsyncBulkByScrollAction.RequestWrapper<?> buildRequest(ScrollableHitSource.Hit doc) Build theAbstractAsyncBulkByScrollAction.RequestWrapperfor a single search hit. This shouldn't handle metadata or scripting. That will be handled by copyMetadata and apply functions that can be overridden. -
copyMetadata
protected AbstractAsyncBulkByScrollAction.RequestWrapper<?> copyMetadata(AbstractAsyncBulkByScrollAction.RequestWrapper<?> request, ScrollableHitSource.Hit doc) Copies the metadata from a hit to the request. -
copyRouting
protected void copyRouting(AbstractAsyncBulkByScrollAction.RequestWrapper<?> request, String routing) Copy the routing from a search hit to the request. -
accept
Used to accept or ignore a search hit. Ignored search hits will be excluded from the bulk request. It is also where we fail on invalid search hits, like when the document has no source but it's required. -
buildScrollableResultSource
-
buildResponse
protected BulkByScrollResponse buildResponse(TimeValue took, List<BulkItemResponse.Failure> indexingFailures, List<ScrollableHitSource.SearchFailure> searchFailures, boolean timedOut) Build the response for reindex actions. -
start
public void start()Start the action by firing the initial search request. -
finishHim
Finish the request.- Parameters:
failure- if non null then the request failed catastrophically with this exception
-
finishHim
protected void finishHim(Exception failure, List<BulkItemResponse.Failure> indexingFailures, List<ScrollableHitSource.SearchFailure> searchFailures, boolean timedOut) Finish the request.- Parameters:
failure- if non null then the request failed catastrophically with this exceptionindexingFailures- any indexing failures accumulated during the requestsearchFailures- any search failures accumulated during the requesttimedOut- have any of the sub-requests timed out?
-
wrap
public static AbstractAsyncBulkByScrollAction.RequestWrapper<IndexRequest> wrap(IndexRequest request) -
wrap
public static AbstractAsyncBulkByScrollAction.RequestWrapper<DeleteRequest> wrap(DeleteRequest request)
-