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

Implementation of Redlock #271

Merged
merged 1 commit into from
Aug 5, 2019
Merged

Implementation of Redlock #271

merged 1 commit into from
Aug 5, 2019

Conversation

rsrinivasanNetflix
Copy link
Contributor

Implementing redlock in Dyno.

Will add more tests. Starting PR to get some feedback to iterate.

Copy link
Contributor

@smukil smukil left a comment

Choose a reason for hiding this comment

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

Thanks for doing this. It looks good. Some minor code changes and comment requests.

Will have a second pass after the first round is addressed.

List<String> racks = numHostsPerRack.keySet().stream().sorted(Comparator.comparing(String::toString)).collect(Collectors.toList());
for(String rack: racks) {
// // Already have required number of hosts for voting. Do not take any more.
// if(numHostsRequired.get() <= 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we just remove this commented code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point. this got left behind. will remove.

AtomicInteger numHostsRequired = new AtomicInteger(effectiveVotingSize);
// Map to keep track of number of hosts to take for voting from this rack
Map<String, Integer> numHosts = new HashMap<>();
// Sort racks to get the same order
Copy link
Contributor

Choose a reason for hiding this comment

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

Would this work reliably if we have the same rack names across DCs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved offline

// continue;
// }
// Need more hosts take as as many as you can from this rack.
int v = (int) Math.min(numHostsRequired.get(), numHostsPerRack.get(rack));
Copy link
Contributor

Choose a reason for hiding this comment

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

How do we handle the case where we don't have enough voting hosts? Eg: If we just get back one host from this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point. added a check for an edge case.

Copy link
Contributor

@smukil smukil left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for addressing the review comments.

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.

3 participants