public class Execution extends Object
ExecutionVertex can be executed multiple times (for recovery,
or other re-computation), this class tracks the state of a single execution of that vertex and the resources.
NOTE ABOUT THE DESIGN RATIONAL:
In several points of the code, we need to deal with possible concurrent state changes and actions.
For example, while the call to deploy a task (send it to the TaskManager) happens, the task gets cancelled.
We could lock the entire portion of the code (decision to deploy, deploy, set state to running) such that
it is guaranteed that any "cancel command" will only pick up after deployment is done and that the "cancel
command" call will never overtake the deploying call.
This blocks the threads big time, because the remote calls may take long. Depending of their locking behavior, it
may even result in distributed deadlocks (unless carefully avoided). We therefore use atomic state updates and
occasional double-checking to ensure that the state after a completed call is as expected, and trigger correcting
actions if it is not. Many actions are also idempotent (like canceling).| Constructor and Description |
|---|
Execution(ExecutionVertex vertex,
int attemptNumber,
long startTimestamp) |
| Modifier and Type | Method and Description |
|---|---|
void |
cancel() |
void |
deployToSlot(AllocatedSlot slot) |
void |
fail(Throwable t)
This method fails the vertex due to an external condition.
|
AllocatedSlot |
getAssignedResource() |
ExecutionAttemptID |
getAttemptId() |
int |
getAttemptNumber() |
Throwable |
getFailureCause() |
ExecutionState |
getState() |
long |
getStateTimestamp(ExecutionState state) |
long[] |
getStateTimestamps() |
ExecutionVertex |
getVertex() |
String |
getVertexWithAttempt() |
boolean |
isFinished() |
void |
scheduleForExecution(Scheduler scheduler,
boolean queued)
NOTE: This method only throws exceptions if it is in an illegal state to be scheduled, or if the tasks needs
to be scheduled immediately and no resource is available.
|
String |
toString() |
public Execution(ExecutionVertex vertex, int attemptNumber, long startTimestamp)
public ExecutionVertex getVertex()
public ExecutionAttemptID getAttemptId()
public int getAttemptNumber()
public ExecutionState getState()
public AllocatedSlot getAssignedResource()
public Throwable getFailureCause()
public long[] getStateTimestamps()
public long getStateTimestamp(ExecutionState state)
public boolean isFinished()
public void scheduleForExecution(Scheduler scheduler, boolean queued) throws NoResourceAvailableException
scheduler - IllegalStateException - Thrown, if the vertex is not in CREATED state, which is the only state that permits scheduling.NoResourceAvailableException - Thrown is no queued scheduling is allowed and no resources are currently available.public void deployToSlot(AllocatedSlot slot) throws JobException
JobExceptionpublic void cancel()
public void fail(Throwable t)
t - The exception that caused the task to fail.public String getVertexWithAttempt()
Copyright © 2015 The Apache Software Foundation. All rights reserved.