You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by el...@apache.org on 2011/06/12 03:36:14 UTC

svn commit: r1134854 - in /hadoop/common/trunk: CHANGES.txt src/java/org/apache/hadoop/fs/FileContext.java src/test/core/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java

Author: eli
Date: Sun Jun 12 01:36:13 2011
New Revision: 1134854

URL: http://svn.apache.org/viewvc?rev=1134854&view=rev
Log:
HADOOP-7375. Add resolvePath method to FileContext. Contributed by Sanjay Radia

Modified:
    hadoop/common/trunk/CHANGES.txt
    hadoop/common/trunk/src/java/org/apache/hadoop/fs/FileContext.java
    hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java

Modified: hadoop/common/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/CHANGES.txt?rev=1134854&r1=1134853&r2=1134854&view=diff
==============================================================================
--- hadoop/common/trunk/CHANGES.txt (original)
+++ hadoop/common/trunk/CHANGES.txt Sun Jun 12 01:36:13 2011
@@ -204,6 +204,8 @@ Trunk (unreleased changes)
 
     HADOOP-1886. Undocumented parameters in FilesSystem. (Frank Conrad via eli)
 
+    HADOOP-7375. Add resolvePath method to FileContext. (Sanjay Radia via eli)
+
   OPTIMIZATIONS
   
     HADOOP-7333. Performance improvement in PureJavaCrc32. (Eric Caspole

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/fs/FileContext.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/fs/FileContext.java?rev=1134854&r1=1134853&r2=1134854&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/fs/FileContext.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/fs/FileContext.java Sun Jun 12 01:36:13 2011
@@ -547,6 +547,29 @@ public final class FileContext {
   
   
   /**
+   * Resolve the path following any symlinks or mount points
+   * @param f to be resolved
+   * @return fully qualified resolved path
+   * 
+   * @throws FileNotFoundException  If <code>f</code> does not exist
+   * @throws AccessControlException if access denied
+   * @throws IOException If an IO Error occurred
+   * 
+   * Exceptions applicable to file systems accessed over RPC:
+   * @throws RpcClientException If an exception occurred in the RPC client
+   * @throws RpcServerException If an exception occurred in the RPC server
+   * @throws UnexpectedServerException If server implementation throws
+   *           undeclared exception to RPC server
+   * 
+   * RuntimeExceptions:
+   * @throws InvalidPathException If path <code>f</code> is not valid
+   */
+  public Path resolvePath(final Path f) throws FileNotFoundException,
+      UnresolvedLinkException, AccessControlException, IOException {
+    return resolve(f);
+  }
+  
+  /**
    * Make the path fully qualified if it is isn't. 
    * A Fully-qualified path has scheme and authority specified and an absolute
    * path.
@@ -2204,13 +2227,14 @@ public final class FileContext {
    * Resolves all symbolic links in the specified path.
    * Returns the new path object.
    */
-  protected Path resolve(final Path f) throws IOException {
-    return new FSLinkResolver<FileStatus>() {
-      public FileStatus next(final AbstractFileSystem fs, final Path p) 
+  protected Path resolve(final Path f) throws FileNotFoundException,
+      UnresolvedLinkException, AccessControlException, IOException {
+    return new FSLinkResolver<Path>() {
+      public Path next(final AbstractFileSystem fs, final Path p) 
         throws IOException, UnresolvedLinkException {
-        return fs.getFileStatus(p);
+        return fs.resolvePath(p);
       }
-    }.resolve(this, f).getPath();
+    }.resolve(this, f);
   }
 
   /**
@@ -2240,7 +2264,8 @@ public final class FileContext {
   Set<AbstractFileSystem> resolveAbstractFileSystems(final Path f)
       throws IOException {
     final Path absF = fixRelativePart(f);
-    final HashSet<AbstractFileSystem> result = new HashSet<AbstractFileSystem>();
+    final HashSet<AbstractFileSystem> result 
+      = new HashSet<AbstractFileSystem>();
     new FSLinkResolver<Void>() {
       public Void next(final AbstractFileSystem fs, final Path p)
           throws IOException, UnresolvedLinkException {

Modified: hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java?rev=1134854&r1=1134853&r2=1134854&view=diff
==============================================================================
--- hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java (original)
+++ hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java Sun Jun 12 01:36:13 2011
@@ -468,20 +468,20 @@ public class ViewFsBaseTest {
   
   @Test
   public void testResolvePathInternalPaths() throws IOException {
-    Assert.assertEquals(new Path("/"), fcView.getDefaultFileSystem().resolvePath(new Path("/")));
+    Assert.assertEquals(new Path("/"), fcView.resolvePath(new Path("/")));
     Assert.assertEquals(new Path("/internalDir"),
-                          fcView.getDefaultFileSystem().resolvePath(new Path("/internalDir")));
+                          fcView.resolvePath(new Path("/internalDir")));
   }
   @Test
   public void testResolvePathMountPoints() throws IOException {
     Assert.assertEquals(new Path(targetTestRoot,"user"),
-                          fcView.getDefaultFileSystem().resolvePath(new Path("/user")));
+                          fcView.resolvePath(new Path("/user")));
     Assert.assertEquals(new Path(targetTestRoot,"data"),
-        fcView.getDefaultFileSystem().resolvePath(new Path("/data")));
+        fcView.resolvePath(new Path("/data")));
     Assert.assertEquals(new Path(targetTestRoot,"dir2"),
-        fcView.getDefaultFileSystem().resolvePath(new Path("/internalDir/linkToDir2")));
+        fcView.resolvePath(new Path("/internalDir/linkToDir2")));
     Assert.assertEquals(new Path(targetTestRoot,"dir3"),
-        fcView.getDefaultFileSystem().resolvePath(new Path("/internalDir/internalDir2/linkToDir3")));
+        fcView.resolvePath(new Path("/internalDir/internalDir2/linkToDir3")));
 
   }
   
@@ -489,30 +489,30 @@ public class ViewFsBaseTest {
   public void testResolvePathThroughMountPoints() throws IOException {
     FileContextTestHelper.createFile(fcView, "/user/foo");
     Assert.assertEquals(new Path(targetTestRoot,"user/foo"),
-                          fcView.getDefaultFileSystem().resolvePath(new Path("/user/foo")));
+                          fcView.resolvePath(new Path("/user/foo")));
     
     fcView.mkdir(
         FileContextTestHelper.getTestRootPath(fcView, "/user/dirX"),
         FileContext.DEFAULT_PERM, false);
     Assert.assertEquals(new Path(targetTestRoot,"user/dirX"),
-        fcView.getDefaultFileSystem().resolvePath(new Path("/user/dirX")));
+        fcView.resolvePath(new Path("/user/dirX")));
 
     
     fcView.mkdir(
         FileContextTestHelper.getTestRootPath(fcView, "/user/dirX/dirY"),
         FileContext.DEFAULT_PERM, false);
     Assert.assertEquals(new Path(targetTestRoot,"user/dirX/dirY"),
-        fcView.getDefaultFileSystem().resolvePath(new Path("/user/dirX/dirY")));
+        fcView.resolvePath(new Path("/user/dirX/dirY")));
   }
 
   @Test(expected=FileNotFoundException.class) 
   public void testResolvePathDanglingLink() throws IOException {
-      fcView.getDefaultFileSystem().resolvePath(new Path("/danglingLink"));
+      fcView.resolvePath(new Path("/danglingLink"));
   }
   
   @Test(expected=FileNotFoundException.class) 
   public void testResolvePathMissingThroughMountPoints() throws IOException {
-    fcView.getDefaultFileSystem().resolvePath(new Path("/user/nonExisting"));
+    fcView.resolvePath(new Path("/user/nonExisting"));
   }
   
 
@@ -521,7 +521,7 @@ public class ViewFsBaseTest {
     fcView.mkdir(
         FileContextTestHelper.getTestRootPath(fcView, "/user/dirX"),
         FileContext.DEFAULT_PERM, false);
-    fcView.getDefaultFileSystem().resolvePath(new Path("/user/dirX/nonExisting"));
+    fcView.resolvePath(new Path("/user/dirX/nonExisting"));
   }