HADOOP-11659. o.a.h.FileSystem.Cache#remove should use a single hash map lookup. Contributed by Brahma Reddy Battula.

(cherry picked from commit 34117325b2)
This commit is contained in:
Akira Ajisaka 2015-03-18 15:43:10 +09:00
parent 7d0f84bd8d
commit 18740f9383
2 changed files with 10 additions and 4 deletions

View File

@ -17,6 +17,9 @@ Release 2.8.0 - UNRELEASED
HADOOP-11692. Improve authentication failure WARN message to avoid user
confusion. (Yongjun Zhang)
HADOOP-11659. o.a.h.fs.FileSystem.Cache#remove should use a single hash map
lookup. (Brahma Reddy Battula via aajisaka)
OPTIMIZATIONS
BUG FIXES

View File

@ -2701,10 +2701,12 @@ public abstract class FileSystem extends Configured implements Closeable {
}
synchronized void remove(Key key, FileSystem fs) {
if (map.containsKey(key) && fs == map.get(key)) {
map.remove(key);
FileSystem cachedFs = map.remove(key);
if (fs == cachedFs) {
toAutoClose.remove(key);
}
} else if (cachedFs != null) {
map.put(key, cachedFs);
}
}
synchronized void closeAll() throws IOException {
@ -2731,7 +2733,8 @@ public abstract class FileSystem extends Configured implements Closeable {
}
//remove from cache
remove(key, fs);
map.remove(key);
toAutoClose.remove(key);
if (fs != null) {
try {