public boolean shouldRetry()

in src/main/java/com/microsoft/azure/datalake/store/retrypolicies/ExponentialBackoffPolicyforMSI.java [42:83]


    public boolean shouldRetry(int httpResponseCode, Exception lastException) {

        // Non-retryable error
        if (      (httpResponseCode >= 300 && httpResponseCode < 500   // 3xx and 4xx, except specific ones below
                                           && httpResponseCode != 404  // 404 is required for MSI; for some error conditions
                                                                       // they return a 404 that goes away on retry
                                           && httpResponseCode != 408
                                           && httpResponseCode != 429
                                           && httpResponseCode != 401)
               || (httpResponseCode == 501) // Not Implemented
               || (httpResponseCode == 505) // Version Not Supported
               ) {
            return false;
        }

        // Retryable error, retry with exponential backoff
        if ( lastException!=null || httpResponseCode >=500    // exception or 5xx, + specific ones below
                                 || httpResponseCode == 404   // see comment above for 404
                                 || httpResponseCode == 408
                                 || httpResponseCode == 429
                                 || httpResponseCode == 401) {
            if (retryCount < maxRetries) {
                int timeSpent = (int)((System.nanoTime() - lastAttemptStartTime) / 1000000);
                wait(exponentialRetryInterval - timeSpent);
                exponentialRetryInterval *= exponentialFactor;
                retryCount++;
                lastAttemptStartTime = System.nanoTime();
                return true;
            } else {
                return false;  // max # of retries exhausted
            }
        }

        // these are not errors - this method should never have been called with this
        if (httpResponseCode >= 100 && httpResponseCode <300)
        {
            return false;
        }

        // Dont know what happened - we should never get here
        return false;
    }