Skip to content

HDFS-14541. When evictableMmapped or evictable size is zero, do not throw NoSuchElementException #977

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

Merged
merged 1 commit into from
Jun 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,8 @@ public void run() {
int numDemoted = demoteOldEvictableMmaped(curMs);
int numPurged = 0;
Long evictionTimeNs;
while (true) {
Object eldestKey;
try {
eldestKey = evictable.firstKey();
} catch (NoSuchElementException e) {
break;
}
while (!evictable.isEmpty()) {
Object eldestKey = evictable.firstKey();
evictionTimeNs = (Long)eldestKey;
long evictionTimeMs =
TimeUnit.MILLISECONDS.convert(evictionTimeNs, TimeUnit.NANOSECONDS);
Expand Down Expand Up @@ -493,13 +488,8 @@ private int demoteOldEvictableMmaped(long now) {
boolean needMoreSpace = false;
Long evictionTimeNs;

while (true) {
Object eldestKey;
try {
eldestKey = evictableMmapped.firstKey();
} catch (NoSuchElementException e) {
break;
}
while (!evictableMmapped.isEmpty()) {
Object eldestKey = evictableMmapped.firstKey();
evictionTimeNs = (Long)eldestKey;
long evictionTimeMs =
TimeUnit.MILLISECONDS.convert(evictionTimeNs, TimeUnit.NANOSECONDS);
Expand Down Expand Up @@ -533,23 +523,15 @@ private void trimEvictionMaps() {
long now = Time.monotonicNow();
demoteOldEvictableMmaped(now);

while (true) {
long evictableSize = evictable.size();
long evictableMmappedSize = evictableMmapped.size();
if (evictableSize + evictableMmappedSize <= maxTotalSize) {
return;
}
while (evictable.size() + evictableMmapped.size() > maxTotalSize) {
ShortCircuitReplica replica;
try {
if (evictableSize == 0) {
replica = (ShortCircuitReplica)evictableMmapped.get(evictableMmapped
.firstKey());
} else {
replica = (ShortCircuitReplica)evictable.get(evictable.firstKey());
}
} catch (NoSuchElementException e) {
break;
if (evictable.isEmpty()) {
replica = (ShortCircuitReplica) evictableMmapped
.get(evictableMmapped.firstKey());
} else {
replica = (ShortCircuitReplica) evictable.get(evictable.firstKey());
}

if (LOG.isTraceEnabled()) {
LOG.trace(this + ": trimEvictionMaps is purging " + replica +
StringUtils.getStackTrace(Thread.currentThread()));
Expand Down