module Elasticsearch::API::Tasks::Actions
Public Instance Methods
Source
# File lib/elasticsearch/api/actions/tasks/cancel.rb, line 48 def cancel(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'tasks.cancel' } defined_params = [:task_id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _task_id = arguments.delete(:task_id) method = Elasticsearch::API::HTTP_POST path = if _task_id "_tasks/#{Utils.listify(_task_id)}/_cancel" else '_tasks/_cancel' end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
Cancel a task. WARNING: The task management API
is new and should still be considered a beta feature. The API
may change in ways that are not backwards compatible. A task may continue to run for some time after it has been cancelled because it may not be able to safely stop its current activity straight away. It is also possible that Elasticsearch
must complete its work on other tasks before it can process the cancellation. The get task information API
will continue to list these cancelled tasks until they complete. The cancelled flag in the response indicates that the cancellation command has been processed and the task will stop as soon as possible. To troubleshoot why a cancelled task does not complete promptly, use the get task information API
with the +?detailed+ parameter to identify the other tasks the system is running. You can also use the node hot threads API
to obtain detailed information about the work the system is doing instead of completing the cancelled task. This functionality is Experimental and may be changed or removed completely in a future release. Elastic will take a best effort approach to fix any issues, but experimental features are not subject to the support SLA of official GA features.
@option arguments [String, Integer] :task_id The task identifier. @option arguments [String] :actions A comma-separated list or wildcard expression of actions that is used to limit the request. @option arguments [Array<String>] :nodes A comma-separated list of node IDs or names that is used to limit the request. @option arguments [String] :parent_task_id A parent task ID that is used to limit the tasks. @option arguments [Boolean] :wait_for_completion If true, the request blocks until all found tasks are complete. @option arguments [Hash] :headers Custom HTTP headers
@see www.elastic.co/docs/api/doc/elasticsearch/v9/group/endpoint-tasks
Source
# File lib/elasticsearch/api/actions/tasks/get.rb, line 43 def get(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'tasks.get' } defined_params = [:task_id].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'task_id' missing" unless arguments[:task_id] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil _task_id = arguments.delete(:task_id) method = Elasticsearch::API::HTTP_GET path = "_tasks/#{Utils.listify(_task_id)}" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
Get task information. Get information about a task currently running in the cluster. WARNING: The task management API
is new and should still be considered a beta feature. The API
may change in ways that are not backwards compatible. If the task identifier is not found, a 404 response code indicates that there are no resources that match the request. This functionality is Experimental and may be changed or removed completely in a future release. Elastic will take a best effort approach to fix any issues, but experimental features are not subject to the support SLA of official GA features.
@option arguments [String] :task_id The task identifier. (Required) @option arguments [Time] :timeout The period to wait for a response.
If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s.
@option arguments [Boolean] :wait_for_completion If true
, the request blocks until the task has completed. @option arguments [Hash] :headers Custom HTTP headers
@see www.elastic.co/docs/api/doc/elasticsearch/v9/group/endpoint-tasks
Source
# File lib/elasticsearch/api/actions/tasks/list.rb, line 100 def list(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'tasks.list' } arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil method = Elasticsearch::API::HTTP_GET path = '_tasks' params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end
Get all tasks. Get information about the tasks currently running on one or more nodes in the cluster. WARNING: The task management API
is new and should still be considered a beta feature. The API
may change in ways that are not backwards compatible. **Identifying running tasks** The +X-Opaque-Id header+, when provided on the HTTP request header, is going to be returned as a header in the response as well as in the headers field for in the task information. This enables you to track certain calls or associate certain tasks with the client that started them. For example: + curl -i -H “X-Opaque-Id: 123456” “localhost:9200/_tasks?group_by=parents” + The API
returns the following result: + HTTP/1.1 200 OK X-Opaque-Id: 123456 content-type: application/json; charset=UTF-8 content-length: 831 {
"tasks" : { "u5lcZHqcQhu-rUoFaqDphA:45" : { "node" : "u5lcZHqcQhu-rUoFaqDphA", "id" : 45, "type" : "transport", "action" : "cluster:monitor/tasks/lists", "start_time_in_millis" : 1513823752749, "running_time_in_nanos" : 293139, "cancellable" : false, "headers" : { "X-Opaque-Id" : "123456" }, "children" : [ { "node" : "u5lcZHqcQhu-rUoFaqDphA", "id" : 46, "type" : "direct", "action" : "cluster:monitor/tasks/lists[n]", "start_time_in_millis" : 1513823752750, "running_time_in_nanos" : 92133, "cancellable" : false, "parent_task_id" : "u5lcZHqcQhu-rUoFaqDphA:45", "headers" : { "X-Opaque-Id" : "123456" } } ] } } }
+ In this example, +X-Opaque-Id: 123456+ is the ID as a part of the response header. The X-Opaque-Id
in the task headers
is the ID for the task that was initiated by the REST request. The X-Opaque-Id
in the children headers
is the child task of the task that was initiated by the REST request. This functionality is Experimental and may be changed or removed completely in a future release. Elastic will take a best effort approach to fix any issues, but experimental features are not subject to the support SLA of official GA features.
@option arguments [String] :actions A comma-separated list or wildcard expression of actions used to limit the request.
For example, you can use +cluser:*+ to retrieve all cluster-related tasks.
@option arguments [Boolean] :detailed If true
, the response includes detailed information about the running tasks.
This information is useful to distinguish tasks from each other but is more costly to run.
@option arguments [String] :group_by A key that is used to group tasks in the response.
The task lists can be grouped either by nodes or by parent tasks.
@option arguments [String, Array] :nodes A comma-separated list of node IDs or names that is used to limit the returned information. @option arguments [String] :parent_task_id A parent task identifier that is used to limit returned information.
To return all tasks, omit this parameter or use a value of +-1+. If the parent task is not found, the API does not return a 404 response code.
@option arguments [Time] :timeout The period to wait for each node to respond.
If a node does not respond before its timeout expires, the response does not include its information. However, timed out nodes are included in the +node_failures+ property. Server default: 30s.
@option arguments [Boolean] :wait_for_completion If true
, the request blocks until the operation is complete. @option arguments [Hash] :headers Custom HTTP headers
@see www.elastic.co/docs/api/doc/elasticsearch/v9/group/endpoint-tasks