public void finished(TaskRunner runner) {
    if (statsTasks.isEmpty() || !(runner.getTask() instanceof MapRedTask)) {
      return;
    }
    MapRedTask mapredTask = (MapRedTask) runner.getTask();

    MapWork mapWork = mapredTask.getWork().getMapWork();
    ReduceWork reduceWork = mapredTask.getWork().getReduceWork();
    List<Operator> operators = new ArrayList<Operator>(mapWork.getAliasToWork().values());
    if (reduceWork != null) {
      operators.add(reduceWork.getReducer());
    }
    final List<String> statKeys = new ArrayList<String>(1);
    NodeUtils.iterate(operators, FileSinkOperator.class, new Function<FileSinkOperator>() {
      @Override
      public void apply(FileSinkOperator fsOp) {
        if (fsOp.getConf().isGatherStats()) {
          statKeys.add(fsOp.getConf().getStatsAggPrefix());
        }
      }
    });
    for (String statKey : statKeys) {
      if (statsTasks.containsKey(statKey)) {
        statsTasks.get(statKey).getWork().setSourceTask(mapredTask);
      } else {
        LOG.debug("There is no correspoing statTask for: " + statKey);
      }
    }
  }
Checks if a task can be launched.

@param tsk
         the task to be checked
@return true if the task is launchable, false otherwise
ql/src/java/org/apache/hadoop/hive/ql/TaskQueue.java