use of org.apache.tez.dag.api.VertexManagerPluginContext.ScheduleTaskRequest 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);
}
}
use of org.apache.tez.dag.api.VertexManagerPluginContext.ScheduleTaskRequest in project tez by apache.
the class TestCartesianProductVertexManagerPartitioned method testOnVertexStartHelper.
private void testOnVertexStartHelper(boolean broadcastRunning) throws Exception {
vertexManager.onVertexStateUpdated(new VertexStateUpdate("v0", VertexState.CONFIGURED));
vertexManager.onVertexStateUpdated(new VertexStateUpdate("v1", VertexState.CONFIGURED));
if (broadcastRunning) {
vertexManager.onVertexStateUpdated(new VertexStateUpdate("v2", VertexState.RUNNING));
}
List<TaskAttemptIdentifier> completions = new ArrayList<>();
completions.add(allCompletions.get(0));
completions.add(allCompletions.get(1));
completions.add(allCompletions.get(4));
completions.add(allCompletions.get(8));
vertexManager.onVertexStarted(completions);
if (!broadcastRunning) {
verify(context, never()).scheduleTasks(Matchers.<List<ScheduleTaskRequest>>any());
vertexManager.onVertexStateUpdated(new VertexStateUpdate("v2", VertexState.RUNNING));
}
List<ScheduleTaskRequest> scheduleTaskRequests;
verify(context, times(1)).scheduleTasks(scheduleTaskRequestCaptor.capture());
scheduleTaskRequests = scheduleTaskRequestCaptor.getValue();
assertEquals(1, scheduleTaskRequests.size());
assertEquals(0, scheduleTaskRequests.get(0).getTaskIndex());
}
use of org.apache.tez.dag.api.VertexManagerPluginContext.ScheduleTaskRequest in project tez by apache.
the class TestFairCartesianProductVertexManager method verifyScheduleRequest.
private void verifyScheduleRequest(int expectedTimes, int... expectedTid) {
verify(ctx, times(expectedTimes)).scheduleTasks(scheduleRequestCaptor.capture());
if (expectedTimes > 0) {
List<ScheduleTaskRequest> requests = scheduleRequestCaptor.getValue();
int i = 0;
for (int tid : expectedTid) {
assertEquals(tid, requests.get(i).getTaskIndex());
i++;
}
}
}
Aggregations