code: protected void refreshTaskCountsAndWaitTime(TaskType type, long now) {
      TaskInProgress[] allTips = getTasks(type);
      int finishedTips = 0;
      int runningTips = 0;
      int runningTaskAttempts = 0;
      long totalWaitTime = 0;
      long jobStartTime = this.getStartTime();
      for (TaskInProgress tip : allTips) {
        if (tip.isComplete()) {
          finishedTips += 1;
        } else if(tip.isRunning()) {
          runningTaskAttempts += tip.getActiveTasks().size();
          runningTips += 1;
        }
        if (tip.getExecStartTime() > 0) {
          totalWaitTime += tip.getExecStartTime() - jobStartTime;
        } else {
          totalWaitTime += now - jobStartTime;
        }
      }
      if (TaskType.MAP == type) {
        totalMapWaitTime = totalWaitTime;
        runningMapTasks = runningTaskAttempts;
        neededMapTasks = numMapTasks - runningTips - finishedTips
            + neededSpeculativeMaps();
        pendingMapTasks = numMapTasks - runningTaskAttempts
            - failedMapTIPs - finishedMapTasks + speculativeMapTasks;
      } else {
        totalReduceWaitTime = totalWaitTime;
        runningReduceTasks = runningTaskAttempts;
        neededReduceTasks = numReduceTasks - runningTips - finishedTips
            + neededSpeculativeReduces();
        pendingReduceTasks = numReduceTasks - runningTaskAttempts
            - failedReduceTIPs - finishedReduceTasks + speculativeReduceTasks;
      }
    }
docs: Refresh runningTasks, neededTasks and pendingTasks counters
  @param type TaskType to refresh