Jelajahi Sumber

commit 601e2f165a9ddfec67a75f02aad8ea3e4977dceb
Author: Hairong Kuang <hairong@ucdev21.inktomisearch.com>
Date: Tue Mar 2 23:04:42 2010 +0000

HADOOP:6569 from http://issues.apache.org/jira/secure/attachment/12437633/optimizeCat-yahoo2.patch

+++ b/YAHOO-CHANGES.txt
+ HADOOP-6569. FsShell#cat should avoid calling uneccessary getFileStatus
+ before opening a file to read. (hairong)
+


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.20-security-patches@1077269 13f79535-47bb-0310-9956-ffa450edef68

Owen O'Malley 14 tahun lalu
induk
melakukan
cab78aa5ba

+ 1 - 4
src/core/org/apache/hadoop/fs/FsShell.java

@@ -333,7 +333,7 @@ public class FsShell extends Configured implements Tool {
    * @exception: IOException
    * @see org.apache.hadoop.fs.FileSystem.globStatus 
    */
-  void cat(String src, boolean verifyChecksum) throws IOException {
+  void cat(final String src, boolean verifyChecksum) throws IOException {
     //cat behavior in Linux
     //  [~/1207]$ ls ?.txt
     //  x.txt  z.txt
@@ -346,9 +346,6 @@ public class FsShell extends Configured implements Tool {
     new DelayedExceptionThrowing() {
       @Override
       void process(Path p, FileSystem srcFs) throws IOException {
-        if (srcFs.getFileStatus(p).isDir()) {
-          throw new IOException("Source must be a file.");
-        }
         printToStdout(srcFs.open(p));
       }
     }.globAndProcess(srcPattern, getSrcFileSystem(srcPattern, verifyChecksum));

+ 1 - 1
src/hdfs/org/apache/hadoop/hdfs/DFSClient.java

@@ -1558,7 +1558,7 @@ public class DFSClient implements FSConstants, java.io.Closeable {
     synchronized void openInfo() throws IOException {
       LocatedBlocks newInfo = callGetBlockLocations(namenode, src, 0, prefetchSize);
       if (newInfo == null) {
-        throw new IOException("Cannot open filename " + src);
+        throw new FileNotFoundException("File does not exist: " + src);
       }
 
       if (locatedBlocks != null) {

+ 3 - 3
src/test/org/apache/hadoop/cli/testConf.xml

@@ -2314,7 +2314,7 @@
       <comparators>
         <comparator>
           <type>RegexpComparator</type>
-          <expected-output>^cat: File does not exist: file</expected-output>
+          <expected-output>^cat: File does not exist: /user/[a-z]*/file</expected-output>
         </comparator>
       </comparators>
     </test>
@@ -2331,7 +2331,7 @@
       <comparators>
         <comparator>
           <type>RegexpComparator</type>
-          <expected-output>^cat: Source must be a file.</expected-output>
+          <expected-output>^cat: File does not exist: /dir1</expected-output>
         </comparator>
       </comparators>
     </test>
@@ -2348,7 +2348,7 @@
       <comparators>
         <comparator>
           <type>RegexpComparator</type>
-          <expected-output>^cat: File does not exist: dir</expected-output>
+          <expected-output>^cat: File does not exist: /user/[a-z]*/dir</expected-output>
         </comparator>
       </comparators>
     </test>