private String constructPendingTaskCountsLogMessage() {
    StringBuilder sb = new StringBuilder();
    int totalCount = 0;
    sb.append("numPriorityLevels=").append(pendingTasks.size()).append(". ");
    Iterator<Entry<Priority, List<TaskInfo>>> pendingIterator =
        pendingTasks.entrySet().iterator();
    while (pendingIterator.hasNext()) {
      Entry<Priority, List<TaskInfo>> entry = pendingIterator.next();
      int count = entry.getValue() == null ? 0 : entry.getValue().size();
      sb.append("[p=").append(entry.getKey().toString()).append(",c=").append(count).append("]");
      totalCount += count;
    }
    int runningTasks = guaranteedTasks.values().stream().mapToInt(t -> t.size()).sum() +
        speculativeTasks.values().stream().mapToInt(t -> t.size()).sum();
    sb.append(". runningTasks=").append(runningTasks);
    sb.append(". totalPendingTasks=").append(totalCount);
    sb.append(". delayedTaskQueueSize=").append(delayedTaskQueue.size());
    sb.append(". highPriTaskQueueSize=").append(highPriorityTaskQueue.size());
    sb.append(". preemptTaskQueueSize=").append(preemptionCandidates.size());
    sb.append(". pendingPreemptions=").append(pendingPreemptions.get());
    return sb.toString();
  }
Should cycle when:
 1. There are available Resources OR
 2. There is a pending task with higher pri than running ones
@param availableHostMap
@return
llap-tez/src/java/org/apache/hadoop/hive/llap/tezplugins/LlapTaskSchedulerService.java