use of org.apache.tez.dag.app.dag.event.TaskEventScheduleTask in project tez by apache.
the class VertexImpl method scheduleTasks.
@Override
public void scheduleTasks(List<ScheduleTaskRequest> tasksToSchedule) {
try {
unsetTasksNotYetScheduled();
// update state under write lock
writeLock.lock();
try {
for (ScheduleTaskRequest task : tasksToSchedule) {
if (numTasks <= task.getTaskIndex()) {
throw new TezUncheckedException("Invalid taskId: " + task.getTaskIndex() + " for vertex: " + logIdentifier);
}
TaskLocationHint locationHint = task.getTaskLocationHint();
if (locationHint != null) {
if (taskLocationHints == null) {
taskLocationHints = new TaskLocationHint[numTasks];
}
taskLocationHints[task.getTaskIndex()] = locationHint;
}
}
} finally {
writeLock.unlock();
}
/**
* read lock is not needed here. For e.g after starting task
* scheduling on the vertex, it would not change numTasks. Rest of
* the methods creating remote task specs have their
* own locking mechanisms. Ref: TEZ-3297
*/
for (ScheduleTaskRequest task : tasksToSchedule) {
TezTaskID taskId = TezTaskID.getInstance(vertexId, task.getTaskIndex());
TaskSpec baseTaskSpec = createRemoteTaskSpec(taskId.getId());
boolean fromRecovery = recoveryData == null ? false : recoveryData.getTaskRecoveryData(taskId) != null;
eventHandler.handle(new TaskEventScheduleTask(taskId, baseTaskSpec, getTaskLocationHint(taskId), fromRecovery));
}
} catch (AMUserCodeException e) {
String msg = "Exception in " + e.getSource() + ", vertex=" + getLogIdentifier();
LOG.error(msg, e);
// send event to fail the vertex
eventHandler.handle(new VertexEventManagerUserCodeError(getVertexId(), e));
// throw an unchecked exception to stop the vertex manager that invoked this.
throw new TezUncheckedException(e);
}
}
Aggregations