Skip to content

Conversation

@PetrGlad
Copy link
Contributor

@PetrGlad PetrGlad commented Nov 28, 2017

For context see #315

  • Correct working time calculation
  • Default to milliseconds in retry object internally, remove TimeUnit field.
  • Extract duplication code in test
  • Streamline retry builder error checking

Petr Gladkikh added 6 commits November 28, 2017 12:59
Default to milliseconds internally.
The behavior would be incorrect with any other time unit anyway:
due to multiple unit.toMillis(unit.toMillis(unit.toMillis(x)))
conversions.

Extract duplicating code in unit test.
NakadiException.throwNonNull throws IllegalStateException while
NakadiException is itself exception, also throwNonNull is a non
null check that is retrofitted to throw unconditionally.
This all is rather confusing.
return nextBackOffMillis(System.currentTimeMillis());
}

long nextBackOffMillis(long nowMillis) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracted for testing.

}

workingInterval = unit.toMillis(workingInterval) * (workingAttempts * workingAttempts);
workingInterval = workingInterval * (workingAttempts * workingAttempts);
Copy link
Contributor Author

@PetrGlad PetrGlad Nov 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still looks like too aggressive increase. workingInterval = startingInterval * pow(workingInterval, 2) would be OK (and easier to review).

exponentialRetry.nextBackOffMillis(100);
assertFalse(exponentialRetry.isFinished());
exponentialRetry.nextBackOffMillis(101);
assertFalse(exponentialRetry.isFinished());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would previously fail here as accumulated time was 202 milliseconds (instead of 101).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant