HDFS-14419. Avoid repeated calls to the listOpenFiles function. Contributed by HuangTao.
This commit is contained in:
parent
3ae775d740
commit
99f88c30cb
|
@ -25,6 +25,7 @@ import java.util.Collection;
|
|||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.NavigableSet;
|
||||
import java.util.Set;
|
||||
|
@ -302,7 +303,9 @@ public class LeaseManager {
|
|||
|
||||
int count = 0;
|
||||
String fullPathName = null;
|
||||
for (Long inodeId: inodeIds) {
|
||||
Iterator<Long> inodeIdIterator = inodeIds.iterator();
|
||||
while (inodeIdIterator.hasNext()) {
|
||||
Long inodeId = inodeIdIterator.next();
|
||||
final INodeFile inodeFile =
|
||||
fsnamesystem.getFSDirectory().getInode(inodeId).asFile();
|
||||
if (!inodeFile.isUnderConstruction()) {
|
||||
|
@ -323,7 +326,8 @@ public class LeaseManager {
|
|||
break;
|
||||
}
|
||||
}
|
||||
boolean hasMore = (numResponses < remainingLeases.size());
|
||||
// avoid rescanning all leases when we have checked all leases already
|
||||
boolean hasMore = inodeIdIterator.hasNext();
|
||||
return new BatchedListEntries<>(openFileEntries, hasMore);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue