public long backoffBeforeAvailableBootstrapServer(long currentTimeMs) {
        long minBackoffMs = retryBackoffMs;

        Iterator<ConnectionState> iterator = connections.values().iterator();
        while (iterator.hasNext()) {
            ConnectionState connection = iterator.next();
            if (connection.hasRequestTimedOut(currentTimeMs)) {
                // Mark the node as ready after request timeout
                iterator.remove();
            } else if (connection.isBackoffComplete(currentTimeMs)) {
                // Mark the node as ready after completed backoff
                iterator.remove();
            } else if (connection.hasInflightRequest(currentTimeMs)) {
                // There can be at most one inflight fetch request
                return connection.remainingRequestTimeMs(currentTimeMs);
            } else if (connection.isBackingOff(currentTimeMs)) {
                minBackoffMs = Math.min(minBackoffMs, connection.remainingBackoffMs(currentTimeMs));
            }
        }

        // There are no inflight fetch requests so check if there is a ready bootstrap server
        for (Node node : bootstrapServers) {
            if (isReady(node, currentTimeMs)) {
                return 0L;
            }
        }

        // There are no ready bootstrap servers and inflight fetch requests, return the backoff
        return minBackoffMs;
    }
Computes the amount of time needed to wait before a bootstrap server is ready for a Fetch
request.

If there is a connection with a pending request it returns the amount of time to wait until
the request times out.

Returns zero, if there are no pending requests and at least one of the bootstrap servers is
ready.

If all of the bootstrap servers are backing off and there are no pending requests, return
the minimum amount of time until a bootstrap server becomes ready.

@param currentTimeMs the current time
@return the amount of time to wait until bootstrap server can accept a Fetch request
raft/src/main/java/org/apache/kafka/raft/RequestManager.java