Переглянути джерело

svn merge -c 1301291 from branch-1 for HDFS-3101.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1.0@1301292 13f79535-47bb-0310-9956-ffa450edef68
Tsz-wo Sze 13 роки тому
батько
коміт
057b46bf9d

+ 5 - 3
CHANGES.txt

@@ -1,8 +1,5 @@
 Hadoop Change Log
 
-    HDFS-3075. Backport HADOOP-4885: Try to restore failed name-node storage
-    directories at checkpoint time.  (Brandon Li via szetszwo)
-
 Release 1.0.2 - unreleased
 
   NEW FEATURES
@@ -46,6 +43,11 @@ Release 1.0.2 - unreleased
 
     HDFS-2702. A single failed name dir can cause the NN to exit. (eli)
 
+    HDFS-3075. Backport HADOOP-4885: Try to restore failed name-node storage
+    directories at checkpoint time.  (Brandon Li via szetszwo)
+
+    HDFS-3101. Cannot read empty file using WebHDFS.  (szetszwo)
+
 Release 1.0.1 - 2012.02.14
 
   NEW FEATURES

+ 5 - 3
src/hdfs/org/apache/hadoop/hdfs/server/namenode/web/resources/NamenodeWebHdfsMethods.java

@@ -137,9 +137,11 @@ public class NamenodeWebHdfsMethods {
         throw new FileNotFoundException("File " + path + " not found.");
       }
       final long len = status.getLen();
-      if (op == GetOpParam.Op.OPEN && (openOffset < 0L || openOffset >= len)) {
-        throw new IOException("Offset=" + openOffset + " out of the range [0, "
-          + len + "); " + op + ", path=" + path);
+      if (op == GetOpParam.Op.OPEN) {
+        if (openOffset < 0L || (openOffset >= len && len > 0)) {
+          throw new IOException("Offset=" + openOffset
+              + " out of the range [0, " + len + "); " + op + ", path=" + path);
+        }
       }
 
       if (len > 0) {

+ 15 - 2
src/test/org/apache/hadoop/hdfs/web/TestWebHdfsFileSystemContract.java

@@ -198,7 +198,21 @@ public class TestWebHdfsFileSystemContract extends FileSystemContractBaseTest {
   }
 
   public void testSeek() throws IOException {
-    final Path p = new Path("/test/testSeek");
+    final Path dir = new Path("/test/testSeek");
+    assertTrue(fs.mkdirs(dir));
+
+    { //test zero file size
+      final Path zero = new Path(dir, "zero");
+      fs.create(zero).close();
+      
+      int count = 0;
+      final FSDataInputStream in = fs.open(zero);
+      for(; in.read() != -1; count++);
+      in.close();
+      assertEquals(0, count);
+    }
+
+    final Path p = new Path(dir, "file");
     createFile(p);
 
     final int one_third = data.length/3;
@@ -269,7 +283,6 @@ public class TestWebHdfsFileSystemContract extends FileSystemContractBaseTest {
       final FSDataInputStream in = fs.open(root);
       in.read();
       fail();
-      fail();
     } catch(IOException e) {
       WebHdfsFileSystem.LOG.info("This is expected.", e);
     }