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).

ValueMeaning
NEWConstructed, not yet initialized
INITEDInitialized (vertices/edges built), not started
RUNNINGExecuting vertices
TERMINATINGA kill/fail is in progress; waiting for vertices to stop
COMMITTINGRunning output commit(s) after all vertices succeeded
SUCCEEDEDCompleted successfully
FAILEDA vertex/task failure caused the DAG to fail
KILLEDKilled by the client
ERRORInternal 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.

ValueMeaning
NEWConstructed
INITIALIZINGRunning input initializers / deciding parallelism
INITEDFully configured; parallelism, edges, I/O fixed
RUNNINGTasks executing
TERMINATINGStopping due to kill/fail
COMMITTINGCommitting this vertex's outputs (per-vertex commit mode)
SUCCEEDEDAll tasks succeeded
FAILEDFailed
KILLEDKilled
ERRORInternal error

TaskStateInternal — ...dag.app.dag.TaskStateInternal

The internal state of one task (TaskImpl). Small, because a task is mostly a holder for attempts.

ValueMeaning
NEWConstructed
SCHEDULEDScheduled; an attempt has been (or is being) created
RUNNINGAn attempt is running
SUCCEEDEDAn attempt succeeded
FAILEDExhausted attempts / failed
KILL_WAITKill requested; waiting for the running attempt to stop
KILLEDKilled

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.

ValueMeaning
NEWConstructed
START_WAITScheduled with the task scheduler; waiting for a container
SUBMITTEDAssigned to a container and submitted to run
RUNNINGExecuting in the container
KILL_IN_PROGRESSKill requested; container being told to stop
FAIL_IN_PROGRESSFailure being processed; container being torn down
SUCCEEDEDCompleted successfully
FAILEDFailed
KILLEDKilled

AMContainerState / AMNodeState / DAGAppMasterState

EnumValues
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.

EnumValuesNote
DAGStatus.State (...dag.api.client)SUBMITTED, INITING, RUNNING, SUCCEEDED, KILLED, FAILED, ERRORSUBMITTED only from the RM; INITING currently folded into RUNNING
VertexStatus.State (...dag.api.client)NEW, INITIALIZING, INITED, RUNNING, COMMITTING, SUCCEEDED, FAILED, KILLED, ERROR, TERMINATINGMirrors internal VertexState closely
TaskState (...dag.api.oldrecords)NEW, SCHEDULED, RUNNING, SUCCEEDED, FAILED, KILLEDThe public task state
VertexState (...dag.api.event)SUCCEEDED, RUNNING, FAILED, KILLED, PARALLELISM_UPDATED, CONFIGURED, INITIALIZINGThe notification enum a VertexManagerPlugin receives — not the internal state machine

Note: There are two VertexState enums. ...dag.app.dag.VertexState is the AM's internal state machine; ...dag.api.event.VertexState is the public notification enum a vertex manager gets via onVertexStateUpdated. 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

ValueMeaning
DAG_INITInitialize the DAG
DAG_STARTBegin execution
DAG_VERTEX_COMPLETEDA vertex reached a terminal state
DAG_VERTEX_RERUNNINGA completed vertex is re-running (downstream fetch failure)
DAG_SCHEDULER_UPDATEDAG scheduler wants to (re)schedule vertices
DAG_COMMIT_COMPLETEDAn output commit finished
DAG_COUNTER_UPDATECounter deltas to aggregate
DAG_DIAGNOSTIC_UPDATEAppend a diagnostic message
DAG_TERMINATEKill request
DAG_RECOVERRecover this DAG from the recovery log
INTERNAL_ERRORFatal inconsistency

VertexEventType — drives VertexImpl

ValueMeaning
V_INITInitialize the vertex
V_STARTStart the vertex
V_READY_TO_INITPreconditions met to move out of INITIALIZING
V_SOURCE_VERTEX_STARTEDAn upstream vertex started
V_SOURCE_TASK_ATTEMPT_COMPLETEDAn upstream attempt completed (source data available)
V_TASK_COMPLETEDOne of this vertex's tasks completed
V_TASK_RESCHEDULEDA task must re-run (its output was lost)
V_TASK_ATTEMPT_COMPLETEDOne of this vertex's attempts completed
V_ROUTE_EVENTCarry runtime I/O events to be routed across edges
V_ROOT_INPUT_INITIALIZEDAn input initializer finished
V_ROOT_INPUT_FAILEDAn input initializer failed
V_INPUT_DATA_INFORMATIONSplit/parallelism info from an initializer
V_NULL_EDGE_INITIALIZEDA custom edge finished initializing
V_MANAGER_USER_CODE_ERRORThe vertex manager plugin threw
V_COMMIT_COMPLETEDThis vertex's commit finished
V_RECOVERRecover this vertex
V_TERMINATEKill request
V_INTERNAL_ERRORFatal inconsistency
V_DELETE_SHUFFLE_DATATrigger cleanup of this vertex's shuffle data

TaskEventType — drives TaskImpl

ValueMeaning
T_SCHEDULESchedule the task (create/launch an attempt)
T_ADD_SPEC_ATTEMPTAdd a speculative attempt
T_ATTEMPT_LAUNCHEDAn attempt launched
T_ATTEMPT_SUCCEEDEDAn attempt succeeded
T_ATTEMPT_FAILEDAn attempt failed
T_ATTEMPT_KILLEDAn attempt was killed
T_TERMINATEKill request

