Class TaskState

java.lang.Object
org.apache.drill.yarn.appMaster.TaskState
Direct Known Subclasses:
TaskState.EndingState, TaskState.KillingState

public abstract class TaskState extends Object
Represents the behaviors associated with each state in the lifecycle of a task.

Startup process:

START --> REQUESTING
New task sends a container request to YARN.
REQUESTING --> LAUNCHING
Container received from YARN, launching the tasks's process.
LAUNCHING --> RUNNING
Task launched and needs no start Ack.
LAUNCHING --> WAIT_START_ACK
Task launched and needs a start Ack.
WAIT_START_ACK --> RUNNING
Start Ack received.

Shutdown process:

RUNNING --> WAIT_END_ACK | END
The resource manager reported task completion.
RUNNING --> ENDING
Request sent to the task for a graceful shutdown.
RUNNING --> KILLING
Request sent to the node manager to forcibly kill the task.
ENDING --> WAIT_END_ACK | END
The task gracefully exited as reported by the resource manager.
ENDING --> KILLING
The wait for graceful exit timed out, a forced kill message sent to the node manager.
KILLING --> WAIT_END_ACK | END
The task exited as reported by the resource manager.
END_ACK --> END
The end-ack is received or the wait timed out.

This is a do-it-yourself enum. Java enums values are instances of a single class. In this version, each enum value is the sole instance of a separate class, allowing each state to have its own behavior.

  • Field Details

    • START

      public static final TaskState START
    • REQUESTING

      public static final TaskState REQUESTING
    • LAUNCHING

      public static final TaskState LAUNCHING
    • WAIT_START_ACK

      public static final TaskState WAIT_START_ACK
    • RUNNING

      public static final TaskState RUNNING
    • ENDING

      public static final TaskState ENDING
    • KILLING

      public static final TaskState KILLING
    • WAIT_END_ACK

      public static final TaskState WAIT_END_ACK
    • END

      public static final TaskState END
    • hasContainer

      protected final boolean hasContainer
    • lifeCycleEvent

      protected final TaskLifecycleListener.Event lifeCycleEvent
    • label

      protected final String label
    • cancellable

      protected final boolean cancellable
  • Constructor Details

  • Method Details

    • endOrAck

      protected void endOrAck(EventContext context)
    • requestContainer

      public void requestContainer(EventContext context)
    • containerAllocated

      public void containerAllocated(EventContext context, org.apache.hadoop.yarn.api.records.Container container)
      Resource Manager reports that the task has been allocated a container.
      Parameters:
      context -
      container -
    • launchFailed

      public void launchFailed(EventContext context, Throwable t)
      The launch of the container failed.
      Parameters:
      context -
      t -
    • containerStarted

      public void containerStarted(EventContext context)
      Node Manager reports that the task has started execution.
      Parameters:
      context -
    • startAck

      public void startAck(EventContext context)
      The monitoring plugin has detected that the task has confirmed that it is fully started.
    • stopTaskFailed

      public void stopTaskFailed(EventContext context, Throwable t)
      The node manager request to stop a task failed.
      Parameters:
      context -
      t -
    • completionAck

      public void completionAck(EventContext context)
      The monitoring plugin has detected that the task has confirmed that it has started shutdown.
    • containerStopped

      public void containerStopped(EventContext context)
      Node Manager reports that the task has stopped execution. We don't yet know if this was a success or failure.
      Parameters:
      context -
    • containerCompleted

      public void containerCompleted(EventContext context, org.apache.hadoop.yarn.api.records.ContainerStatus status)
      Resource Manager reports that the task has completed execution and provided the completion status.
      Parameters:
      context -
      status -
    • cancel

      public void cancel(EventContext context)
      Cluster manager wishes to cancel this task.
      Parameters:
      context -
    • tick

      public void tick(EventContext context, long curTime)
    • transition

      protected void transition(EventContext context, TaskState newState)
      Implement a state transition, alerting any life cycle listeners and updating the log file. Marks the start time of the new state in support of states that implement a timeout.
      Parameters:
      context -
      newState -
    • taskStartFailed

      protected void taskStartFailed(EventContext context, Task.Disposition disposition)
      Task failed when starting. No container has been allocated. The task will go from:
      * --> END

      If the run failed, and the task can be retried, it may then move from
      END --> STARTING

      Parameters:
      context -
      disposition -
    • taskTerminated

      protected void taskTerminated(EventContext context)
      A running task terminated. It may have succeeded or failed, this method will determine which.

      Every task goes from:
      * --> END

      If the run failed, and the task can be retried, it may then move from
      END --> STARTING

      Parameters:
      context -
    • completed

      protected void completed(EventContext context, org.apache.hadoop.yarn.api.records.ContainerStatus status)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hasContainer

      public boolean hasContainer()
    • getLabel

      public String getLabel()
    • isCancellable

      public boolean isCancellable()