DBZ-4902 Change for exponential strategy

This commit is contained in:
Jiri Pechanec 2022-06-27 14:26:07 +02:00
parent 1b17372d2d
commit 9ada2f28ce
3 changed files with 8 additions and 6 deletions

View File

@ -90,7 +90,7 @@ protected static enum State {
protected BaseSourceTask() {
// Use exponential delay to log the progress frequently at first, but the quickly tapering off to once an hour...
pollOutputDelay = ElapsedTimeStrategy.exponential(clock, INITIAL_POLL_PERIOD_IN_MILLIS , MAX_POLL_PERIOD_IN_MILLIS);
pollOutputDelay = ElapsedTimeStrategy.exponential(clock, INITIAL_POLL_PERIOD_IN_MILLIS, MAX_POLL_PERIOD_IN_MILLIS);
// Initial our poll output delay logic ...
pollOutputDelay.hasElapsed();

View File

@ -111,19 +111,21 @@ public boolean sleepWhen(boolean criteria) {
* @return the strategy; never null
*/
public static DelayStrategy exponential(Duration initialDelay, Duration maxDelay) {
return exponential(initialDelay.toMillis(), maxDelay.toMillis(), 2.0);
return exponential(initialDelay, maxDelay, 2.0);
}
/**
* Create a delay strategy that applies an exponentially-increasing delay as long as the criteria is met. As soon as
* the criteria is not met, the delay resets to zero.
*
* @param initialDelayInMilliseconds the initial delay; must be positive
* @param maxDelayInMilliseconds the maximum delay; must be greater than the initial delay
* @param initialDelay the initial delay; must be positive
* @param maxDelay the maximum delay; must be greater than the initial delay
* @param backOffMultiplier the factor by which the delay increases each pass
* @return the strategy
*/
public static DelayStrategy exponential(long initialDelayInMilliseconds, long maxDelayInMilliseconds, double backOffMultiplier) {
public static DelayStrategy exponential(Duration initialDelay, Duration maxDelay, double backOffMultiplier) {
final long initialDelayInMilliseconds = initialDelay.toMillis();
final long maxDelayInMilliseconds = maxDelay.toMillis();
if (backOffMultiplier <= 1.0) {
throw new IllegalArgumentException("Backup multiplier must be greater than 1");
}

View File

@ -442,4 +442,4 @@
</build>
</profile>
</profiles>
</project>
</project>