You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ra...@apache.org on 2009/04/13 23:07:20 UTC
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
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());