code: private void updateTotalTaskCapacity(TaskTrackerStatus status) {
      int mapSlots = taskScheduler.getMaxSlots(status, TaskType.MAP);
      String trackerName = status.getTrackerName();
      Integer oldMapSlots = trackerNameToMapSlots.get(trackerName);
      if (oldMapSlots == null) {
        oldMapSlots = 0;
      }
      int delta = mapSlots - oldMapSlots;
  
      if (delta != 0) {
        totalMapTaskCapacity += delta;
        trackerNameToMapSlots.put(trackerName, mapSlots);
  
        LOG.info("Changing map slot count due to " + trackerName + " from " +
                 oldMapSlots + " to " + mapSlots + ", totalMap = " + totalMapTaskCapacity);
      }
  
      int reduceSlots = taskScheduler.getMaxSlots(status, TaskType.REDUCE);
      Integer oldReduceSlots = trackerNameToReduceSlots.get(trackerName);
      if (oldReduceSlots == null) {
        oldReduceSlots = 0;
      }
  
      delta = reduceSlots - oldReduceSlots;
  
      if (delta != 0) {
        totalReduceTaskCapacity += delta;
        trackerNameToReduceSlots.put(trackerName, reduceSlots);
  
        LOG.info("Changing reduce slot count due to " + trackerName + " from " +
                 oldReduceSlots + " to " + reduceSlots +
                 ", totalReduce = " + totalReduceTaskCapacity);
      }
    }
docs: Update totalMapTaskCapacity and totalReduceTaskCapacity to resolve the
  number of slots changed in a tasktracker. The change could be from
  TaskScheduler or TaskTrackerStatus
  
  @param status The status of the tasktracker