code: public ClusterNode getRunnableNode(String host, LocalityLevel maxLevel,
        ResourceType type, Set<String> excluded) {
      if (host == null) {
        RunnableIndices r = typeToIndices.get(type);
        return r.getRunnableNodeForAny(excluded);
      }
      RequestedNode node = resolve(host, type);
      return getRunnableNode(node, maxLevel, type, excluded);
    }
docs: Find the best matching node for this host subject to the maxLevel
  constraint
  @param host the host of the request
  @param maxLevel the max locality level to consider
  @param type the type of resource needed on the node
  @param excluded the list of nodes to exclude from consideration
  @return the runnable node satisfying the constraints