hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sur...@apache.org
Subject svn commit: r822806 - in /hadoop/common/branches/branch-0.21: CHANGES.txt src/java/org/apache/hadoop/fs/FileContext.java
Date Wed, 07 Oct 2009 17:11:25 GMT
Author: suresh
Date: Wed Oct  7 17:11:25 2009
New Revision: 822806

URL: http://svn.apache.org/viewvc?rev=822806&view=rev
Log:
HADOOP-6286. Fix bugs in related to URI handling in glob methods in FileContext. Contributed
by Boris Shkolnik.

Modified:
    hadoop/common/branches/branch-0.21/CHANGES.txt
    hadoop/common/branches/branch-0.21/src/java/org/apache/hadoop/fs/FileContext.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=822806&r1=822805&r2=822806&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.21/CHANGES.txt (original)
+++ hadoop/common/branches/branch-0.21/CHANGES.txt Wed Oct  7 17:11:25 2009
@@ -1075,6 +1075,9 @@
     HADOOP-6285. Fix the result type of the getParameterMap method in the
     HttpServer.QuotingInputFilter. (omalley)
 
+    HADOOP-6286. Fix bugs in related to URI handling in glob methods in 
+    FileContext. (Boris Shkolnik via suresh)
+
 Release 0.20.1 - 2009-09-01
 
   INCOMPATIBLE CHANGES

Modified: hadoop/common/branches/branch-0.21/src/java/org/apache/hadoop/fs/FileContext.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.21/src/java/org/apache/hadoop/fs/FileContext.java?rev=822806&r1=822805&r2=822806&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.21/src/java/org/apache/hadoop/fs/FileContext.java (original)
+++ hadoop/common/branches/branch-0.21/src/java/org/apache/hadoop/fs/FileContext.java Wed
Oct  7 17:11:25 2009
@@ -869,7 +869,11 @@
       }
       ArrayList<FileStatus> results = new ArrayList<FileStatus>(paths.length);
       for (int i = 0; i < paths.length; i++) {
-        results.add(FileContext.this.getFileStatus(paths[i]));
+        try {
+          results.add(FileContext.this.getFileStatus(paths[i]));
+        } catch (FileNotFoundException fnfe) {
+          // ignoring 
+        }
       }
       return results.toArray(new FileStatus[results.size()]);
     }
@@ -1016,17 +1020,25 @@
      * @return an array of FileStatus objects
      * @throws IOException if any I/O error occurs when fetching file status
      */
-    public FileStatus[] globStatus(Path pathPattern, PathFilter filter)
+    public FileStatus[] globStatus(final Path pathPattern, final PathFilter filter)
       throws IOException {
+      
       String filename = pathPattern.toUri().getPath();
+      
       List<String> filePatterns = GlobExpander.expand(filename);
       if (filePatterns.size() == 1) {
-        return globStatusInternal(pathPattern, filter);
+        Path p = fixRelativePart(pathPattern);
+        FileSystem fs = getFSofPath(p);
+        URI uri = fs.getUri();
+        return globStatusInternal(uri, p, filter);
       } else {
         List<FileStatus> results = new ArrayList<FileStatus>();
         for (String filePattern : filePatterns) {
-          FileStatus[] files = 
-                      globStatusInternal(new Path(filePattern), filter);
+          Path p = new Path(filePattern);
+          p = fixRelativePart(p);
+          FileSystem fs = getFSofPath(p);
+          URI uri = fs.getUri();
+          FileStatus[] files = globStatusInternal(uri, p, filter);
           for (FileStatus file : files) {
             results.add(file);
           }
@@ -1035,15 +1047,21 @@
       }
     }
 
-    private FileStatus[] globStatusInternal(Path pathPattern, PathFilter filter)
+    private FileStatus[] globStatusInternal(
+        final URI uri, final Path inPathPattern, final PathFilter filter)
       throws IOException {
       Path[] parents = new Path[1];
       int level = 0;
+      
+      // comes in as full path, but just in case
+      final Path pathPattern = fixRelativePart(inPathPattern);
+      
       String filename = pathPattern.toUri().getPath();
       
       // path has only zero component
       if ("".equals(filename) || Path.SEPARATOR.equals(filename)) {
-        return getFileStatus(new Path[]{pathPattern});
+        Path p = pathPattern.makeQualified(uri, null);
+        return getFileStatus(new Path[]{p});
       }
 
       // path has at least one component
@@ -1058,11 +1076,18 @@
 
       // glob the paths that match the parent path, ie. [0, components.length-1]
       boolean[] hasGlob = new boolean[]{false};
-      Path[] parentPaths = globPathsLevel(parents, components, level, hasGlob);
+      Path[] relParentPaths = globPathsLevel(parents, components, level, hasGlob);
       FileStatus[] results;
-      if (parentPaths == null || parentPaths.length == 0) {
+      
+      if (relParentPaths == null || relParentPaths.length == 0) {
         results = null;
       } else {
+        // fix the pathes to be abs
+        Path[] parentPaths = new Path [relParentPaths.length]; 
+        for(int i=0; i<relParentPaths.length; i++) {
+          parentPaths[i] = relParentPaths[i].makeQualified(uri, null);
+        }
+        
         // Now work on the last component of the path
         GlobFilter fp = 
                     new GlobFilter(components[components.length - 1], filter);
@@ -1374,7 +1399,7 @@
     return (srcUri.getAuthority().equals(dstUri.getAuthority()) && srcUri
         .getAuthority().equals(dstUri.getAuthority()));
   }
-  
+
   /**
    * Deletes all the paths in deleteOnExit on JVM shutdown
    */



Mime
View raw message