Package org.elasticsearch.index.reindex
Class BulkByScrollTask
- java.lang.Object
-
- org.elasticsearch.tasks.Task
-
- org.elasticsearch.tasks.CancellableTask
-
- org.elasticsearch.index.reindex.BulkByScrollTask
-
public class BulkByScrollTask extends CancellableTask
Task storing information about a currently running BulkByScroll request. When the request is not sliced, this task is the only task created, and starts an action to perform search requests. When the request is sliced, this task can either represent a coordinating task (usingsetWorkerCount(int)
) or a worker task that performs search queries (usingsetWorker(float, Integer)
). We don't always know if this task will be a leader or worker task when it's created, because if slices is set to "auto" it may be either depending on the number of shards in the source indices. We figure that out when the request is handled and set it on this class withsetWorkerCount(int)
orsetWorker(float, Integer)
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BulkByScrollTask.Status
Status of the reindex, update by query, or delete by query.static class
BulkByScrollTask.StatusBuilder
This class acts as a builder forBulkByScrollTask.Status
.static class
BulkByScrollTask.StatusOrException
The status of a slice of the request.
-
Field Summary
-
Fields inherited from class org.elasticsearch.tasks.Task
X_OPAQUE_ID
-
-
Constructor Summary
Constructors Constructor Description BulkByScrollTask(long id, java.lang.String type, java.lang.String action, java.lang.String description, TaskId parentTaskId, java.util.Map<java.lang.String,java.lang.String> headers)
-
Method Summary
Modifier and Type Method Description LeaderBulkByScrollTaskState
getLeaderState()
Returns the object that tracks the state of sliced subtasks.BulkByScrollTask.Status
getStatus()
Build a status for this task or null if this task doesn't have status.WorkerBulkByScrollTaskState
getWorkerState()
Returns the object that manages sending search requests.boolean
isLeader()
Returns true if this task is a leader for other slice subtasksboolean
isWorker()
Returns true if this task is a worker task that performs search requests.void
onCancelled()
Called after the task is cancelled so that it can take any actions that it has to take.void
setWorker(float requestsPerSecond, java.lang.Integer sliceId)
Sets this task to be a worker task that performs search requestsvoid
setWorkerCount(int slices)
Sets this task to be a leader task forslices
sliced subtasksboolean
shouldCancelChildrenOnCancellation()
Returns true if this task can potentially have children that need to be cancelled when it parent is cancelled.TaskInfo
taskInfoGivenSubtaskInfo(java.lang.String localNodeId, java.util.List<TaskInfo> sliceInfo)
Build the status for this task given a snapshot of the information of running slices.-
Methods inherited from class org.elasticsearch.tasks.CancellableTask
cancelOnParentLeaving, getReasonCancelled, isCancelled
-
Methods inherited from class org.elasticsearch.tasks.Task
getAction, getDescription, getHeader, getId, getParentTaskId, getStartTime, getType, result, result, taskInfo, taskInfo
-
-
-
-
Constructor Detail
-
BulkByScrollTask
public BulkByScrollTask(long id, java.lang.String type, java.lang.String action, java.lang.String description, TaskId parentTaskId, java.util.Map<java.lang.String,java.lang.String> headers)
-
-
Method Detail
-
getStatus
public BulkByScrollTask.Status getStatus()
Description copied from class:Task
Build a status for this task or null if this task doesn't have status. Since most tasks don't have status this defaults to returning null. While this can never perform IO it might be a costly operation, requiring collating lists of results, etc. So only use it if you need the value.
-
taskInfoGivenSubtaskInfo
public TaskInfo taskInfoGivenSubtaskInfo(java.lang.String localNodeId, java.util.List<TaskInfo> sliceInfo)
Build the status for this task given a snapshot of the information of running slices. This is only supported if the task is set as a leader for slice subtasks
-
isLeader
public boolean isLeader()
Returns true if this task is a leader for other slice subtasks
-
setWorkerCount
public void setWorkerCount(int slices)
Sets this task to be a leader task forslices
sliced subtasks
-
getLeaderState
public LeaderBulkByScrollTaskState getLeaderState()
Returns the object that tracks the state of sliced subtasks. Throws IllegalStateException if this task is not set to be a leader task.
-
isWorker
public boolean isWorker()
Returns true if this task is a worker task that performs search requests. False otherwise
-
setWorker
public void setWorker(float requestsPerSecond, @Nullable java.lang.Integer sliceId)
Sets this task to be a worker task that performs search requests- Parameters:
requestsPerSecond
- How many search requests per second this task should makesliceId
- If this is is a sliced task, which slice number this task corresponds to. Null if not sliced.
-
getWorkerState
public WorkerBulkByScrollTaskState getWorkerState()
Returns the object that manages sending search requests. Throws IllegalStateException if this task is not set to be a worker task.
-
onCancelled
public void onCancelled()
Description copied from class:CancellableTask
Called after the task is cancelled so that it can take any actions that it has to take.- Overrides:
onCancelled
in classCancellableTask
-
shouldCancelChildrenOnCancellation
public boolean shouldCancelChildrenOnCancellation()
Description copied from class:CancellableTask
Returns true if this task can potentially have children that need to be cancelled when it parent is cancelled.- Specified by:
shouldCancelChildrenOnCancellation
in classCancellableTask
-
-