microsoft-azure-storage/src/com/microsoft/azure/storage/RetryPolicy.java
protected RetryInfo evaluateRetryInfo(final RetryContext retryContext, final boolean secondaryNotFound,
            final long retryInterval) {
        RetryInfo retryInfo = new RetryInfo(retryContext);

        // Moreover, in case of 404 when trying the secondary location, instead of retrying on the
        // secondary, further requests should be sent only to the primary location, as it most
        // probably has a higher chance of succeeding there.
        if (secondaryNotFound && (retryContext.getLocationMode() != LocationMode.SECONDARY_ONLY)) {
            retryInfo.setUpdatedLocationMode(LocationMode.PRIMARY_ONLY);
            retryInfo.setTargetLocation(StorageLocation.PRIMARY);
        }

        // Now is the time to calculate the exact retry interval. ShouldRetry call above already
        // returned back how long two requests to the same location should be apart from each other.
        // However, for the reasons explained above, the time spent between the last attempt to
        // the target location and current time must be subtracted from the total retry interval
        // that ShouldRetry returned.
        Date lastAttemptTime = retryInfo.getTargetLocation() == StorageLocation.PRIMARY ? this.lastPrimaryAttempt
                : this.lastSecondaryAttempt;
        if (lastAttemptTime != null) {
            long sinceLastAttempt = (new Date().getTime() - lastAttemptTime.getTime() > 0) ? new Date().getTime()
                    - lastAttemptTime.getTime() : 0;
            retryInfo.setRetryInterval((int) (retryInterval - sinceLastAttempt));
        }
        else {
            retryInfo.setRetryInterval(0);
        }

        return retryInfo;
    }
protected RetryInfo evaluateRetryInfo(final RetryContext retryContext, final boolean secondaryNotFound,
            final long retryInterval) {
        RetryInfo retryInfo = new RetryInfo(retryContext);

        // Moreover, in case of 404 when trying the secondary location, instead of retrying on the
        // secondary, further requests should be sent only to the primary location, as it most
        // probably has a higher chance of succeeding there.
        if (secondaryNotFound && (retryContext.getLocationMode() != LocationMode.SECONDARY_ONLY)) {
            retryInfo.setUpdatedLocationMode(LocationMode.PRIMARY_ONLY);
            retryInfo.setTargetLocation(StorageLocation.PRIMARY);
        }

        // Now is the time to calculate the exact retry interval. ShouldRetry call above already
        // returned back how long two requests to the same location should be apart from each other.
        // However, for the reasons explained above, the time spent between the last attempt to
        // the target location and current time must be subtracted from the total retry interval
        // that ShouldRetry returned.
        Date lastAttemptTime = retryInfo.getTargetLocation() == StorageLocation.PRIMARY ? this.lastPrimaryAttempt
                : this.lastSecondaryAttempt;
        if (lastAttemptTime != null) {
            long sinceLastAttempt = (new Date().getTime() - lastAttemptTime.getTime() > 0) ? new Date().getTime()
                    - lastAttemptTime.getTime() : 0;
            retryInfo.setRetryInterval((int) (retryInterval - sinceLastAttempt));
        }
        else {
            retryInfo.setRetryInterval(0);
        }

        return retryInfo;
    }
Determines the {@link RetryInfo} object that indicates whether the next retry will happen in the primary or
secondary location, and specifies the location mode.

@param retryContext
A {@link RetryContext} object that indicates the number of retries, last request's results, whether
the next retry should happen in the primary or secondary location, and specifies the location mode.

@param secondaryNotFound
A <code>boolean</code> representing whether a request sent to the secondary location failed with 404
(Not Found)
@param retryInterval
Backoff Interval.
@return
A reference to the {@link RetryInfo} object that indicates whether the next retry will happen in the
primary or secondary location, and specifies the location mode.