private Pair<Resource, Map<String, List<NodeInfo>>> getResourceAvailability() {
    int memory = 0;
    int vcores = 0;
    int numInstancesFound = 0;
    Map<String, List<NodeInfo>> availableHostMap;
    readLock.lock();
    try {
      // maintain insertion order (needed for Next slot in locality miss)
      availableHostMap = new LinkedHashMap<>(instanceToNodeMap.size());
      Collection<LlapServiceInstance> instances = consistentSplits ?
          // might also include Inactive instances
          activeInstances.getAllInstancesOrdered(true):
          // if consistent splits are NOT used we don't need the ordering as there will be no cache benefit anyways
          activeInstances.getAll();
      boolean foundSlot = false;
      for (LlapServiceInstance inst : instances) {
        NodeInfo nodeInfo = instanceToNodeMap.get(inst.getWorkerIdentity());
        if (nodeInfo != null) {
          List<NodeInfo> hostList = availableHostMap.get(nodeInfo.getHost());
          if (hostList == null) {
            hostList = new ArrayList<>();
            availableHostMap.put(nodeInfo.getHost(), hostList);
          }
          if (!(inst instanceof InactiveServiceInstance)) {
            Resource r = inst.getResource();
            memory += r.getMemory();
            vcores += r.getVirtualCores();
            numInstancesFound++;
            // Only add to List Nodes with available resources
            // Hosts, however, exist even for nodes that do not currently have resources
            if (nodeInfo.canAcceptTask()) {
              foundSlot = true;
              hostList.add(nodeInfo);
            }
          }
        } else {
          LOG.warn("Null NodeInfo when attempting to get available resources for " + inst.getWorkerIdentity());
        }
      }
      // isClusterCapacityFull will be set to false on every trySchedulingPendingTasks call
      // set it false here to bail out early when we know there are no resources available.
      if (!foundSlot) {
        isClusterCapacityFull.set(true);
      }
    } finally {
      readLock.unlock();
    }
    if (LOG.isDebugEnabled()) {
      LOG.debug("Available resources: numInstancesFound={}, totalMem={}, totalVcores={} availableHosts: {}",
          numInstancesFound, memory, vcores, availableHostMap.size());
    }
    return new ImmutablePair<>(Resource.newInstance(memory, vcores), availableHostMap);
  }
Updates relevant structures on the node, and fixes the position in the disabledNodeQueue
to facilitate the actual re-enablement of the node.
@param nodeInfo  the node to be re-enabled
llap-tez/src/java/org/apache/hadoop/hive/llap/tezplugins/LlapTaskSchedulerService.java