hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject svn commit: r1077289 - in /hadoop/common/branches/branch-0.20-security-patches/src: hdfs/org/apache/hadoop/hdfs/DFSClient.java test/org/apache/hadoop/hdfs/TestFileStatus.java
Date Fri, 04 Mar 2011 04:00:11 GMT
Author: omalley
Date: Fri Mar  4 04:00:11 2011
New Revision: 1077289

URL: http://svn.apache.org/viewvc?rev=1077289&view=rev
Log:
commit 7b94098a74404ef4ae8b497c0e6af74824f1900b
Author: Hairong Kuang <hairong@ucdev21.inktomisearch.com>
Date:   Fri Mar 5 05:58:25 2010 +0000

    HDFS:814 from http://issues.apache.org/jira/secure/attachment/12437934/getLength-yahoo-0.20.patch
    
    +++ b/YAHOO-CHANGES.txt
    +    HDFS-814. Add an api to get the visible length of a
    +    DFSDataInputStream. (hairong)
    +

Modified:
    hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/hdfs/TestFileStatus.java

Modified: hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java?rev=1077289&r1=1077288&r2=1077289&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java
Fri Mar  4 04:00:11 2011
@@ -1505,7 +1505,7 @@ public class DFSClient implements FSCons
    * DFSInputStream provides bytes from a named file.  It handles 
    * negotiation of the namenode and various datanodes as necessary.
    ****************************************************************/
-  class DFSInputStream extends FSInputStream {
+  private class DFSInputStream extends FSInputStream {
     private Socket s = null;
     private boolean closed = false;
 
@@ -2163,8 +2163,11 @@ public class DFSClient implements FSCons
       throw new IOException("Mark/reset not supported");
     }
   }
-    
-  static class DFSDataInputStream extends FSDataInputStream {
+
+  /**
+   * The Hdfs implementation of {@link FSDataInputStream}
+   */
+  public static class DFSDataInputStream extends FSDataInputStream {
     DFSDataInputStream(DFSInputStream in)
       throws IOException {
       super(in);
@@ -2191,6 +2194,12 @@ public class DFSClient implements FSCons
       return ((DFSInputStream)in).getAllBlocks();
     }
 
+    /**
+     * @return The visible length of the file.
+     */
+    public long getVisibleLength() throws IOException {
+      return ((DFSInputStream)in).getFileLength();
+    }
   }
 
   /****************************************************************

Modified: hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/hdfs/TestFileStatus.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/hdfs/TestFileStatus.java?rev=1077289&r1=1077288&r2=1077289&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/hdfs/TestFileStatus.java
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/hdfs/TestFileStatus.java
Fri Mar  4 04:00:11 2011
@@ -29,6 +29,7 @@ import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.hdfs.DFSClient.DFSDataInputStream;
 import org.apache.hadoop.hdfs.protocol.HdfsFileStatus;
 import org.apache.hadoop.hdfs.server.namenode.FSNamesystem;
 import org.apache.hadoop.hdfs.server.namenode.NameNode;
@@ -110,6 +111,10 @@ public class TestFileStatus extends Test
       assertEquals(fs.makeQualified(file1).toString(), 
           status.getPath().toString());
 
+      // test getVisbileLen
+      DFSDataInputStream fin = (DFSDataInputStream)fs.open(file1);
+      assertEquals(status.getLen(), fin.getVisibleLength());
+      
       // test listStatus on a file
       FileStatus[] stats = fs.listStatus(file1);
       assertEquals(1, stats.length);



Mime
View raw message