This is an automated email from the ASF dual-hosted git repository.
inigoiri pushed a commit to branch branch-2.9
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/branch-2.9 by this push:
new c2af516 HDFS-14541. When evictableMmapped or evictable size is zero,
do not throw NoSuchElementException.
c2af516 is described below
commit c2af516a9764ce30d826f5cc9f488814c1f3bd8b
Author: Inigo Goiri <[email protected]>
AuthorDate: Mon Jun 24 19:02:41 2019 -0700
HDFS-14541. When evictableMmapped or evictable size is zero, do not throw
NoSuchElementException.
(cherry picked from commit 0966407ad6fddb7adf60dba846d1f7c8a13b8ec1)
---
.../hdfs/shortcircuit/ShortCircuitCache.java | 40 ++++++----------------
1 file changed, 11 insertions(+), 29 deletions(-)
diff --git
a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/shortcircuit/ShortCircuitCache.java
b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/shortcircuit/ShortCircuitCache.java
index bd02a97..77e85cb 100644
---
a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/shortcircuit/ShortCircuitCache.java
+++
b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/shortcircuit/ShortCircuitCache.java
@@ -109,13 +109,8 @@ public class ShortCircuitCache implements Closeable {
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);
@@ -488,13 +483,8 @@ public class ShortCircuitCache implements Closeable {
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);
@@ -528,23 +518,15 @@ public class ShortCircuitCache implements Closeable {
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()));
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]