Return-Path: Delivered-To: apmail-hadoop-core-commits-archive@www.apache.org Received: (qmail 60115 invoked from network); 13 Apr 2009 21:07:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 13 Apr 2009 21:07:44 -0000 Received: (qmail 36069 invoked by uid 500); 13 Apr 2009 21:07:44 -0000 Delivered-To: apmail-hadoop-core-commits-archive@hadoop.apache.org Received: (qmail 35982 invoked by uid 500); 13 Apr 2009 21:07:43 -0000 Mailing-List: contact core-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: core-dev@hadoop.apache.org Delivered-To: mailing list core-commits@hadoop.apache.org Received: (qmail 35973 invoked by uid 99); 13 Apr 2009 21:07:43 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Apr 2009 21:07:43 +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; Mon, 13 Apr 2009 21:07:41 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 77CB0238893B; Mon, 13 Apr 2009 21:07:20 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r764605 - in /hadoop/core/trunk: CHANGES.txt src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java src/test/org/apache/hadoop/hdfs/TestDistributedFileSystem.java Date: Mon, 13 Apr 2009 21:07:20 -0000 To: core-commits@hadoop.apache.org From: rangadi@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090413210720.77CB0238893B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: rangadi Date: Mon Apr 13 21:07:19 2009 New Revision: 764605 URL: http://svn.apache.org/viewvc?rev=764605&view=rev Log: HADOOP-5581. HDFS should throw FileNotFoundException when while opening a file that does not exist. (Brian Bockelman via rangadi) Modified: hadoop/core/trunk/CHANGES.txt hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/TestDistributedFileSystem.java Modified: hadoop/core/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=764605&r1=764604&r2=764605&view=diff ============================================================================== --- hadoop/core/trunk/CHANGES.txt (original) +++ hadoop/core/trunk/CHANGES.txt Mon Apr 13 21:07:19 2009 @@ -223,6 +223,9 @@ value of webinterface.private.actions. (Vinod Kumar Vavilapalli via yhemanth) + HADOOP-5581. HDFS should throw FileNotFoundException when while opening + a file that does not exist. (Brian Bockelman via rangadi) + OPTIMIZATIONS HADOOP-5595. NameNode does not need to run a replicator to choose a Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java?rev=764605&r1=764604&r2=764605&view=diff ============================================================================== --- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java (original) +++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java Mon Apr 13 21:07:19 2009 @@ -778,6 +778,7 @@ /** * Get block locations within the specified range. * @see ClientProtocol#getBlockLocations(String, long, long) + * @throws FileNotFoundException */ public LocatedBlocks getBlockLocations(String src, long offset, long length, boolean doAccessTime) throws IOException { @@ -787,7 +788,10 @@ if (length < 0) { throw new IOException("Negative length is not supported. File: " + src ); } - final LocatedBlocks ret = getBlockLocationsInternal(src, dir.getFileINode(src), + INodeFile inode = dir.getFileINode(src); + if (inode == null) + throw new FileNotFoundException(); + final LocatedBlocks ret = getBlockLocationsInternal(src, inode, offset, length, Integer.MAX_VALUE, doAccessTime); if (auditLog.isInfoEnabled()) { logAuditEvent(UserGroupInformation.getCurrentUGI(), Modified: hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/TestDistributedFileSystem.java URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/TestDistributedFileSystem.java?rev=764605&r1=764604&r2=764605&view=diff ============================================================================== --- hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/TestDistributedFileSystem.java (original) +++ hadoop/core/trunk/src/test/org/apache/hadoop/hdfs/TestDistributedFileSystem.java Mon Apr 13 21:07:19 2009 @@ -18,6 +18,7 @@ package org.apache.hadoop.hdfs; +import java.io.FileNotFoundException; import java.io.IOException; import java.net.URI; import java.util.Random; @@ -100,6 +101,27 @@ } { + // Check to see if opening a non-existent file triggers a FNF + FileSystem fs = cluster.getFileSystem(); + Path dir = new Path("/wrwelkj"); + assertFalse("File should not exist for test.", fs.exists(dir)); + + try { + FSDataInputStream in = fs.open(dir); + try { + in.close(); + fs.close(); + } finally { + assertTrue("Did not get a FileNotFoundException for non-existing" + + " file.", false); + } + } catch (FileNotFoundException fnf) { + // This is the proper exception to catch; move on. + } + + } + + { DistributedFileSystem dfs = (DistributedFileSystem)cluster.getFileSystem(); assertFalse(dfs.dfs.isLeaseCheckerStarted());