Return-Path: Delivered-To: apmail-hadoop-common-commits-archive@www.apache.org Received: (qmail 20596 invoked from network); 7 Oct 2009 17:11:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 7 Oct 2009 17:11:49 -0000 Received: (qmail 47844 invoked by uid 500); 7 Oct 2009 17:11:49 -0000 Delivered-To: apmail-hadoop-common-commits-archive@hadoop.apache.org Received: (qmail 47795 invoked by uid 500); 7 Oct 2009 17:11:49 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-dev@hadoop.apache.org Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 47786 invoked by uid 99); 7 Oct 2009 17:11:49 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Oct 2009 17:11:49 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Oct 2009 17:11:46 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 96B5423888E4; Wed, 7 Oct 2009 17:11:25 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: common-commits@hadoop.apache.org From: suresh@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091007171125.96B5423888E4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 results = new ArrayList(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 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 results = new ArrayList(); 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