RetryController extends ComponentSupport { public ExceptionFilter majorExceptionFilter() { return majorExceptionFilter; } 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; }
@Test public void testMajorFilter() throws Exception { verifyBackoff(0, TEST_CAUSE, 0, 10); verifyBackoff(1, TEST_CAUSE, 0, 30); verifyBackoff(2, TEST_CAUSE, 0, 70); verifyBackoff(3, TEST_CAUSE, 0, 150); verifyBackoff(4, TEST_CAUSE, 0, 310); verifyBackoff(5, TEST_CAUSE, 0, 630); verifyBackoff(6, TEST_CAUSE, 0, 1270); verifyBackoff(7, TEST_CAUSE, 0, 2550); underTest.majorExceptionFilter().addException(TestException.class); verifyBackoff(0, TEST_CAUSE, 100, 200); verifyBackoff(1, TEST_CAUSE, 100, 400); verifyBackoff(2, TEST_CAUSE, 100, 800); verifyBackoff(3, TEST_CAUSE, 100, 1600); verifyBackoff(4, TEST_CAUSE, 100, 3200); verifyBackoff(5, TEST_CAUSE, 100, 6400); verifyBackoff(6, TEST_CAUSE, 100, 12800); verifyBackoff(7, TEST_CAUSE, 100, 25600); underTest.majorExceptionFilter().removeException(TestException.class); verifyBackoff(0, TEST_CAUSE, 0, 10); verifyBackoff(1, TEST_CAUSE, 0, 30); verifyBackoff(2, TEST_CAUSE, 0, 70); verifyBackoff(3, TEST_CAUSE, 0, 150); verifyBackoff(4, TEST_CAUSE, 0, 310); verifyBackoff(5, TEST_CAUSE, 0, 630); verifyBackoff(6, TEST_CAUSE, 0, 1270); verifyBackoff(7, TEST_CAUSE, 0, 2550); }