@Test public void delayOnIntermediateTry() { assertThat(calc.getExponentialDelayMillis(4, backupFlags)).isEqualTo(2100L); }
public long getExponentialDelayMillis(int attemptsLeft, BackupFlags backupFlags) { int maxWaitingTimeBtwUpload = backupFlags.getMaxWaitingTimeBtwUpload(); if (attemptsLeft < 1) { return backupFlags.getMinUploadDelay(); } if (attemptsLeft > backupFlags.getAttemptsAmount()) { return maxWaitingTimeBtwUpload; } long delay = (long) (backupFlags.getMinUploadDelay() + (Math.round(Math.pow(DELAY_CALCULATION_BASE, backupFlags.getAttemptsAmount() - attemptsLeft + 1)) - DELAY_CALCULATION_BASE) * MILS_MUL); return (delay >= maxWaitingTimeBtwUpload) ? maxWaitingTimeBtwUpload : delay; }
DelayCalculator { public long getExponentialDelayMillis(int attemptsLeft, BackupFlags backupFlags) { int maxWaitingTimeBtwUpload = backupFlags.getMaxWaitingTimeBtwUpload(); if (attemptsLeft < 1) { return backupFlags.getMinUploadDelay(); } if (attemptsLeft > backupFlags.getAttemptsAmount()) { return maxWaitingTimeBtwUpload; } long delay = (long) (backupFlags.getMinUploadDelay() + (Math.round(Math.pow(DELAY_CALCULATION_BASE, backupFlags.getAttemptsAmount() - attemptsLeft + 1)) - DELAY_CALCULATION_BASE) * MILS_MUL); return (delay >= maxWaitingTimeBtwUpload) ? maxWaitingTimeBtwUpload : delay; } }
DelayCalculator { public long getExponentialDelayMillis(int attemptsLeft, BackupFlags backupFlags) { int maxWaitingTimeBtwUpload = backupFlags.getMaxWaitingTimeBtwUpload(); if (attemptsLeft < 1) { return backupFlags.getMinUploadDelay(); } if (attemptsLeft > backupFlags.getAttemptsAmount()) { return maxWaitingTimeBtwUpload; } long delay = (long) (backupFlags.getMinUploadDelay() + (Math.round(Math.pow(DELAY_CALCULATION_BASE, backupFlags.getAttemptsAmount() - attemptsLeft + 1)) - DELAY_CALCULATION_BASE) * MILS_MUL); return (delay >= maxWaitingTimeBtwUpload) ? maxWaitingTimeBtwUpload : delay; }  }
DelayCalculator { public long getExponentialDelayMillis(int attemptsLeft, BackupFlags backupFlags) { int maxWaitingTimeBtwUpload = backupFlags.getMaxWaitingTimeBtwUpload(); if (attemptsLeft < 1) { return backupFlags.getMinUploadDelay(); } if (attemptsLeft > backupFlags.getAttemptsAmount()) { return maxWaitingTimeBtwUpload; } long delay = (long) (backupFlags.getMinUploadDelay() + (Math.round(Math.pow(DELAY_CALCULATION_BASE, backupFlags.getAttemptsAmount() - attemptsLeft + 1)) - DELAY_CALCULATION_BASE) * MILS_MUL); return (delay >= maxWaitingTimeBtwUpload) ? maxWaitingTimeBtwUpload : delay; }  long getExponentialDelayMillis(int attemptsLeft, BackupFlags backupFlags); }
DelayCalculator { public long getExponentialDelayMillis(int attemptsLeft, BackupFlags backupFlags) { int maxWaitingTimeBtwUpload = backupFlags.getMaxWaitingTimeBtwUpload(); if (attemptsLeft < 1) { return backupFlags.getMinUploadDelay(); } if (attemptsLeft > backupFlags.getAttemptsAmount()) { return maxWaitingTimeBtwUpload; } long delay = (long) (backupFlags.getMinUploadDelay() + (Math.round(Math.pow(DELAY_CALCULATION_BASE, backupFlags.getAttemptsAmount() - attemptsLeft + 1)) - DELAY_CALCULATION_BASE) * MILS_MUL); return (delay >= maxWaitingTimeBtwUpload) ? maxWaitingTimeBtwUpload : delay; }  long getExponentialDelayMillis(int attemptsLeft, BackupFlags backupFlags);  }