private boolean shouldCycle(Map<String, List<NodeInfo>> availableHostMap) {
    // short-circuit on resource availability
    int nodeCnt = 0;
    for (List<NodeInfo> nodes : availableHostMap.values()) {
      nodeCnt += nodes.size();
    }
    if (nodeCnt > 0) return true;
    // check if pending Pri is lower than existing tasks pri
    int specMax = speculativeTasks.isEmpty() ? Integer.MIN_VALUE : speculativeTasks.lastKey();
    int guarMax = guaranteedTasks.isEmpty() ? Integer.MIN_VALUE : guaranteedTasks.lastKey();
    return pendingTasks.firstKey().getPriority() < Math.max(specMax, guarMax);
  }
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