State Machine & Event Map
Tez's application master is a set of event-driven finite state machines. Every
control-plane entity — the DAG, each vertex, each task, each attempt, each
container, each node — is a Hadoop StateMachineFactory machine. Nothing calls a
method on another entity directly; instead it puts an event on the central
dispatcher, which delivers it to the target entity's handler, which runs a
transition. This file is the reference for those states and events: the real
enums, and a routing table of who sends what to whom.
Read ../deep-dives/state-machines.md for the
mechanism and ../deep-dives/event-routing.md
for the dispatch. Every enum below was extracted from source; confirm with:
# A state enum:
grep -A15 "enum VertexState" tez-dag/src/main/java/org/apache/tez/dag/app/dag/VertexState.java
# An event-type enum:
grep -A20 "enum TaskAttemptEventType" \
tez-dag/src/main/java/org/apache/tez/dag/app/dag/event/TaskAttemptEventType.java
# The dispatcher registrations that build the routing table:
grep -n "dispatcher.register" tez-dag/src/main/java/org/apache/tez/dag/app/DAGAppMaster.java
The state enums
DAGState — ...dag.app.dag.DAGState
The internal state of one DAG (DAGImpl).
| Value | Meaning |
|---|---|
NEW | Constructed, not yet initialized |
INITED | Initialized (vertices/edges built), not started |
RUNNING | Executing vertices |
TERMINATING | A kill/fail is in progress; waiting for vertices to stop |
COMMITTING | Running output commit(s) after all vertices succeeded |
SUCCEEDED | Completed successfully |
FAILED | A vertex/task failure caused the DAG to fail |
KILLED | Killed by the client |
ERROR | Internal error (bug/inconsistency) |
VertexState — ...dag.app.dag.VertexState
The internal state of one vertex (VertexImpl). Note the extra INITIALIZING
state — a vertex can initialize asynchronously (input initializers, parallelism
decisions) before it is INITED.
| Value | Meaning |
|---|---|
NEW | Constructed |
INITIALIZING | Running input initializers / deciding parallelism |
INITED | Fully configured; parallelism, edges, I/O fixed |
RUNNING | Tasks executing |
TERMINATING | Stopping due to kill/fail |
COMMITTING | Committing this vertex's outputs (per-vertex commit mode) |
SUCCEEDED | All tasks succeeded |
FAILED | Failed |
KILLED | Killed |
ERROR | Internal error |
TaskStateInternal — ...dag.app.dag.TaskStateInternal
The internal state of one task (TaskImpl). Small, because a task is mostly a
holder for attempts.
| Value | Meaning |
|---|---|
NEW | Constructed |
SCHEDULED | Scheduled; an attempt has been (or is being) created |
RUNNING | An attempt is running |
SUCCEEDED | An attempt succeeded |
FAILED | Exhausted attempts / failed |
KILL_WAIT | Kill requested; waiting for the running attempt to stop |
KILLED | Killed |
TaskAttemptStateInternal — ...dag.app.dag.TaskAttemptStateInternal
The internal state of one attempt (TaskAttemptImpl). The *_IN_PROGRESS states
are the ones you will see in logs when an attempt is being torn down.
| Value | Meaning |
|---|---|
NEW | Constructed |
START_WAIT | Scheduled with the task scheduler; waiting for a container |
SUBMITTED | Assigned to a container and submitted to run |
RUNNING | Executing in the container |
KILL_IN_PROGRESS | Kill requested; container being told to stop |
FAIL_IN_PROGRESS | Failure being processed; container being torn down |
SUCCEEDED | Completed successfully |
FAILED | Failed |
KILLED | Killed |
AMContainerState / AMNodeState / DAGAppMasterState
| Enum | Values |
|---|---|
AMContainerState (...rm.container) | ALLOCATED, LAUNCHING, IDLE, RUNNING, STOP_REQUESTED, STOPPING, COMPLETED |
AMNodeState (...rm.node) | ACTIVE, FORCED_ACTIVE, BLACKLISTED, UNHEALTHY |
DAGAppMasterState (...dag.app) | NEW, INITED, RECOVERING, IDLE, RUNNING, SUCCEEDED, FAILED, KILLED, ERROR |
Public status enums (client-facing)
The internal states above are @Private. Clients see coarser enums over the wire.
Do not confuse them with the internal ones.
| Enum | Values | Note |
|---|---|---|
DAGStatus.State (...dag.api.client) | SUBMITTED, INITING, RUNNING, SUCCEEDED, KILLED, FAILED, ERROR | SUBMITTED only from the RM; INITING currently folded into RUNNING |
VertexStatus.State (...dag.api.client) | NEW, INITIALIZING, INITED, RUNNING, COMMITTING, SUCCEEDED, FAILED, KILLED, ERROR, TERMINATING | Mirrors internal VertexState closely |
TaskState (...dag.api.oldrecords) | NEW, SCHEDULED, RUNNING, SUCCEEDED, FAILED, KILLED | The public task state |
VertexState (...dag.api.event) | SUCCEEDED, RUNNING, FAILED, KILLED, PARALLELISM_UPDATED, CONFIGURED, INITIALIZING | The notification enum a VertexManagerPlugin receives — not the internal state machine |
Note: There are two
VertexStateenums....dag.app.dag.VertexStateis the AM's internal state machine;...dag.api.event.VertexStateis the public notification enum a vertex manager gets viaonVertexStateUpdated. Grep the package before assuming which one a symbol refers to.
The event-type enums
Each state machine is registered against exactly one event-type enum in
DAGAppMaster.serviceInit (see the dispatcher.register(...) calls). These are
the "control plane" events — distinct from the runtime org.apache.tez.runtime.api.events.*
data-plane events.
DAGEventType — drives DAGImpl
| Value | Meaning |
|---|---|
DAG_INIT | Initialize the DAG |
DAG_START | Begin execution |
DAG_VERTEX_COMPLETED | A vertex reached a terminal state |
DAG_VERTEX_RERUNNING | A completed vertex is re-running (downstream fetch failure) |
DAG_SCHEDULER_UPDATE | DAG scheduler wants to (re)schedule vertices |
DAG_COMMIT_COMPLETED | An output commit finished |
DAG_COUNTER_UPDATE | Counter deltas to aggregate |
DAG_DIAGNOSTIC_UPDATE | Append a diagnostic message |
DAG_TERMINATE | Kill request |
DAG_RECOVER | Recover this DAG from the recovery log |
INTERNAL_ERROR | Fatal inconsistency |
VertexEventType — drives VertexImpl
| Value | Meaning |
|---|---|
V_INIT | Initialize the vertex |
V_START | Start the vertex |
V_READY_TO_INIT | Preconditions met to move out of INITIALIZING |
V_SOURCE_VERTEX_STARTED | An upstream vertex started |
V_SOURCE_TASK_ATTEMPT_COMPLETED | An upstream attempt completed (source data available) |
V_TASK_COMPLETED | One of this vertex's tasks completed |
V_TASK_RESCHEDULED | A task must re-run (its output was lost) |
V_TASK_ATTEMPT_COMPLETED | One of this vertex's attempts completed |
V_ROUTE_EVENT | Carry runtime I/O events to be routed across edges |
V_ROOT_INPUT_INITIALIZED | An input initializer finished |
V_ROOT_INPUT_FAILED | An input initializer failed |
V_INPUT_DATA_INFORMATION | Split/parallelism info from an initializer |
V_NULL_EDGE_INITIALIZED | A custom edge finished initializing |
V_MANAGER_USER_CODE_ERROR | The vertex manager plugin threw |
V_COMMIT_COMPLETED | This vertex's commit finished |
V_RECOVER | Recover this vertex |
V_TERMINATE | Kill request |
V_INTERNAL_ERROR | Fatal inconsistency |
V_DELETE_SHUFFLE_DATA | Trigger cleanup of this vertex's shuffle data |
TaskEventType — drives TaskImpl
| Value | Meaning |
|---|---|
T_SCHEDULE | Schedule the task (create/launch an attempt) |
T_ADD_SPEC_ATTEMPT | Add a speculative attempt |
T_ATTEMPT_LAUNCHED | An attempt launched |
T_ATTEMPT_SUCCEEDED | An attempt succeeded |
T_ATTEMPT_FAILED | An attempt failed |
T_ATTEMPT_KILLED | An attempt was killed |
T_TERMINATE | Kill request |
TaskAttemptEventType — drives TaskAttemptImpl
| Value | Meaning |
|---|---|
TA_SCHEDULE | Schedule the attempt with the task scheduler |
TA_SUBMITTED | Assigned to a container and submitted |
TA_STARTED_REMOTELY | The container reported the attempt started |
TA_STATUS_UPDATE | Progress/counter heartbeat from the task |
TA_TEZ_EVENT_UPDATE | Runtime events from the task (for recovery) |
TA_DONE | The task reported success |
TA_FAILED | The task reported failure |
TA_KILLED | Killed (e.g. by a task communicator) |
TA_TIMED_OUT | Heartbeat timeout expired |
TA_KILL_REQUEST | Request to kill this attempt |
TA_CONTAINER_TERMINATING | Its container is being stopped |
TA_CONTAINER_TERMINATED | Its container stopped |
TA_CONTAINER_TERMINATED_BY_SYSTEM | Its container was killed by YARN/system |
TA_NODE_FAILED | The node hosting it went bad |
TA_OUTPUT_FAILED | A consumer reported this attempt's output unreadable |
Scheduler, launcher, container, node, and misc event types
| Enum | Values |
|---|---|
AMSchedulerEventType (...rm) | S_TA_LAUNCH_REQUEST, S_TA_STATE_UPDATED, S_TA_ENDED, S_CONTAINER_DEALLOCATE, S_NODE_BLACKLISTED, S_NODE_UNBLACKLISTED, S_NODE_HEALTHY, S_NODE_UNHEALTHY |
ContainerLauncherEventType (...rm) | CONTAINER_LAUNCH_REQUEST, CONTAINER_STOP_REQUEST |
AMContainerEventType (...rm.container) | C_LAUNCH_REQUEST, C_ASSIGN_TA, C_LAUNCHED, C_LAUNCH_FAILED, C_TA_SUCCEEDED, C_COMPLETED, C_NODE_FAILED, C_STOP_REQUEST, C_NM_STOP_SENT, C_NM_STOP_FAILED, C_TIMED_OUT |
AMNodeEventType (...rm.node) | N_CONTAINER_ALLOCATED, N_CONTAINER_COMPLETED, N_TA_SUCCEEDED, N_TA_ENDED, N_TURNED_UNHEALTHY, N_TURNED_HEALTHY, N_NODE_COUNT_UPDATED, N_IGNORE_BLACKLISTING_ENABLED, N_IGNORE_BLACKLISTING_DISABLED |
DAGAppMasterEventType (...dag.event) | INTERNAL_ERROR, AM_REBOOT, DAG_FINISHED, NEW_DAG_SUBMITTED, DAG_CLEANUP, SCHEDULING_SERVICE_ERROR, TASK_COMMUNICATOR_SERVICE_FATAL_ERROR, CONTAINER_LAUNCHER_SERVICE_FATAL_ERROR, TASK_SCHEDULER_SERVICE_FATAL_ERROR |
SpeculatorEventType (...dag.event) | S_TASK_ATTEMPT_STATUS_UPDATE |
CallableEventType (...dag.event) | CALLABLE |
HistoryEventType — the logged milestone stream
Not a state-machine driver, but the enum every history backend records. From
...dag.history.HistoryEventType (each value also carries a HistoryLogLevel):
APP_LAUNCHED, AM_LAUNCHED, AM_STARTED, DAG_SUBMITTED, DAG_INITIALIZED,
DAG_STARTED, DAG_FINISHED, DAG_KILL_REQUEST, VERTEX_INITIALIZED,
VERTEX_STARTED, VERTEX_CONFIGURE_DONE, VERTEX_FINISHED, TASK_STARTED,
TASK_FINISHED, TASK_ATTEMPT_STARTED, TASK_ATTEMPT_FINISHED,
CONTAINER_LAUNCHED, CONTAINER_STOPPED, DAG_COMMIT_STARTED,
VERTEX_COMMIT_STARTED, VERTEX_GROUP_COMMIT_STARTED,
VERTEX_GROUP_COMMIT_FINISHED, DAG_RECOVERED.
Dispatcher registrations (the backbone)
DAGAppMaster registers each event-type enum against one handler. This is the
authoritative wiring — everything in the routing table below flows through it:
| Event type | Registered handler |
|---|---|
DAGEventType | DagEventDispatcher → routes to the DAGImpl |
VertexEventType | VertexEventDispatcher → routes to the target VertexImpl |
TaskEventType | TaskEventDispatcher → routes to the target TaskImpl |
TaskAttemptEventType | TaskAttemptEventDispatcher → routes to the target TaskAttemptImpl |
AMContainerEventType | AMContainerMap → routes to the target AMContainerImpl |
AMNodeEventType | AMNodeTracker → routes to the target AMNodeImpl |
AMSchedulerEventType | TaskSchedulerManager |
ContainerLauncherEventType | ContainerLauncherManager |
DAGAppMasterEventType | DAGAppMaster.DAGAppMasterEventHandler |
SpeculatorEventType | SpeculatorEventHandler (its own dispatcher) |
Note:
TaskEventTypeandTaskAttemptEventTypecan share a concurrent dispatcher whentez.am.use.concurrent-dispatcher=true— the registration differs but the target*Implis the same. GrepregisterAndCreateDispatcherinDAGAppMasterto see it.
Who sends what to whom
The ~25 most important events on the happy path (schedule → launch → run →
complete) plus the key failure edges. "Producer" is the entity that raises the
event; "consumer" is the *Impl (via its registered dispatcher) that handles it.
This is the flow you trace when debugging "why did nothing happen after X".
| Event | Producer | Consumer | What it means |
|---|---|---|---|
DAG_START | DAGAppMaster | DAGImpl | Begin the DAG |
V_INIT / V_START | DAGImpl | VertexImpl | Initialize / start a vertex |
V_SOURCE_VERTEX_STARTED | VertexImpl (upstream) | VertexImpl (downstream) | Propagate upstream start |
T_SCHEDULE | VertexImpl | TaskImpl | Create/launch an attempt for a task |
TA_SCHEDULE | TaskImpl | TaskAttemptImpl | Ask for a container |
S_TA_LAUNCH_REQUEST | TaskAttemptImpl | TaskSchedulerManager | Request a container from YARN for this attempt |
C_LAUNCH_REQUEST | TaskSchedulerManager | AMContainerImpl | Allocate/launch a container |
CONTAINER_LAUNCH_REQUEST | AMContainerImpl | ContainerLauncherManager | Tell the NM to start the container process |
N_CONTAINER_ALLOCATED | TaskSchedulerManager | AMNodeImpl (via tracker) | Record a container on a node |
C_LAUNCHED | ContainerLauncherManager | AMContainerImpl | Container process started |
C_ASSIGN_TA | TaskSchedulerManager | AMContainerImpl | Assign this attempt to the (reused/new) container |
TA_SUBMITTED | AMContainerImpl | TaskAttemptImpl | Attempt handed to a container |
TA_STARTED_REMOTELY | TaskCommunicatorManager (umbilical) | TaskAttemptImpl | Container reported the attempt running |
TA_STATUS_UPDATE | TaskCommunicatorManager (umbilical) | TaskAttemptImpl | Progress + counter heartbeat |
S_TASK_ATTEMPT_STATUS_UPDATE | TaskAttemptImpl | Speculator | Feed the speculator timing data |
TA_DONE | TaskCommunicatorManager (umbilical) | TaskAttemptImpl | Task reported success |
C_TA_SUCCEEDED | TaskAttemptImpl | AMContainerImpl | Free the container for reuse |
S_TA_ENDED | TaskAttemptImpl | TaskSchedulerManager | Attempt ended; release/reuse its container |
N_TA_ENDED / N_TA_SUCCEEDED | TaskSchedulerManager | AMNodeImpl | Update per-node failure/success counts |
T_ATTEMPT_SUCCEEDED | TaskAttemptImpl | TaskImpl | An attempt succeeded |
V_TASK_COMPLETED | TaskImpl | VertexImpl | A task of this vertex completed |
V_SOURCE_TASK_ATTEMPT_COMPLETED | TaskAttemptImpl | VertexImpl (downstream) | Source data now available to consumers |
DAG_VERTEX_COMPLETED | VertexImpl | DAGImpl | A vertex reached terminal state |
TA_OUTPUT_FAILED | consumer TaskAttemptImpl (via InputReadErrorEvent) | producer TaskAttemptImpl | A downstream task couldn't read this output |
V_TASK_RESCHEDULED | VertexImpl | TaskImpl | Re-run a task whose output was lost |
C_COMPLETED | TaskSchedulerManager (RM callback) | AMContainerImpl | The container exited |
CONTAINER_STOP_REQUEST | AMContainerImpl | ContainerLauncherManager | Tell the NM to stop an idle container |
DAG_FINISHED | DAGImpl | DAGAppMaster | DAG done; in session mode, go IDLE; else shut down |
Warning: The producer/consumer pairs above describe the standard flow; a few events (e.g.
TA_STATUS_UPDATE,TA_DONE,TA_FAILED) originate from the task over the umbilical and are injected by theTaskCommunicatorManageron the AM's behalf, not raised by an AM state machine. When tracing, confirm the actual producer with agrepfor the event class's constructor call sites:grep -rn "new TaskAttemptEventStatusUpdate" tez-dag/src/main/java/ grep -rn "new AMSchedulerEventTALaunchRequest" tez-dag/src/main/java/