hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject svn commit: r1502067 - in /hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop: fs/Hdfs.java hdfs/protocol/HdfsFileStatus.java hdfs/protocol/HdfsLocatedFileStatus.java
Date Thu, 11 Jul 2013 00:12:24 GMT
Author: tucu
Date: Thu Jul 11 00:12:23 2013
New Revision: 1502067

URL: http://svn.apache.org/r1502067
Log:
HADOOP-9414.  Refactor out FSLinkResolver and relevant helper methods. (Andrew Wang via Colin
Patrick McCabe)

Modified:
    hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/fs/Hdfs.java
    hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/HdfsFileStatus.java
    hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/HdfsLocatedFileStatus.java

Modified: hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/fs/Hdfs.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/fs/Hdfs.java?rev=1502067&r1=1502066&r2=1502067&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/fs/Hdfs.java
(original)
+++ hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/fs/Hdfs.java
Thu Jul 11 00:12:23 2013
@@ -123,7 +123,7 @@ public class Hdfs extends AbstractFileSy
       throws IOException, UnresolvedLinkException {
     HdfsFileStatus fi = dfs.getFileInfo(getUriPath(f));
     if (fi != null) {
-      return makeQualified(fi, f);
+      return fi.makeQualified(getUri(), f);
     } else {
       throw new FileNotFoundException("File does not exist: " + f.toString());
     }
@@ -134,33 +134,10 @@ public class Hdfs extends AbstractFileSy
       throws IOException, UnresolvedLinkException {
     HdfsFileStatus fi = dfs.getFileLinkInfo(getUriPath(f));
     if (fi != null) {
-      return makeQualified(fi, f);
+      return fi.makeQualified(getUri(), f);
     } else {
       throw new FileNotFoundException("File does not exist: " + f);
     }
-  }  
-
-  private FileStatus makeQualified(HdfsFileStatus f, Path parent) {
-    // NB: symlink is made fully-qualified in FileContext. 
-    return new FileStatus(f.getLen(), f.isDir(), f.getReplication(),
-        f.getBlockSize(), f.getModificationTime(),
-        f.getAccessTime(),
-        f.getPermission(), f.getOwner(), f.getGroup(),
-        f.isSymlink() ? new Path(f.getSymlink()) : null,
-        (f.getFullPath(parent)).makeQualified(
-            getUri(), null)); // fully-qualify path
-  }
-
-  private LocatedFileStatus makeQualifiedLocated(
-      HdfsLocatedFileStatus f, Path parent) {
-    return new LocatedFileStatus(f.getLen(), f.isDir(), f.getReplication(),
-        f.getBlockSize(), f.getModificationTime(),
-        f.getAccessTime(),
-        f.getPermission(), f.getOwner(), f.getGroup(),
-        f.isSymlink() ? new Path(f.getSymlink()) : null,
-        (f.getFullPath(parent)).makeQualified(
-            getUri(), null), // fully-qualify path
-        DFSUtil.locatedBlocks2Locations(f.getBlockLocations()));
   }
 
   @Override
@@ -181,7 +158,8 @@ public class Hdfs extends AbstractFileSy
 
       @Override
       public LocatedFileStatus next() throws IOException {
-        return makeQualifiedLocated((HdfsLocatedFileStatus)getNext(), p);
+        return ((HdfsLocatedFileStatus)getNext()).makeQualifiedLocated(
+            getUri(), p);
       }
     };
   }
@@ -194,7 +172,7 @@ public class Hdfs extends AbstractFileSy
 
       @Override
       public FileStatus next() throws IOException {
-        return makeQualified(getNext(), f);
+        return getNext().makeQualified(getUri(), f);
       }
     };
   }
@@ -278,7 +256,7 @@ public class Hdfs extends AbstractFileSy
     if (!thisListing.hasMore()) { // got all entries of the directory
       FileStatus[] stats = new FileStatus[partialListing.length];
       for (int i = 0; i < partialListing.length; i++) {
-        stats[i] = makeQualified(partialListing[i], f);
+        stats[i] = partialListing[i].makeQualified(getUri(), f);
       }
       return stats;
     }
@@ -291,7 +269,7 @@ public class Hdfs extends AbstractFileSy
       new ArrayList<FileStatus>(totalNumEntries);
     // add the first batch of entries to the array list
     for (HdfsFileStatus fileStatus : partialListing) {
-      listing.add(makeQualified(fileStatus, f));
+      listing.add(fileStatus.makeQualified(getUri(), f));
     }
  
     // now fetch more entries
@@ -305,7 +283,7 @@ public class Hdfs extends AbstractFileSy
  
       partialListing = thisListing.getPartialListing();
       for (HdfsFileStatus fileStatus : partialListing) {
-        listing.add(makeQualified(fileStatus, f));
+        listing.add(fileStatus.makeQualified(getUri(), f));
       }
     } while (thisListing.hasMore());
  

Modified: hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/HdfsFileStatus.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/HdfsFileStatus.java?rev=1502067&r1=1502066&r2=1502067&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/HdfsFileStatus.java
(original)
+++ hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/HdfsFileStatus.java
Thu Jul 11 00:12:23 2013
@@ -17,8 +17,11 @@
  */
 package org.apache.hadoop.hdfs.protocol;
 
+import java.net.URI;
+
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.classification.InterfaceStability;
+import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.hdfs.DFSUtil;
@@ -238,4 +241,14 @@ public class HdfsFileStatus {
   final public int getChildrenNum() {
     return childrenNum;
   }
+
+  final public FileStatus makeQualified(URI defaultUri, Path path) {
+    return new FileStatus(getLen(), isDir(), getReplication(),
+        getBlockSize(), getModificationTime(),
+        getAccessTime(),
+        getPermission(), getOwner(), getGroup(),
+        isSymlink() ? new Path(getSymlink()) : null,
+        (getFullPath(path)).makeQualified(
+            defaultUri, null)); // fully-qualify path
+  }
 }

Modified: hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/HdfsLocatedFileStatus.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/HdfsLocatedFileStatus.java?rev=1502067&r1=1502066&r2=1502067&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/HdfsLocatedFileStatus.java
(original)
+++ hadoop/common/branches/branch-2.1-beta/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/HdfsLocatedFileStatus.java
Thu Jul 11 00:12:23 2013
@@ -17,9 +17,14 @@
  */
 package org.apache.hadoop.hdfs.protocol;
 
+import java.net.URI;
+
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.classification.InterfaceStability;
+import org.apache.hadoop.fs.LocatedFileStatus;
+import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.permission.FsPermission;
+import org.apache.hadoop.hdfs.DFSUtil;
 
 /** 
  * Interface that represents the over the wire information
@@ -61,4 +66,16 @@ public class HdfsLocatedFileStatus exten
   public LocatedBlocks getBlockLocations() {
     return locations;
   }
+
+  final public LocatedFileStatus makeQualifiedLocated(URI defaultUri,
+      Path path) {
+    return new LocatedFileStatus(getLen(), isDir(), getReplication(),
+        getBlockSize(), getModificationTime(),
+        getAccessTime(),
+        getPermission(), getOwner(), getGroup(),
+        isSymlink() ? new Path(getSymlink()) : null,
+        (getFullPath(path)).makeQualified(
+            defaultUri, null), // fully-qualify path
+        DFSUtil.locatedBlocks2Locations(getBlockLocations()));
+  }
 }



Mime
View raw message