@Test public void testDelay() { TimingValues timingValues = new TimingValues(); int transientFailures = 0; int fatalFailures = 0; long delay = JRTConfigRequester.calculateFailedRequestDelay(ErrorType.TRANSIENT, transientFailures, fatalFailures, timingValues, true); assertThat(delay, is(timingValues.getConfiguredErrorDelay())); assertThat(delay, is((transientFailures + 1) * timingValues.getConfiguredErrorDelay())); }
static long calculateFailedRequestDelay(ErrorType errorCode, int transientFailures, int fatalFailures, TimingValues timingValues, boolean configured) { long delay; if (configured) delay = timingValues.getConfiguredErrorDelay(); else delay = timingValues.getUnconfiguredDelay(); if (errorCode == ErrorType.TRANSIENT) { delay = delay * Math.min((transientFailures + 1), timingValues.getMaxDelayMultiplier()); } else { delay = timingValues.getFixedDelay() + (delay * Math.min(fatalFailures, timingValues.getMaxDelayMultiplier())); delay = timingValues.getPlusMinusFractionRandom(delay, randomFraction); } return delay; }
JRTConfigRequester implements RequestWaiter { static long calculateFailedRequestDelay(ErrorType errorCode, int transientFailures, int fatalFailures, TimingValues timingValues, boolean configured) { long delay; if (configured) delay = timingValues.getConfiguredErrorDelay(); else delay = timingValues.getUnconfiguredDelay(); if (errorCode == ErrorType.TRANSIENT) { delay = delay * Math.min((transientFailures + 1), timingValues.getMaxDelayMultiplier()); } else { delay = timingValues.getFixedDelay() + (delay * Math.min(fatalFailures, timingValues.getMaxDelayMultiplier())); delay = timingValues.getPlusMinusFractionRandom(delay, randomFraction); } return delay; } }
JRTConfigRequester implements RequestWaiter { static long calculateFailedRequestDelay(ErrorType errorCode, int transientFailures, int fatalFailures, TimingValues timingValues, boolean configured) { long delay; if (configured) delay = timingValues.getConfiguredErrorDelay(); else delay = timingValues.getUnconfiguredDelay(); if (errorCode == ErrorType.TRANSIENT) { delay = delay * Math.min((transientFailures + 1), timingValues.getMaxDelayMultiplier()); } else { delay = timingValues.getFixedDelay() + (delay * Math.min(fatalFailures, timingValues.getMaxDelayMultiplier())); delay = timingValues.getPlusMinusFractionRandom(delay, randomFraction); } return delay; } JRTConfigRequester(ConfigSourceSet configSourceSet, ScheduledThreadPoolExecutor scheduler,
                       ConnectionPool connectionPool, TimingValues timingValues);  JRTConfigRequester(ConnectionPool connectionPool, TimingValues timingValues); }
JRTConfigRequester implements RequestWaiter { static long calculateFailedRequestDelay(ErrorType errorCode, int transientFailures, int fatalFailures, TimingValues timingValues, boolean configured) { long delay; if (configured) delay = timingValues.getConfiguredErrorDelay(); else delay = timingValues.getUnconfiguredDelay(); if (errorCode == ErrorType.TRANSIENT) { delay = delay * Math.min((transientFailures + 1), timingValues.getMaxDelayMultiplier()); } else { delay = timingValues.getFixedDelay() + (delay * Math.min(fatalFailures, timingValues.getMaxDelayMultiplier())); delay = timingValues.getPlusMinusFractionRandom(delay, randomFraction); } return delay; } JRTConfigRequester(ConfigSourceSet configSourceSet, ScheduledThreadPoolExecutor scheduler,
                       ConnectionPool connectionPool, TimingValues timingValues);  JRTConfigRequester(ConnectionPool connectionPool, TimingValues timingValues); static JRTConfigRequester create(ConfigSourceSet sourceSet, TimingValues timingValues); void request(JRTConfigSubscription<T> sub); @SuppressWarnings("unchecked") @Override void handleRequestDone(Request req); void close(); ConnectionPool getConnectionPool(); }
JRTConfigRequester implements RequestWaiter { static long calculateFailedRequestDelay(ErrorType errorCode, int transientFailures, int fatalFailures, TimingValues timingValues, boolean configured) { long delay; if (configured) delay = timingValues.getConfiguredErrorDelay(); else delay = timingValues.getUnconfiguredDelay(); if (errorCode == ErrorType.TRANSIENT) { delay = delay * Math.min((transientFailures + 1), timingValues.getMaxDelayMultiplier()); } else { delay = timingValues.getFixedDelay() + (delay * Math.min(fatalFailures, timingValues.getMaxDelayMultiplier())); delay = timingValues.getPlusMinusFractionRandom(delay, randomFraction); } return delay; } JRTConfigRequester(ConfigSourceSet configSourceSet, ScheduledThreadPoolExecutor scheduler,
                       ConnectionPool connectionPool, TimingValues timingValues);  JRTConfigRequester(ConnectionPool connectionPool, TimingValues timingValues); static JRTConfigRequester create(ConfigSourceSet sourceSet, TimingValues timingValues); void request(JRTConfigSubscription<T> sub); @SuppressWarnings("unchecked") @Override void handleRequestDone(Request req); void close(); ConnectionPool getConnectionPool(); static final ConfigSourceSet defaultSourceSet; }