code: protected LocalityLevel getAllowedLocalityLevel(JobInProgress job,
        long currentTime) {
      JobInfo info = infos.get(job);
      if (info == null) { // Job not in infos (shouldn't happen)
        LOG.error("getAllowedLocalityLevel called on job " + job
            + ", which does not have a JobInfo in infos");
        return LocalityLevel.ANY;
      }
      if (job.nonLocalMaps.size() > 0) { // Job doesn't have locality information
        return LocalityLevel.ANY;
      }
      // In the common case, compute locality level based on time waited
      switch(info.lastMapLocalityLevel) {
      case NODE: // Last task launched was node-local
        if (info.timeWaitedForLocalMap >=
            (localityDelayNodeLocal + localityDelayRackLocal))
          return LocalityLevel.ANY;
        else if (info.timeWaitedForLocalMap >= localityDelayNodeLocal)
          return LocalityLevel.RACK;
        else
          return LocalityLevel.NODE;
      case RACK: // Last task launched was rack-local
        if (info.timeWaitedForLocalMap >= localityDelayRackLocal)
          return LocalityLevel.ANY;
        else
          return LocalityLevel.RACK;
      default: // Last task was non-local; can launch anywhere
        return LocalityLevel.ANY;
      }
    }
docs: Get the maximum locality level at which a given job is allowed to
  launch tasks, based on how long it has been waiting for local tasks.
  This is used to implement the "delay scheduling" feature of the Fair
  Scheduler for optimizing data locality.
  If the job has no locality information (e.g. it does not use HDFS), this
  method returns LocalityLevel.ANY, allowing tasks at any level.
  Otherwise, the job can only launch tasks at its current locality level
  or lower, unless it has waited at least localityDelayNodeLocal or
  localityDelayRackLocal milliseconds depends on the current level. If it
  has waited (localityDelayNodeLocal + localityDelayRackLocal) milliseconds,
  it can go to any level.