Merge pull request #57 from Renjuju/cherry-pick-leases-list-to-set
[Cherry-pick] Convert expiredLeases to set (#56)
This commit is contained in:
commit
a24e7dcf03
1 changed files with 4 additions and 1 deletions
|
|
@ -499,10 +499,13 @@ public class DynamoDBLeaseTaker implements LeaseTaker {
|
|||
*/
|
||||
private Map<String, Integer> computeLeaseCounts(List<Lease> expiredLeases) {
|
||||
Map<String, Integer> leaseCounts = new HashMap<>();
|
||||
// The set will give much faster lookup than the original list, an
|
||||
// important optimization when the list is large
|
||||
Set<Lease> expiredLeasesSet = new HashSet<>(expiredLeases);
|
||||
|
||||
// Compute the number of leases per worker by looking through allLeases and ignoring leases that have expired.
|
||||
for (Lease lease : allLeases.values()) {
|
||||
if (!expiredLeases.contains(lease)) {
|
||||
if (!expiredLeasesSet.contains(lease)) {
|
||||
String leaseOwner = lease.leaseOwner();
|
||||
Integer oldCount = leaseCounts.get(leaseOwner);
|
||||
if (oldCount == null) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue