code: int getLocalityLevel(TaskInProgress tip, TaskTrackerStatus tts) {
      Node tracker = jobtracker.getNode(tts.getHost());
      int level = this.maxLevel;
      // find the right level across split locations
      for (String local : maps[tip.getIdWithinJob()].getSplitLocations()) {
        Node datanode = jobtracker.getNode(local);
        int newLevel = this.maxLevel;
        if (tracker != null && datanode != null) {
          newLevel = getMatchingLevelForNodes(tracker, datanode);
        }
        if (newLevel < level) {
          level = newLevel;
          // an optimization
          if (level == 0) {
            break;
          }
        }
      }
      return level;
    }
docs: Get the level of locality that a given task would have if launched on
  a particular TaskTracker. Returns 0 if the task has data on that machine,
  1 if it has data on the same rack, etc (depending on number of levels in
  the network hierarchy).