Browse Source

HADOOP-1131. Add a closeAll() static method to FileSystem. Contributed by Philippe Gassmann.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@522268 13f79535-47bb-0310-9956-ffa450edef68
Thomas White 18 years ago
parent
commit
c4336003ac
2 changed files with 17 additions and 0 deletions
  1. 3 0
      CHANGES.txt
  2. 14 0
      src/java/org/apache/hadoop/fs/FileSystem.java

+ 3 - 0
CHANGES.txt

@@ -37,6 +37,9 @@ Trunk (unreleased changes)
 11. HADOOP-1122.  Fix divide-by-zero exception in FSNamesystem
     chooseTarget method.  (Dhruba Borthakur via tomwhite)
 
+12. HADOOP-1131.  Add a closeAll() static method to FileSystem.
+    (Philippe Gassmann via tomwhite)
+
 
 Release 0.12.2 - 2007-23-17
 

+ 14 - 0
src/java/org/apache/hadoop/fs/FileSystem.java

@@ -164,6 +164,20 @@ public abstract class FileSystem extends Configured {
       return fs;
     }
 
+    /**
+     * Close all cached filesystems. Be sure those filesystems are not
+     * used anymore.
+     * 
+     * @throws IOException
+     */
+    public static synchronized void closeAll() throws IOException{
+      for(Map<String, FileSystem>  fss : CACHE.values()){
+        for(FileSystem fs : fss.values()){
+          fs.close();
+        }
+      }
+    }
+
     /** Make sure that a path specifies a FileSystem. */
     public Path makeQualified(Path path) {
       checkPath(path);