code: static private DatanodeInfo bestNode(DatanodeInfo nodes[],
                                 ConcurrentHashMap<DatanodeInfo, Long> deadNodes,
                                 Collection<DatanodeInfo> unfavoredNodes,
                                 Collection<DatanodeInfo> ignoredNodes)
                                  throws IOException {
      InjectionHandler.processEventIO(InjectionEvent.DFSCLIENT_BEFORE_BEST_NODE,
          nodes, deadNodes);
      
      if (nodes != null) {
        // First try to find a node which is not included in favored ndoe list
        for (int i = 0; i < nodes.length; i++) {
          if (!deadNodes.containsKey(nodes[i])
              && (unfavoredNodes == null || !unfavoredNodes.contains(nodes[i]))
              && (ignoredNodes == null || !ignoredNodes.contains(nodes[i]))) {
              return nodes[i];
          }
        }
  
        // All live nodes are un-favored. Ignore the unfavor setting
        for (int i = 0; i < nodes.length; i++) {
          if (!deadNodes.containsKey(nodes[i])
              && (ignoredNodes == null || !ignoredNodes.contains(nodes[i]))) {
              return nodes[i];
          }
        }
      }
      return null;
    }
docs: Pick the best node from which to stream the data.
  Entries in <i>nodes</i> are already in the priority order