private List < SimulatorEvent > handleSimulatorLaunchTaskAction ( SimulatorLaunchTaskAction action , long now ) { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Handling launch task action " + action ) ; } // First, create statuses and update used slots for map and reduce // task separately Task task = action . getTask ( ) ; TaskAttemptID taskId = task . getTaskID ( ) ; if ( tasks . containsKey ( taskId ) ) { throw new IllegalArgumentException ( "Multiple launch of task id =" + taskId ) ; } // Ctor of MapTaskStatus and ReduceTaskStatus need deprecated // o.a.h.mapred.TaskAttemptID, hence the downgrade org . apache . hadoop . mapred . TaskAttemptID taskIdOldApi = org . apache . hadoop . mapred . TaskAttemptID . downgrade ( taskId ) ; TaskStatus status ; int numSlotsRequired = task . getNumSlotsRequired ( ) ; Counters emptyCounters = new Counters ( ) ; if ( task . isMapTask ( ) ) { status = new MapTaskStatus ( taskIdOldApi , 0f , numSlotsRequired , State . RUNNING , "" , "" , taskTrackerName , Phase . MAP , emptyCounters ) ; usedMapSlots += numSlotsRequired ; if ( usedMapSlots > maxMapSlots ) { throw new IllegalStateException ( "usedMapSlots exceeds maxMapSlots: " + usedMapSlots + " > " + maxMapSlots ) ; } } else { status = new ReduceTaskStatus ( taskIdOldApi , 0f , numSlotsRequired , State . RUNNING , "" , "" , taskTrackerName , Phase . SHUFFLE , emptyCounters ) ; usedReduceSlots += numSlotsRequired ; if ( usedReduceSlots > maxReduceSlots ) { throw new IllegalStateException ( "usedReduceSlots exceeds usedReduceSlots: " + usedReduceSlots + " > " + usedReduceSlots ) ; } } // Second, create and store a TIP status . setStartTime ( now ) ; SimulatorTaskInProgress tip = new SimulatorTaskInProgress ( action , status , now ) ; tasks . put ( taskId , tip ) ; // Third, schedule events for ourselves if ( task . isMapTask ( ) ) { // we know when this task attempts ends iff it is a map TaskAttemptCompletionEvent e = createTaskAttemptCompletionEvent ( tip , now ) ; return Collections . < SimulatorEvent > singletonList ( e ) ; } else { // reduce, completion time can only be determined when all maps are done return SimulatorEngine . EMPTY_EVENTS ; } }
Launches a task on the simulated task tracker .