Return-Path: Delivered-To: apmail-hadoop-common-commits-archive@www.apache.org Received: (qmail 98453 invoked from network); 4 Mar 2011 04:00:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 4 Mar 2011 04:00:33 -0000 Received: (qmail 66897 invoked by uid 500); 4 Mar 2011 04:00:32 -0000 Delivered-To: apmail-hadoop-common-commits-archive@hadoop.apache.org Received: (qmail 66783 invoked by uid 500); 4 Mar 2011 04:00:32 -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 66773 invoked by uid 99); 4 Mar 2011 04:00:32 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Mar 2011 04:00:32 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.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; Fri, 04 Mar 2011 04:00:31 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 94EA22388901; Fri, 4 Mar 2011 04:00:11 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: common-commits@hadoop.apache.org From: omalley@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110304040011.94EA22388901@eris.apache.org> 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 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);