backOffTimeoutsInMilliseconds = new ExponentialBackOffTimesPolicy().getBackOffTimeoutsInMillis(); InternalLogger.INSTANCE.trace("No BackOffTimesContainer, using default values."); return; backOffTimeoutsInMilliseconds = new ExponentialBackOffTimesPolicy().getBackOffTimeoutsInMillis(); InternalLogger.INSTANCE.trace("BackOff timeouts are not supplied or not valid, using default values."); return;
/** * Create the {@link TransmissionPolicyManager} and set the ability to throttle. * @param throttlingIsEnabled Set whether the {@link TransmissionPolicyManager} can be throttled. */ public TransmissionPolicyManager(boolean throttlingIsEnabled) { suspensionDate = null; this.throttlingIsEnabled = throttlingIsEnabled; this.transmissionHandlers = new ArrayList<TransmissionHandler>(); this.backoffManager = new SenderThreadsBackOffManager(new ExponentialBackOffTimesPolicy()); }
public BackOffTimesPolicy create(String typeAsString) { BackOffPolicyType type = BackOffPolicyType.EXPONENTIAL; if (Strings.isNullOrEmpty(typeAsString)) { InternalLogger.INSTANCE.trace("No back-off container defined, using the default '%s'", type); } else { try { type = BackOffPolicyType.valueOf(typeAsString.toUpperCase()); } catch (Exception e) { InternalLogger.INSTANCE.error("Failed to parse '%s', using the default back-off container '%s'", typeAsString, type); } } switch (type) { case STATIC: return new StaticBackOffTimesPolicy(); default: return new ExponentialBackOffTimesPolicy(); } } }
@Test public void testBackOffs() { long[] backOffs = new ExponentialBackOffTimesPolicy().getBackOffTimeoutsInMillis(); assertNotNull(backOffs); assertTrue(backOffs.length % 2 == 1); int couples = backOffs.length / 2; long lastEventValue = BackOffTimesPolicy.MIN_TIME_TO_BACK_OFF_IN_MILLS; for (int i = 0; i < couples; ++i) { if (i % 2 == 0) { assertEquals(BackOffTimesPolicy.MIN_TIME_TO_BACK_OFF_IN_MILLS, backOffs[i]); } else { assertThat(lastEventValue, lessThan(backOffs[i])); lastEventValue = backOffs[i]; } } } }