Package org.elasticsearch.index.reindex
Class AbstractAsyncBulkByScrollAction<Request extends org.elasticsearch.index.reindex.AbstractBulkByScrollRequest<Request>>
- java.lang.Object
-
- org.elasticsearch.index.reindex.AbstractAsyncBulkByScrollAction<Request>
-
- Direct Known Subclasses:
AsyncDeleteByQueryAction
public abstract class AbstractAsyncBulkByScrollAction<Request extends org.elasticsearch.index.reindex.AbstractBulkByScrollRequest<Request>> extends java.lang.ObjectAbstract 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 classAbstractAsyncBulkByScrollAction.DeleteRequestWrapperAbstractAsyncBulkByScrollAction.RequestWrapperforDeleteRequeststatic classAbstractAsyncBulkByScrollAction.IndexRequestWrapperAbstractAsyncBulkByScrollAction.RequestWrapperforIndexRequeststatic classAbstractAsyncBulkByScrollAction.OpTypestatic interfaceAbstractAsyncBulkByScrollAction.RequestWrapper<Self extends org.elasticsearch.action.DocWriteRequest<Self>>Wrapper for theDocWriteRequestthat are used in this action class.static classAbstractAsyncBulkByScrollAction.ScriptApplierApply aScriptto aAbstractAsyncBulkByScrollAction.RequestWrapper
-
Field Summary
Fields Modifier and Type Field Description protected org.elasticsearch.cluster.ClusterStateclusterStateprotected org.apache.logging.log4j.Loggerloggerprotected RequestmainRequestThe request for this action.protected org.elasticsearch.script.ScriptServicescriptServiceprotected org.elasticsearch.index.reindex.BulkByScrollTasktaskprotected org.elasticsearch.threadpool.ThreadPoolthreadPoolprotected org.elasticsearch.index.reindex.WorkerBulkByScrollTaskStateworker
-
Constructor Summary
Constructors Constructor Description AbstractAsyncBulkByScrollAction(org.elasticsearch.index.reindex.BulkByScrollTask task, org.apache.logging.log4j.Logger logger, org.elasticsearch.client.ParentTaskAssigningClient client, org.elasticsearch.threadpool.ThreadPool threadPool, Request mainRequest, org.elasticsearch.script.ScriptService scriptService, org.elasticsearch.cluster.ClusterState clusterState, org.elasticsearch.action.ActionListener<org.elasticsearch.index.reindex.BulkByScrollResponse> listener)AbstractAsyncBulkByScrollAction(org.elasticsearch.index.reindex.BulkByScrollTask task, org.apache.logging.log4j.Logger logger, org.elasticsearch.client.ParentTaskAssigningClient client, org.elasticsearch.threadpool.ThreadPool threadPool, Request mainRequest, org.elasticsearch.script.ScriptService scriptService, org.elasticsearch.cluster.ClusterState clusterState, org.elasticsearch.action.ActionListener<org.elasticsearch.index.reindex.BulkByScrollResponse> listener, org.elasticsearch.common.settings.Settings settings)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected booleanaccept(org.elasticsearch.index.reindex.ScrollableHitSource.Hit doc)Used to accept or ignore a search hit.protected abstract AbstractAsyncBulkByScrollAction.RequestWrapper<?>buildRequest(org.elasticsearch.index.reindex.ScrollableHitSource.Hit doc)Build theAbstractAsyncBulkByScrollAction.RequestWrapperfor a single search hit.protected org.elasticsearch.index.reindex.BulkByScrollResponsebuildResponse(org.elasticsearch.common.unit.TimeValue took, java.util.List<org.elasticsearch.action.bulk.BulkItemResponse.Failure> indexingFailures, java.util.List<org.elasticsearch.index.reindex.ScrollableHitSource.SearchFailure> searchFailures, boolean timedOut)Build the response for reindex actions.java.util.function.BiFunction<AbstractAsyncBulkByScrollAction.RequestWrapper<?>,org.elasticsearch.index.reindex.ScrollableHitSource.Hit,AbstractAsyncBulkByScrollAction.RequestWrapper<?>>buildScriptApplier()Build theBiFunctionto apply to allAbstractAsyncBulkByScrollAction.RequestWrapper.protected org.elasticsearch.index.reindex.ScrollableHitSourcebuildScrollableResultSource(org.elasticsearch.action.bulk.BackoffPolicy backoffPolicy)protected AbstractAsyncBulkByScrollAction.RequestWrapper<?>copyMetadata(AbstractAsyncBulkByScrollAction.RequestWrapper<?> request, org.elasticsearch.index.reindex.ScrollableHitSource.Hit doc)Copies the metadata from a hit to the request.protected voidcopyRouting(AbstractAsyncBulkByScrollAction.RequestWrapper<?> request, java.lang.String routing)Copy the routing from a search hit to the request.protected voidfinishHim(java.lang.Exception failure)Finish the request.protected voidfinishHim(java.lang.Exception failure, java.util.List<org.elasticsearch.action.bulk.BulkItemResponse.Failure> indexingFailures, java.util.List<org.elasticsearch.index.reindex.ScrollableHitSource.SearchFailure> searchFailures, boolean timedOut)Finish the request.protected abstract booleanneedsSourceDocumentVersions()Does this operation need the versions of the source documents?voidstart()Start the action by firing the initial search request.static AbstractAsyncBulkByScrollAction.RequestWrapper<org.elasticsearch.action.delete.DeleteRequest>wrap(org.elasticsearch.action.delete.DeleteRequest request)Wraps aDeleteRequestin aAbstractAsyncBulkByScrollAction.RequestWrapperstatic AbstractAsyncBulkByScrollAction.RequestWrapper<org.elasticsearch.action.index.IndexRequest>wrap(org.elasticsearch.action.index.IndexRequest request)Wraps aIndexRequestin aAbstractAsyncBulkByScrollAction.RequestWrapper
-
-
-
Field Detail
-
logger
protected final org.apache.logging.log4j.Logger logger
-
task
protected final org.elasticsearch.index.reindex.BulkByScrollTask task
-
worker
protected final org.elasticsearch.index.reindex.WorkerBulkByScrollTaskState worker
-
threadPool
protected final org.elasticsearch.threadpool.ThreadPool threadPool
-
scriptService
protected final org.elasticsearch.script.ScriptService scriptService
-
clusterState
protected final org.elasticsearch.cluster.ClusterState clusterState
-
-
Constructor Detail
-
AbstractAsyncBulkByScrollAction
public AbstractAsyncBulkByScrollAction(org.elasticsearch.index.reindex.BulkByScrollTask task, org.apache.logging.log4j.Logger logger, org.elasticsearch.client.ParentTaskAssigningClient client, org.elasticsearch.threadpool.ThreadPool threadPool, Request mainRequest, org.elasticsearch.script.ScriptService scriptService, org.elasticsearch.cluster.ClusterState clusterState, org.elasticsearch.action.ActionListener<org.elasticsearch.index.reindex.BulkByScrollResponse> listener)
-
AbstractAsyncBulkByScrollAction
public AbstractAsyncBulkByScrollAction(org.elasticsearch.index.reindex.BulkByScrollTask task, org.apache.logging.log4j.Logger logger, org.elasticsearch.client.ParentTaskAssigningClient client, org.elasticsearch.threadpool.ThreadPool threadPool, Request mainRequest, org.elasticsearch.script.ScriptService scriptService, org.elasticsearch.cluster.ClusterState clusterState, org.elasticsearch.action.ActionListener<org.elasticsearch.index.reindex.BulkByScrollResponse> listener, org.elasticsearch.common.settings.Settings settings)
-
-
Method Detail
-
buildScriptApplier
public java.util.function.BiFunction<AbstractAsyncBulkByScrollAction.RequestWrapper<?>,org.elasticsearch.index.reindex.ScrollableHitSource.Hit,AbstractAsyncBulkByScrollAction.RequestWrapper<?>> buildScriptApplier()
Build theBiFunctionto 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(org.elasticsearch.index.reindex.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, org.elasticsearch.index.reindex.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(org.elasticsearch.index.reindex.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 org.elasticsearch.index.reindex.ScrollableHitSource buildScrollableResultSource(org.elasticsearch.action.bulk.BackoffPolicy backoffPolicy)
-
buildResponse
protected org.elasticsearch.index.reindex.BulkByScrollResponse buildResponse(org.elasticsearch.common.unit.TimeValue took, java.util.List<org.elasticsearch.action.bulk.BulkItemResponse.Failure> indexingFailures, java.util.List<org.elasticsearch.index.reindex.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<org.elasticsearch.action.bulk.BulkItemResponse.Failure> indexingFailures, java.util.List<org.elasticsearch.index.reindex.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<org.elasticsearch.action.index.IndexRequest> wrap(org.elasticsearch.action.index.IndexRequest request)
Wraps aIndexRequestin aAbstractAsyncBulkByScrollAction.RequestWrapper
-
wrap
public static AbstractAsyncBulkByScrollAction.RequestWrapper<org.elasticsearch.action.delete.DeleteRequest> wrap(org.elasticsearch.action.delete.DeleteRequest request)
Wraps aDeleteRequestin aAbstractAsyncBulkByScrollAction.RequestWrapper
-
-