Package org.elasticsearch.index.reindex
Class AbstractAsyncBulkByScrollAction<Request extends AbstractBulkByScrollRequest<Request>>
- java.lang.Object
-
- org.elasticsearch.index.reindex.AbstractAsyncBulkByScrollAction<Request>
-
- Direct Known Subclasses:
AsyncDeleteByQueryAction
public abstract class AbstractAsyncBulkByScrollAction<Request extends AbstractBulkByScrollRequest<Request>> extends java.lang.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 Classes Modifier and Type Class Description static class
AbstractAsyncBulkByScrollAction.DeleteRequestWrapper
static class
AbstractAsyncBulkByScrollAction.IndexRequestWrapper
static class
AbstractAsyncBulkByScrollAction.OpType
static interface
AbstractAsyncBulkByScrollAction.RequestWrapper<Self extends DocWriteRequest<Self>>
Wrapper for theDocWriteRequest
that are used in this action class.static class
AbstractAsyncBulkByScrollAction.ScriptApplier
Apply aScript
to aAbstractAsyncBulkByScrollAction.RequestWrapper
-
Field Summary
Fields Modifier and Type Field Description protected ClusterState
clusterState
protected org.apache.logging.log4j.Logger
logger
protected Request
mainRequest
The request for this action.protected ScriptService
scriptService
protected BulkByScrollTask
task
protected ThreadPool
threadPool
protected WorkerBulkByScrollTaskState
worker
-
Constructor Summary
Constructors Constructor Description AbstractAsyncBulkByScrollAction(BulkByScrollTask task, org.apache.logging.log4j.Logger logger, ParentTaskAssigningClient client, ThreadPool threadPool, Request mainRequest, ScriptService scriptService, ClusterState clusterState, ActionListener<BulkByScrollResponse> listener)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected boolean
accept(ScrollableHitSource.Hit doc)
Used to accept or ignore a search hit.protected abstract AbstractAsyncBulkByScrollAction.RequestWrapper<?>
buildRequest(ScrollableHitSource.Hit doc)
Build theAbstractAsyncBulkByScrollAction.RequestWrapper
for a single search hit.protected BulkByScrollResponse
buildResponse(TimeValue took, java.util.List<BulkItemResponse.Failure> indexingFailures, java.util.List<ScrollableHitSource.SearchFailure> searchFailures, boolean timedOut)
Build the response for reindex actions.java.util.function.BiFunction<AbstractAsyncBulkByScrollAction.RequestWrapper<?>,ScrollableHitSource.Hit,AbstractAsyncBulkByScrollAction.RequestWrapper<?>>
buildScriptApplier()
Build theBiFunction
to apply to allAbstractAsyncBulkByScrollAction.RequestWrapper
.protected ScrollableHitSource
buildScrollableResultSource(BackoffPolicy backoffPolicy)
protected AbstractAsyncBulkByScrollAction.RequestWrapper<?>
copyMetadata(AbstractAsyncBulkByScrollAction.RequestWrapper<?> request, ScrollableHitSource.Hit doc)
Copies the metadata from a hit to the request.protected void
copyRouting(AbstractAsyncBulkByScrollAction.RequestWrapper<?> request, java.lang.String routing)
Copy the routing from a search hit to the request.protected void
finishHim(java.lang.Exception failure)
Finish the request.protected void
finishHim(java.lang.Exception failure, java.util.List<BulkItemResponse.Failure> indexingFailures, java.util.List<ScrollableHitSource.SearchFailure> searchFailures, boolean timedOut)
Finish the request.protected abstract boolean
needsSourceDocumentVersions()
Does this operation need the versions of the source documents?void
start()
Start the action by firing the initial search request.static AbstractAsyncBulkByScrollAction.RequestWrapper<DeleteRequest>
wrap(DeleteRequest request)
static AbstractAsyncBulkByScrollAction.RequestWrapper<IndexRequest>
wrap(IndexRequest request)
-
-
-
Field Detail
-
logger
protected final org.apache.logging.log4j.Logger logger
-
task
protected final BulkByScrollTask task
-
worker
protected final WorkerBulkByScrollTaskState worker
-
threadPool
protected final ThreadPool threadPool
-
scriptService
protected final ScriptService scriptService
-
clusterState
protected final ClusterState clusterState
-
mainRequest
protected final Request extends AbstractBulkByScrollRequest<Request> mainRequest
The request for this action. Named mainRequest because we create lots ofrequest
variables all representing child requests of this mainRequest.
-
-
Constructor Detail
-
AbstractAsyncBulkByScrollAction
public AbstractAsyncBulkByScrollAction(BulkByScrollTask task, org.apache.logging.log4j.Logger logger, ParentTaskAssigningClient client, ThreadPool threadPool, Request mainRequest, ScriptService scriptService, ClusterState clusterState, ActionListener<BulkByScrollResponse> listener)
-
-
Method Detail
-
buildScriptApplier
public java.util.function.BiFunction<AbstractAsyncBulkByScrollAction.RequestWrapper<?>,ScrollableHitSource.Hit,AbstractAsyncBulkByScrollAction.RequestWrapper<?>> buildScriptApplier()
Build theBiFunction
to apply to allAbstractAsyncBulkByScrollAction.RequestWrapper
. Public for testings....
-
needsSourceDocumentVersions
protected abstract boolean needsSourceDocumentVersions()
Does this operation need the versions of the source documents?
-
buildRequest
protected abstract AbstractAsyncBulkByScrollAction.RequestWrapper<?> buildRequest(ScrollableHitSource.Hit doc)
Build theAbstractAsyncBulkByScrollAction.RequestWrapper
for 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, java.lang.String routing)
Copy the routing from a search hit to the request.
-
accept
protected boolean accept(ScrollableHitSource.Hit doc)
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
protected ScrollableHitSource buildScrollableResultSource(BackoffPolicy backoffPolicy)
-
buildResponse
protected BulkByScrollResponse buildResponse(TimeValue took, java.util.List<BulkItemResponse.Failure> indexingFailures, java.util.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
protected void finishHim(java.lang.Exception failure)
Finish the request.- Parameters:
failure
- if non null then the request failed catastrophically with this exception
-
finishHim
protected void finishHim(java.lang.Exception failure, java.util.List<BulkItemResponse.Failure> indexingFailures, java.util.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)
-
-