Interface TaskDescriptor<V extends Serializable>

Type Parameters:
V - the result type.
All Superinterfaces:
Serializable
All Known Implementing Classes:
MockTaskDescriptor

public interface TaskDescriptor<V extends Serializable> extends Serializable
TaskDescriptor describes the state of a long running task.
Since:
v3.13
  • Method Details

    • getResult

      V getResult()
      This returns the result of the long running task. Returns null if the task is not finished.
      Returns:
      the result of the long running task or null if it has not return value.
    • isStarted

      boolean isStarted()
      True if the task has been started.
      Returns:
      true if the task has been started.
    • isFinished

      boolean isFinished()
      Tells if caller if the task has finished running or not.
      Returns:
      true if the task has finished running.
    • getTaskId

      Long getTaskId()
      Return the identifier for this task. This is only unique in the current execution of the JVM.
      Returns:
      The unique id of the task
    • getStartedTimestamp

      Date getStartedTimestamp()
      Return the date when the task was started.
      Returns:
      the time that task was started. null will be returned if the task has not started executing.
    • getFinishedTimestamp

      Date getFinishedTimestamp()
      Return the date when the task was finished.
      Returns:
      the time that task finished executing. null will be returned if the task has not finished executing.
    • getSubmittedTimestamp

      Date getSubmittedTimestamp()
      Return the date when the task was submitted.
      Returns:
      the time that task was submitted to the TaskManager. A null value will never be returned as the task will always have a submission time.
    • getElapsedRunTime

      long getElapsedRunTime()
      This returns number of milliseconds the task has been running for. Will return zero if the task has not started. When the task has started but not finished, it will return the the difference between the current time and the time was started (i.e. it will change). When the task has finished, it will return the difference between the start time and the end time (i.e. it will not change).
      Returns:
      the elapsed run time in milliseconds.
    • getUserName

      String getUserName()
      Return the user that started to task.
      Returns:
      the user that caused the task to be submitted. This may be null.
    • getDescription

      String getDescription()
      Return the description of the task passed when it was created.
      Returns:
      a meaningful description of the task
    • getTaskContext

      TaskContext getTaskContext()
      Return the context of task. Code that starts long running tasks can implement their own variants of this.
      Returns:
      the context of the task. This method will never return null as a task must always have a context.
    • getProgressURL

      String getProgressURL()
      Returns the URL that displays progress on this task. It is built using the TaskContext.
      Returns:
      the URL that displays progress for this task. null cannot be returned.
    • getTaskProgressIndicator

      TaskProgressIndicator getTaskProgressIndicator()
      Return the TaskProgressIndicator associated with the task. A task will only have an indicator if its callable implements the ProvidesTaskProgress interface.
      Returns:
      the TaskProgressIndicator associated with the task or null if there isn't one.
    • isCancellable

      boolean isCancellable()
      Returns whether this supports requests to cancel it.
      Returns:
      true if cancellation is supported, and false otherwise
      Since:
      v5.2
    • isCancelled

      boolean isCancelled()
      Returns whether cancellation of task has been requested. Long-running operations should poll to see if task has been requested.
      Returns:
      true if cancellation has been requested, and false otherwise
      Since:
      v5.2
    • setCancelled

      void setCancelled(boolean cancelled)
      Set flag to indicate this task has been cancelled;
      Parameters:
      cancelled - Cancelled flag
    • isSelfRecovering

      boolean isSelfRecovering()
      Returns whether the task will be automatically picked up again by the cluster if the node that was executing it crashes.

      Used by Jira to determine which tasks it should clean up after detecting such crashed node.

      Since:
      v8.5.4, v8.6.2, v8.7.1, v8.8.0
      See Also:
    • setResult

      void setResult(V result)
      Store the result in the descriptor.
      Parameters:
      result - The Result
    • getNodeId

      String getNodeId()
      Returns node id from where task was submitted
      Returns:
      node id
    • getSpanningOperation

      @Nullable SpanningOperation getSpanningOperation()
      Return operation that this task is part of.
      Returns:
      operation that this task is part of