@Override
    public long nextTimeoutMS(int answeredNodes) {
        if (askedNodes == answeredNodes) return query.getTimeLeft();  // All nodes have responded - done
        if (answeredNodes < minimumResponses) return query.getTimeLeft(); // Minimum responses have not been received yet

        if (!adaptiveTimeoutCalculated) {
            // Recompute timeout when minimum responses have been received
            long timeLeftMs = query.getTimeLeft();
            adaptiveTimeoutMin = (long) (timeLeftMs * config.minWaitAfterCoverageFactor());
            adaptiveTimeoutMax = (long) (timeLeftMs * config.maxWaitAfterCoverageFactor());
            adaptiveTimeoutCalculated = true;
        }
        long now = timer.milliTime();
        int pendingQueries = askedNodes - answeredNodes;
        double missWidth = ((100.0 - minimumCoverage) * askedNodes) / 100.0 - 1.0;
        double slopedWait = adaptiveTimeoutMin;
        if (pendingQueries > 1 && missWidth > 0.0) {
            slopedWait += ((adaptiveTimeoutMax - adaptiveTimeoutMin) * (pendingQueries - 1)) / missWidth;
        }
        long nextAdaptive = (long) slopedWait;
        if (nextAdaptive >= deadline - now) {
            return deadline - now;
        }
        deadline = now + nextAdaptive;

        return nextAdaptive;
    }
Computes next timeout based on how many responses has been received so far

@author baldersheim
container-search/src/main/java/com/yahoo/search/dispatch/AdaptiveTimeoutHandler.java