|
@@ -311,6 +311,17 @@ public abstract class FileSystem extends Configured implements Closeable {
|
|
CACHE.closeAll();
|
|
CACHE.closeAll();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Close all cached filesystems for a given UGI. Be sure those filesystems
|
|
|
|
+ * are not used anymore.
|
|
|
|
+ * @param ugi
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ public static void closeAllForUGI(UserGroupInformation ugi)
|
|
|
|
+ throws IOException {
|
|
|
|
+ CACHE.closeAll(ugi);
|
|
|
|
+ }
|
|
|
|
+
|
|
/** Make sure that a path specifies a FileSystem. */
|
|
/** Make sure that a path specifies a FileSystem. */
|
|
public Path makeQualified(Path path) {
|
|
public Path makeQualified(Path path) {
|
|
checkPath(path);
|
|
checkPath(path);
|
|
@@ -1816,6 +1827,32 @@ public abstract class FileSystem extends Configured implements Closeable {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ synchronized void closeAll(UserGroupInformation ugi) throws IOException {
|
|
|
|
+ List<FileSystem> targetFSList = new ArrayList<FileSystem>();
|
|
|
|
+ //Make a pass over the list and collect the filesystems to close
|
|
|
|
+ //we cannot close inline since close() removes the entry from the Map
|
|
|
|
+ for (Map.Entry<Key, FileSystem> entry : map.entrySet()) {
|
|
|
|
+ final Key key = entry.getKey();
|
|
|
|
+ final FileSystem fs = entry.getValue();
|
|
|
|
+ if (ugi.equals(key.ugi) && fs != null) {
|
|
|
|
+ targetFSList.add(fs);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ List<IOException> exceptions = new ArrayList<IOException>();
|
|
|
|
+ //now make a pass over the target list and close each
|
|
|
|
+ for (FileSystem fs : targetFSList) {
|
|
|
|
+ try {
|
|
|
|
+ fs.close();
|
|
|
|
+ }
|
|
|
|
+ catch(IOException ioe) {
|
|
|
|
+ exceptions.add(ioe);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (!exceptions.isEmpty()) {
|
|
|
|
+ throw MultipleIOException.createIOException(exceptions);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
/** FileSystem.Cache.Key */
|
|
/** FileSystem.Cache.Key */
|
|
static class Key {
|
|
static class Key {
|
|
final String scheme;
|
|
final String scheme;
|