@Test public void testNoBackoffWhenRetryLimitExceeded() throws Exception { assertThat(underTest.allowRetry(8, MINOR_CAUSE), is(false)); assertThat(backoffCaptor.getAllValues(), is(empty())); }
public boolean allowRetry(final int retriesSoFar, final Exception cause) { int nextRetry = retriesSoFar + 1; if (nextRetry > retryLimit) { if (log.isTraceEnabled()) { log.warn("Exceeded retry limit: {}/{}", retriesSoFar, retryLimit, cause); } else { log.warn("Exceeded retry limit: {}/{} ({})", retriesSoFar, retryLimit, cause.toString()); } return false; } if (nextRetry == excessiveRetriesThreshold && !noisyExceptionFilter.test(cause)) { excessiveRetriesHourlyStats.mark(); } long delay = randomDelay(nextRetry, cause); if (log.isTraceEnabled()) { log.debug("Allowing retry: {}/{} in {}ms", nextRetry, retryLimit, delay, cause); } else { log.debug("Allowing retry: {}/{} in {}ms ({})", nextRetry, retryLimit, delay, cause.toString()); } backoff(delay); return true; }
RetryController extends ComponentSupport { public boolean allowRetry(final int retriesSoFar, final Exception cause) { int nextRetry = retriesSoFar + 1; if (nextRetry > retryLimit) { if (log.isTraceEnabled()) { log.warn("Exceeded retry limit: {}/{}", retriesSoFar, retryLimit, cause); } else { log.warn("Exceeded retry limit: {}/{} ({})", retriesSoFar, retryLimit, cause.toString()); } return false; } if (nextRetry == excessiveRetriesThreshold && !noisyExceptionFilter.test(cause)) { excessiveRetriesHourlyStats.mark(); } long delay = randomDelay(nextRetry, cause); if (log.isTraceEnabled()) { log.debug("Allowing retry: {}/{} in {}ms", nextRetry, retryLimit, delay, cause); } else { log.debug("Allowing retry: {}/{} in {}ms ({})", nextRetry, retryLimit, delay, cause.toString()); } backoff(delay); return true; } }
RetryController extends ComponentSupport { public boolean allowRetry(final int retriesSoFar, final Exception cause) { int nextRetry = retriesSoFar + 1; if (nextRetry > retryLimit) { if (log.isTraceEnabled()) { log.warn("Exceeded retry limit: {}/{}", retriesSoFar, retryLimit, cause); } else { log.warn("Exceeded retry limit: {}/{} ({})", retriesSoFar, retryLimit, cause.toString()); } return false; } if (nextRetry == excessiveRetriesThreshold && !noisyExceptionFilter.test(cause)) { excessiveRetriesHourlyStats.mark(); } long delay = randomDelay(nextRetry, cause); if (log.isTraceEnabled()) { log.debug("Allowing retry: {}/{} in {}ms", nextRetry, retryLimit, delay, cause); } else { log.debug("Allowing retry: {}/{} in {}ms ({})", nextRetry, retryLimit, delay, cause.toString()); } backoff(delay); return true; } RetryController(); }
RetryController extends ComponentSupport { public boolean allowRetry(final int retriesSoFar, final Exception cause) { int nextRetry = retriesSoFar + 1; if (nextRetry > retryLimit) { if (log.isTraceEnabled()) { log.warn("Exceeded retry limit: {}/{}", retriesSoFar, retryLimit, cause); } else { log.warn("Exceeded retry limit: {}/{} ({})", retriesSoFar, retryLimit, cause.toString()); } return false; } if (nextRetry == excessiveRetriesThreshold && !noisyExceptionFilter.test(cause)) { excessiveRetriesHourlyStats.mark(); } long delay = randomDelay(nextRetry, cause); if (log.isTraceEnabled()) { log.debug("Allowing retry: {}/{} in {}ms", nextRetry, retryLimit, delay, cause); } else { log.debug("Allowing retry: {}/{} in {}ms ({})", nextRetry, retryLimit, delay, cause.toString()); } backoff(delay); return true; } RetryController(); int getRetryLimit(); void setRetryLimit(final int retryLimit); int getMinSlots(); void setMinSlots(final int minSlots); int getMaxSlots(); void setMaxSlots(final int maxSlots); int getMinorDelayMillis(); void setMinorDelayMillis(final int minorDelayMillis); int getMajorDelayMillis(); void setMajorDelayMillis(final int majorDelayMillis); ExceptionFilter majorExceptionFilter(); ExceptionFilter noisyExceptionFilter(); boolean allowRetry(final int retriesSoFar, final Exception cause); long excessiveRetriesInLastHour(); }
RetryController extends ComponentSupport { public boolean allowRetry(final int retriesSoFar, final Exception cause) { int nextRetry = retriesSoFar + 1; if (nextRetry > retryLimit) { if (log.isTraceEnabled()) { log.warn("Exceeded retry limit: {}/{}", retriesSoFar, retryLimit, cause); } else { log.warn("Exceeded retry limit: {}/{} ({})", retriesSoFar, retryLimit, cause.toString()); } return false; } if (nextRetry == excessiveRetriesThreshold && !noisyExceptionFilter.test(cause)) { excessiveRetriesHourlyStats.mark(); } long delay = randomDelay(nextRetry, cause); if (log.isTraceEnabled()) { log.debug("Allowing retry: {}/{} in {}ms", nextRetry, retryLimit, delay, cause); } else { log.debug("Allowing retry: {}/{} in {}ms ({})", nextRetry, retryLimit, delay, cause.toString()); } backoff(delay); return true; } RetryController(); int getRetryLimit(); void setRetryLimit(final int retryLimit); int getMinSlots(); void setMinSlots(final int minSlots); int getMaxSlots(); void setMaxSlots(final int maxSlots); int getMinorDelayMillis(); void setMinorDelayMillis(final int minorDelayMillis); int getMajorDelayMillis(); void setMajorDelayMillis(final int majorDelayMillis); ExceptionFilter majorExceptionFilter(); ExceptionFilter noisyExceptionFilter(); boolean allowRetry(final int retriesSoFar, final Exception cause); long excessiveRetriesInLastHour(); static final RetryController INSTANCE; }