class NetworkClient implements KafkaClient {

    @Override
    public Node leastLoadedNode(long now) {
        // 从metadataUpdater获取所有节点
        List<Node> nodes = this.metadataUpdater.fetchNodes();
        int inflight = Integer.MAX_VALUE;
        Node found = null;

        int offset = this.randOffset.nextInt(nodes.size());
        for (int i = 0; i < nodes.size(); i++) {
            int idx = (offset + i) % nodes.size();
            Node node = nodes.get(idx);
            int currInflight = this.inFlightRequests.inFlightRequestCount(node.idString());
            if (currInflight == 0 && this.connectionStates.isConnected(node.idString())) {// 如果发现一个inFlight == 0的，并保持连接的
                // if we find an established connection with no in-flight requests we can stop right away
                return node;
            } else if (!this.connectionStates.isBlackedOut(node.idString(), now) && currInflight < inflight) {
                // otherwise if this is the best we have found so far, record that
                inflight = currInflight;
                found = node;
            }
        }

        return found;
    }

    public  NetworkClient(Selectable selector,
        Metadata metadata,
        String clientId,
        int maxInFlightRequestsPerConnection,
        long reconnectBackoffMs,
        int socketSendBuffer,
        int socketReceiveBuffer,
        int requestTimeoutMs,
        Time time);
    public  NetworkClient(Selectable selector,
        MetadataUpdater metadataUpdater,
        String clientId,
        int maxInFlightRequestsPerConnection,
        long reconnectBackoffMs,
        int socketSendBuffer,
        int socketReceiveBuffer,
        int requestTimeoutMs,
        Time time);
    private  NetworkClient(MetadataUpdater metadataUpdater,
        Metadata metadata,
        Selectable selector,
        String clientId,
        int maxInFlightRequestsPerConnection,
        long reconnectBackoffMs,
        int socketSendBuffer,
        int socketReceiveBuffer,
        int requestTimeoutMs,
        Time time);

}