TaskAttemptEventType — drives TaskAttemptImpl

ValueMeaning
TA_SCHEDULESchedule the attempt with the task scheduler
TA_SUBMITTEDAssigned to a container and submitted
TA_STARTED_REMOTELYThe container reported the attempt started
TA_STATUS_UPDATEProgress/counter heartbeat from the task
TA_TEZ_EVENT_UPDATERuntime events from the task (for recovery)
TA_DONEThe task reported success
TA_FAILEDThe task reported failure
TA_KILLEDKilled (e.g. by a task communicator)
TA_TIMED_OUTHeartbeat timeout expired
TA_KILL_REQUESTRequest to kill this attempt
TA_CONTAINER_TERMINATINGIts container is being stopped
TA_CONTAINER_TERMINATEDIts container stopped
TA_CONTAINER_TERMINATED_BY_SYSTEMIts container was killed by YARN/system
TA_NODE_FAILEDThe node hosting it went bad
TA_OUTPUT_FAILEDA consumer reported this attempt's output unreadable

Scheduler, launcher, container, node, and misc event types

EnumValues
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 typeRegistered handler
DAGEventTypeDagEventDispatcher → routes to the DAGImpl
VertexEventTypeVertexEventDispatcher → routes to the target VertexImpl
TaskEventTypeTaskEventDispatcher → routes to the target TaskImpl
TaskAttemptEventTypeTaskAttemptEventDispatcher → routes to the target TaskAttemptImpl
AMContainerEventTypeAMContainerMap → routes to the target AMContainerImpl
AMNodeEventTypeAMNodeTracker → routes to the target AMNodeImpl
AMSchedulerEventTypeTaskSchedulerManager
ContainerLauncherEventTypeContainerLauncherManager
DAGAppMasterEventTypeDAGAppMaster.DAGAppMasterEventHandler
SpeculatorEventTypeSpeculatorEventHandler (its own dispatcher)

Note: TaskEventType and TaskAttemptEventType can share a concurrent dispatcher when tez.am.use.concurrent-dispatcher=true — the registration differs but the target *Impl is the same. Grep registerAndCreateDispatcher in DAGAppMaster to 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".

EventProducerConsumerWhat it means
DAG_STARTDAGAppMasterDAGImplBegin the DAG
V_INIT / V_STARTDAGImplVertexImplInitialize / start a vertex
V_SOURCE_VERTEX_STARTEDVertexImpl (upstream)VertexImpl (downstream)Propagate upstream start
T_SCHEDULEVertexImplTaskImplCreate/launch an attempt for a task
TA_SCHEDULETaskImplTaskAttemptImplAsk for a container
S_TA_LAUNCH_REQUESTTaskAttemptImplTaskSchedulerManagerRequest a container from YARN for this attempt
C_LAUNCH_REQUESTTaskSchedulerManagerAMContainerImplAllocate/launch a container
CONTAINER_LAUNCH_REQUESTAMContainerImplContainerLauncherManagerTell the NM to start the container process
N_CONTAINER_ALLOCATEDTaskSchedulerManagerAMNodeImpl (via tracker)Record a container on a node
C_LAUNCHEDContainerLauncherManagerAMContainerImplContainer process started
C_ASSIGN_TATaskSchedulerManagerAMContainerImplAssign this attempt to the (reused/new) container
TA_SUBMITTEDAMContainerImplTaskAttemptImplAttempt handed to a container
TA_STARTED_REMOTELYTaskCommunicatorManager (umbilical)TaskAttemptImplContainer reported the attempt running
TA_STATUS_UPDATETaskCommunicatorManager (umbilical)TaskAttemptImplProgress + counter heartbeat
S_TASK_ATTEMPT_STATUS_UPDATETaskAttemptImplSpeculatorFeed the speculator timing data
TA_DONETaskCommunicatorManager (umbilical)TaskAttemptImplTask reported success
C_TA_SUCCEEDEDTaskAttemptImplAMContainerImplFree the container for reuse
S_TA_ENDEDTaskAttemptImplTaskSchedulerManagerAttempt ended; release/reuse its container
N_TA_ENDED / N_TA_SUCCEEDEDTaskSchedulerManagerAMNodeImplUpdate per-node failure/success counts
T_ATTEMPT_SUCCEEDEDTaskAttemptImplTaskImplAn attempt succeeded
V_TASK_COMPLETEDTaskImplVertexImplA task of this vertex completed
V_SOURCE_TASK_ATTEMPT_COMPLETEDTaskAttemptImplVertexImpl (downstream)Source data now available to consumers
DAG_VERTEX_COMPLETEDVertexImplDAGImplA vertex reached terminal state
TA_OUTPUT_FAILEDconsumer TaskAttemptImpl (via InputReadErrorEvent)producer TaskAttemptImplA downstream task couldn't read this output
V_TASK_RESCHEDULEDVertexImplTaskImplRe-run a task whose output was lost
C_COMPLETEDTaskSchedulerManager (RM callback)AMContainerImplThe container exited
CONTAINER_STOP_REQUESTAMContainerImplContainerLauncherManagerTell the NM to stop an idle container
DAG_FINISHEDDAGImplDAGAppMasterDAG 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 the TaskCommunicatorManager on the AM's behalf, not raised by an AM state machine. When tracing, confirm the actual producer with a grep for 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/