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

Added an API on LeaseCoordinator and LeaseTaker to get all leases for… #428

Merged
merged 4 commits into from
Oct 9, 2018
Merged

Added an API on LeaseCoordinator and LeaseTaker to get all leases for… #428

merged 4 commits into from
Oct 9, 2018

Conversation

shask-amazon
Copy link
Contributor

… the application

Issue #, if available:

Description of changes:

  • getAllLeases() allows any application managing KCL scheduler to take additional action related to scale or lease management

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link
Contributor

@sahilpalvia sahilpalvia left a comment

Choose a reason for hiding this comment

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

Looking good, few minor changes required

/**
* @return All leases
*/
Collection<Lease> getAllAssignments();
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you rename the method to allLeases in both the interfaces and return a list. Could you also implement a default method to the newly added methods, since they are added to publicly exposed interfaces.

default List<Lease> allLeases() {
    return Collection.emptyList();
}

Could you also add javadoc for the methods

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok

*/
@Override
public synchronized Collection<Lease> getAllLeases() {
return Collections.unmodifiableCollection(new ArrayList<Lease>(allLeases.values()));
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a suggestion, minimum requirement for the KCL is Java 8+. So you could get away with new ArrayList<>(allLeases.values())

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

coordinator.runLeaseTaker();

Collection<Lease> allAssignments = coordinator.getAllAssignments();
assertEquals(allAssignments.size(), addedLeases.size());
Copy link
Contributor

Choose a reason for hiding this comment

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

assertThat(..., equalTo())

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

taker.takeLeases();

Collection<Lease> allLeases = taker.getAllLeases();
assertEquals(allLeases.size(), addedLeases.size());
Copy link
Contributor

Choose a reason for hiding this comment

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

assertThat(..., equalTo)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@sahilpalvia sahilpalvia added the v2.x Issues related to the 2.x version label Oct 2, 2018
Copy link
Contributor

@sahilpalvia sahilpalvia left a comment

Choose a reason for hiding this comment

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

Looking good, thanks for providing this.

@pfifer pfifer merged commit 31ab0af into awslabs:master Oct 9, 2018
@pfifer pfifer added this to the v2.0.4 milestone Oct 9, 2018
@shask-amazon shask-amazon deleted the shask-amazon branch October 9, 2018 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v2.x Issues related to the 2.x version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants