HDFS-12278. LeaseManager operations are inefficient in 2.8. Contributed by Rushabh S Shah.
This commit is contained in:
parent
639380efff
commit
a54c3437af
|
@ -26,9 +26,10 @@ import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.PriorityQueue;
|
import java.util.NavigableSet;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
@ -84,11 +85,15 @@ public class LeaseManager {
|
||||||
//
|
//
|
||||||
private final SortedMap<String, Lease> leases = new TreeMap<>();
|
private final SortedMap<String, Lease> leases = new TreeMap<>();
|
||||||
// Set of: Lease
|
// Set of: Lease
|
||||||
private final PriorityQueue<Lease> sortedLeases = new PriorityQueue<>(512,
|
private final NavigableSet<Lease> sortedLeases = new TreeSet<>(
|
||||||
new Comparator<Lease>() {
|
new Comparator<Lease>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(Lease o1, Lease o2) {
|
public int compare(Lease o1, Lease o2) {
|
||||||
return Long.signum(o1.getLastUpdate() - o2.getLastUpdate());
|
if (o1.getLastUpdate() != o2.getLastUpdate()) {
|
||||||
|
return Long.signum(o1.getLastUpdate() - o2.getLastUpdate());
|
||||||
|
} else {
|
||||||
|
return o1.holder.compareTo(o2.holder);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// INodeID -> Lease
|
// INodeID -> Lease
|
||||||
|
@ -428,9 +433,10 @@ public class LeaseManager {
|
||||||
|
|
||||||
long start = monotonicNow();
|
long start = monotonicNow();
|
||||||
|
|
||||||
while(!sortedLeases.isEmpty() && sortedLeases.peek().expiredHardLimit()
|
while(!sortedLeases.isEmpty() &&
|
||||||
&& !isMaxLockHoldToReleaseLease(start)) {
|
sortedLeases.first().expiredHardLimit()
|
||||||
Lease leaseToCheck = sortedLeases.peek();
|
&& !isMaxLockHoldToReleaseLease(start)) {
|
||||||
|
Lease leaseToCheck = sortedLeases.first();
|
||||||
LOG.info(leaseToCheck + " has expired hard limit");
|
LOG.info(leaseToCheck + " has expired hard limit");
|
||||||
|
|
||||||
final List<Long> removing = new ArrayList<>();
|
final List<Long> removing = new ArrayList<>();
|
||||||
|
|
Loading…
Reference in New Issue