protected static class ScheduleTaskattemptTransition implements
SingleArcTransition<TaskAttemptImpl, TaskAttemptEvent> {
@Override
public void transition(TaskAttemptImpl ta, TaskAttemptEvent event) {
TaskAttemptEventSchedule scheduleEvent = (TaskAttemptEventSchedule) event;
// TODO Creating the remote task here may not be required in case of
// recovery.
// Create the remote task.
TaskSpec remoteTaskSpec = ta.createRemoteTaskSpec();
// Create startTaskRequest
String[] requestHosts = new String[0];
String[] requestRacks = new String[0];
// Compute node/rack location request even if re-scheduled.
Set<String> racks = new HashSet<String>();
if (ta.locationHint != null) {
if (ta.locationHint.getRacks() != null) {
racks.addAll(ta.locationHint.getRacks());
}
if (ta.locationHint.getDataLocalHosts() != null) {
for (String host : ta.locationHint.getDataLocalHosts()) {
racks.add(RackResolver.resolve(host).getNetworkLocation());
}
requestHosts = ta.resolveHosts(ta.locationHint.getDataLocalHosts()
.toArray(new String[ta.locationHint.getDataLocalHosts().size()]));
}
}
requestRacks = racks.toArray(new String[racks.size()]);
ta.taskHosts.addAll(Arrays.asList(requestHosts));
ta.taskRacks = racks;
// Ask for hosts / racks only if not a re-scheduled task.
if (ta.isRescheduled) {
requestHosts = new String[0];
requestRacks = new String[0];
}
if (LOG.isDebugEnabled()) {
LOG.debug("Asking for container launch with taskAttemptContext: "
+ remoteTaskSpec);
}
// Send out a launch request to the scheduler.
AMSchedulerEventTALaunchRequest launchRequestEvent = new AMSchedulerEventTALaunchRequest(
ta.attemptId, ta.taskResource, remoteTaskSpec, ta, requestHosts,
requestRacks, scheduleEvent.getPriority(), ta.containerContext);
ta.sendEvent(launchRequestEvent);
}