Search in sources :

Example 1 with BulkByScrollTask

use of org.elasticsearch.action.bulk.byscroll.BulkByScrollTask in project elasticsearch by elastic.

the class TransportRethrottleAction method rethrottle.

static void rethrottle(String localNodeId, Client client, BulkByScrollTask task, float newRequestsPerSecond, ActionListener<TaskInfo> listener) {
    int runningSubTasks = task.runningSliceSubTasks();
    if (runningSubTasks == 0) {
        // Nothing to do, all sub tasks are done
        task.rethrottle(newRequestsPerSecond);
        listener.onResponse(task.taskInfo(localNodeId, true));
        return;
    }
    RethrottleRequest subRequest = new RethrottleRequest();
    subRequest.setRequestsPerSecond(newRequestsPerSecond / runningSubTasks);
    subRequest.setParentTaskId(new TaskId(localNodeId, task.getId()));
    client.execute(RethrottleAction.INSTANCE, subRequest, ActionListener.wrap(r -> {
        r.rethrowFailures("Rethrottle");
        listener.onResponse(task.getInfoGivenSliceInfo(localNodeId, r.getTasks()));
    }, listener::onFailure));
}
Also used : TaskInfo(org.elasticsearch.tasks.TaskInfo) ActionFilters(org.elasticsearch.action.support.ActionFilters) FailedNodeException(org.elasticsearch.action.FailedNodeException) Client(org.elasticsearch.client.Client) ClusterService(org.elasticsearch.cluster.service.ClusterService) IOException(java.io.IOException) TaskId(org.elasticsearch.tasks.TaskId) Inject(org.elasticsearch.common.inject.Inject) ListTasksResponse(org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse) List(java.util.List) Settings(org.elasticsearch.common.settings.Settings) TaskOperationFailure(org.elasticsearch.action.TaskOperationFailure) StreamInput(org.elasticsearch.common.io.stream.StreamInput) TransportTasksAction(org.elasticsearch.action.support.tasks.TransportTasksAction) ThreadPool(org.elasticsearch.threadpool.ThreadPool) TransportService(org.elasticsearch.transport.TransportService) BulkByScrollTask(org.elasticsearch.action.bulk.byscroll.BulkByScrollTask) IndexNameExpressionResolver(org.elasticsearch.cluster.metadata.IndexNameExpressionResolver) ActionListener(org.elasticsearch.action.ActionListener) TaskId(org.elasticsearch.tasks.TaskId)

Aggregations

IOException (java.io.IOException)1 List (java.util.List)1 ActionListener (org.elasticsearch.action.ActionListener)1 FailedNodeException (org.elasticsearch.action.FailedNodeException)1 TaskOperationFailure (org.elasticsearch.action.TaskOperationFailure)1 ListTasksResponse (org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse)1 BulkByScrollTask (org.elasticsearch.action.bulk.byscroll.BulkByScrollTask)1 ActionFilters (org.elasticsearch.action.support.ActionFilters)1 TransportTasksAction (org.elasticsearch.action.support.tasks.TransportTasksAction)1 Client (org.elasticsearch.client.Client)1 IndexNameExpressionResolver (org.elasticsearch.cluster.metadata.IndexNameExpressionResolver)1 ClusterService (org.elasticsearch.cluster.service.ClusterService)1 Inject (org.elasticsearch.common.inject.Inject)1 StreamInput (org.elasticsearch.common.io.stream.StreamInput)1 Settings (org.elasticsearch.common.settings.Settings)1 TaskId (org.elasticsearch.tasks.TaskId)1 TaskInfo (org.elasticsearch.tasks.TaskInfo)1 ThreadPool (org.elasticsearch.threadpool.ThreadPool)1 TransportService (org.elasticsearch.transport.TransportService)1