Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry cleanups #318

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

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.

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.


if (isFinished()) {
return STOP;
}

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