hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomwh...@apache.org
Subject svn commit: r953871 - in /hadoop/common/branches/branch-0.21: CHANGES.txt src/java/org/apache/hadoop/fs/FileSystem.java src/test/core/org/apache/hadoop/fs/TestFileSystemCaching.java
Date Fri, 11 Jun 2010 21:10:15 GMT
Author: tomwhite
Date: Fri Jun 11 21:10:15 2010
New Revision: 953871

URL: http://svn.apache.org/viewvc?rev=953871&view=rev
Log:
Merge -r 945734:945735 from trunk to branch-0.21. Fixes: HADOOP-6769

Modified:
    hadoop/common/branches/branch-0.21/CHANGES.txt
    hadoop/common/branches/branch-0.21/src/java/org/apache/hadoop/fs/FileSystem.java
    hadoop/common/branches/branch-0.21/src/test/core/org/apache/hadoop/fs/TestFileSystemCaching.java

Modified: hadoop/common/branches/branch-0.21/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.21/CHANGES.txt?rev=953871&r1=953870&r2=953871&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.21/CHANGES.txt (original)
+++ hadoop/common/branches/branch-0.21/CHANGES.txt Fri Jun 11 21:10:15 2010
@@ -858,6 +858,9 @@ Release 0.21.0 - Unreleased
 
     HADOOP-6403.  Deprecate EC2 bash scripts.  (tomwhite)
 
+    HADOOP-6769. Add an API in FileSystem to get FileSystem instances based 
+    on users(ddas via boryas)
+
   OPTIMIZATIONS
 
     HADOOP-5595. NameNode does not need to run a replicator to choose a

Modified: hadoop/common/branches/branch-0.21/src/java/org/apache/hadoop/fs/FileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.21/src/java/org/apache/hadoop/fs/FileSystem.java?rev=953871&r1=953870&r2=953871&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.21/src/java/org/apache/hadoop/fs/FileSystem.java (original)
+++ hadoop/common/branches/branch-0.21/src/java/org/apache/hadoop/fs/FileSystem.java Fri Jun
11 21:10:15 2010
@@ -21,6 +21,7 @@ import java.io.Closeable;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.net.URI;
+import java.security.PrivilegedExceptionAction;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.EnumSet;
@@ -95,6 +96,31 @@ public abstract class FileSystem extends
    * or the JVM is exited.
    */
   private Set<Path> deleteOnExit = new TreeSet<Path>();
+  
+  /**
+   * Get a filesystem instance based on the uri, the passed
+   * configuration and the user
+   * @param uri
+   * @param conf
+   * @param user
+   * @return the filesystem instance
+   * @throws IOException
+   * @throws InterruptedException
+   */
+  public static FileSystem get(final URI uri, final Configuration conf,
+        final String user) throws IOException, InterruptedException {
+    UserGroupInformation ugi;
+    if (user == null) {
+      ugi = UserGroupInformation.getCurrentUser();
+    } else {
+      ugi = UserGroupInformation.createRemoteUser(user);
+    }
+    return ugi.doAs(new PrivilegedExceptionAction<FileSystem>() {
+      public FileSystem run() throws IOException {
+        return get(uri, conf);
+      }
+    });
+  }
 
   /** Returns the configured filesystem implementation.*/
   public static FileSystem get(Configuration conf) throws IOException {

Modified: hadoop/common/branches/branch-0.21/src/test/core/org/apache/hadoop/fs/TestFileSystemCaching.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.21/src/test/core/org/apache/hadoop/fs/TestFileSystemCaching.java?rev=953871&r1=953870&r2=953871&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.21/src/test/core/org/apache/hadoop/fs/TestFileSystemCaching.java
(original)
+++ hadoop/common/branches/branch-0.21/src/test/core/org/apache/hadoop/fs/TestFileSystemCaching.java
Fri Jun 11 21:10:15 2010
@@ -26,6 +26,7 @@ import java.net.URI;
 import java.net.URISyntaxException;
 
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.security.token.Token;
 import org.apache.hadoop.security.token.TokenIdentifier;
@@ -153,5 +154,14 @@ public class TestFileSystemCaching {
     //We should have the same filesystem for both
     assertSame(fsA, fsA1);
   }
-
+  
+  @Test
+  public void testUserFS() throws Exception {
+    final Configuration conf = new Configuration();
+    
+    FileSystem fsU1 = FileSystem.get(new URI("cachedfile://a"), conf, "bar");
+    FileSystem fsU2 = FileSystem.get(new URI("cachedfile://a"), conf, "foo");
+    
+    assertNotSame(fsU1, fsU2);   
+  }
 }



Mime
View raw message