Exemplo n.º 1
0
 public int compare(JobInProgress j1, JobInProgress j2) {
   // Put needy jobs ahead of non-needy jobs (where needy means must receive
   // new tasks to meet slot minimum), comparing among jobs of the same type
   // by deficit so as to put jobs with higher deficit ahead.
   JobInfo j1Info = infos.get(j1);
   JobInfo j2Info = infos.get(j2);
   long deficitDif;
   boolean j1Needy, j2Needy;
   if (taskType == TaskType.MAP) {
     j1Needy = j1.runningMaps() < Math.floor(j1Info.minMaps);
     j2Needy = j2.runningMaps() < Math.floor(j2Info.minMaps);
     deficitDif = j2Info.mapDeficit - j1Info.mapDeficit;
   } else {
     j1Needy = j1.runningReduces() < Math.floor(j1Info.minReduces);
     j2Needy = j2.runningReduces() < Math.floor(j2Info.minReduces);
     deficitDif = j2Info.reduceDeficit - j1Info.reduceDeficit;
   }
   if (j1Needy && !j2Needy) return -1;
   else if (j2Needy && !j1Needy) return 1;
   else // Both needy or both non-needy; compare by deficit
   return (int) Math.signum(deficitDif);
 }
Exemplo n.º 2
0
 @Override
 public int getRunningTasks() {
   return taskType == TaskType.MAP ? job.runningMaps() : job.runningReduces();
 }