}
@Override
public void scheduleTask(DAGEventSchedulerUpdate event) {
TaskAttempt attempt = event.getAttempt();
Vertex vertex = dag.getVertex(attempt.getVertexID());
int vertexDistanceFromRoot = vertex.getDistanceFromRoot();
LOG.info("Schedule task: " + attempt.getID());
if(currentPartitioner == null) {
// no partitioner. so set it.
currentPartitioner = vertex;
currentShufflerDepth = vertexDistanceFromRoot;
assert realPartitionerResource == null;
Resource partitionerResource = currentPartitioner.getTaskResource();
realPartitionerResource = Resource.newInstance(
partitionerResource.getMemory(),
partitionerResource.getVirtualCores());
LOG.info(vertex.getVertexId() + " is new partitioner at depth "
+ vertexDistanceFromRoot);
} else if (currentShuffler == null &&
vertexDistanceFromRoot > currentShufflerDepth) {
// vertex not a partitioner. no shuffler set. has more depth than current
// shuffler. this must be the new shuffler.
currentShuffler = vertex;
currentShufflerDepth = vertexDistanceFromRoot;
assert realShufflerResource == null;
Resource shufflerResource = currentShuffler.getTaskResource();
realShufflerResource = Resource.newInstance(
shufflerResource.getMemory(),
shufflerResource.getVirtualCores());
LOG.info(vertex.getVertexId() + " is new shuffler at depth "
+ currentShufflerDepth);
}
if(currentShuffler == vertex) {
pendingShuffleTasks.add(attempt);
unassignedShuffleTasks.add(attempt.getTaskID());
schedulePendingShuffles(getNumShufflesToSchedule());
return;
}
if(currentPartitioner == vertex) {
unassignedPartitionTasks.add(attempt.getTaskID());
}
// sanity check
// task should be a partitioner, a shuffler or a retry of an ancestor
if(currentPartitioner != vertex && currentShuffler != vertex &&
vertexDistanceFromRoot >= currentPartitioner.getDistanceFromRoot()) {
String message = vertex.getVertexId() + " is neither the "
+ " current partitioner: " + currentPartitioner.getVertexId()
+ " nor the current shuffler: " + currentShuffler.getVertexId();
LOG.fatal(message);
throw new TezUncheckedException(message);
}