Class Task

java.lang.Object
org.elasticsearch.tasks.Task
Direct Known Subclasses:
CancellableTask, PrimaryReplicaSyncer.ResyncTask, ReplicationTask

public class Task
extends java.lang.Object
Current task information
  • Nested Class Summary

    Nested Classes
    Modifier and Type Class Description
    static interface  Task.Status
    Report of the internal status of a task.
  • Field Summary

    Fields
    Modifier and Type Field Description
    static java.lang.String X_OPAQUE_ID
    The request header to mark tasks with specific ids
  • Constructor Summary

    Constructors
    Constructor Description
    Task​(long id, java.lang.String type, java.lang.String action, java.lang.String description, TaskId parentTask, long startTime, long startTimeNanos, java.util.Map<java.lang.String,​java.lang.String> headers)  
    Task​(long id, java.lang.String type, java.lang.String action, java.lang.String description, TaskId parentTask, java.util.Map<java.lang.String,​java.lang.String> headers)  
  • Method Summary

    Modifier and Type Method Description
    java.lang.String getAction()
    Returns task action
    java.lang.String getDescription()
    Generates task description
    java.lang.String getHeader​(java.lang.String header)
    Returns stored task header associated with the task
    long getId()
    Returns task id
    TaskId getParentTaskId()
    Returns id of the parent task or NO_PARENT_ID if the task doesn't have any parent tasks
    long getStartTime()
    Returns the task's start time as a wall clock time since epoch (System.currentTimeMillis() style).
    long getStartTimeNanos()
    Returns the task's start time in nanoseconds (System.nanoTime() style).
    Task.Status getStatus()
    Build a status for this task or null if this task doesn't have status.
    java.lang.String getType()
    Returns task channel type (netty, transport, direct)
    java.util.Map<java.lang.String,​java.lang.String> headers()  
    TaskResult result​(DiscoveryNode node, java.lang.Exception error)  
    TaskResult result​(DiscoveryNode node, ActionResponse response)  
    TaskInfo taskInfo​(java.lang.String localNodeId, boolean detailed)
    Build a version of the task status you can throw over the wire and back to the user.
    protected TaskInfo taskInfo​(java.lang.String localNodeId, java.lang.String description, Task.Status status)
    Build a proper TaskInfo for this task.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • X_OPAQUE_ID

      public static final java.lang.String X_OPAQUE_ID
      The request header to mark tasks with specific ids
      See Also:
      Constant Field Values
  • Constructor Details

    • Task

      public Task​(long id, java.lang.String type, java.lang.String action, java.lang.String description, TaskId parentTask, java.util.Map<java.lang.String,​java.lang.String> headers)
    • Task

      public Task​(long id, java.lang.String type, java.lang.String action, java.lang.String description, TaskId parentTask, long startTime, long startTimeNanos, java.util.Map<java.lang.String,​java.lang.String> headers)
  • Method Details

    • taskInfo

      public final TaskInfo taskInfo​(java.lang.String localNodeId, boolean detailed)
      Build a version of the task status you can throw over the wire and back to the user.
      Parameters:
      localNodeId - the id of the node this task is running on
      detailed - should the information include detailed, potentially slow to generate data?
    • taskInfo

      protected final TaskInfo taskInfo​(java.lang.String localNodeId, java.lang.String description, Task.Status status)
      Build a proper TaskInfo for this task.
    • getId

      public long getId()
      Returns task id
    • getType

      public java.lang.String getType()
      Returns task channel type (netty, transport, direct)
    • getAction

      public java.lang.String getAction()
      Returns task action
    • getDescription

      public java.lang.String getDescription()
      Generates task description
    • getStartTime

      public long getStartTime()
      Returns the task's start time as a wall clock time since epoch (System.currentTimeMillis() style).
    • getStartTimeNanos

      public long getStartTimeNanos()
      Returns the task's start time in nanoseconds (System.nanoTime() style).
    • getParentTaskId

      public TaskId getParentTaskId()
      Returns id of the parent task or NO_PARENT_ID if the task doesn't have any parent tasks
    • getStatus

      public Task.Status getStatus()
      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.
    • getHeader

      public java.lang.String getHeader​(java.lang.String header)
      Returns stored task header associated with the task
    • headers

      public java.util.Map<java.lang.String,​java.lang.String> headers()
    • result

      public TaskResult result​(DiscoveryNode node, java.lang.Exception error) throws java.io.IOException
      Throws:
      java.io.IOException
    • result

      public TaskResult result​(DiscoveryNode node, ActionResponse response) throws java.io.IOException
      Throws:
      java.io.IOException