hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kih...@apache.org
Subject hadoop git commit: HDFS-8463. Calling DFSInputStream.seekToNewSource just after stream creation causes NullPointerException. Contributed by Masatake Iwasaki. (cherry picked from commit ade6d9a61eb2e57a975f0efcdf8828d51ffec5fd)
Date Thu, 04 Jun 2015 17:53:06 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2 78d626fa8 -> f0f277ddd


HDFS-8463. Calling DFSInputStream.seekToNewSource just after stream creation causes NullPointerException.
Contributed by Masatake Iwasaki.
(cherry picked from commit ade6d9a61eb2e57a975f0efcdf8828d51ffec5fd)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/f0f277dd
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/f0f277dd
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/f0f277dd

Branch: refs/heads/branch-2
Commit: f0f277ddd0432660f97a2ba36f723154ec138110
Parents: 78d626f
Author: Kihwal Lee <kihwal@apache.org>
Authored: Thu Jun 4 12:52:49 2015 -0500
Committer: Kihwal Lee <kihwal@apache.org>
Committed: Thu Jun 4 12:52:49 2015 -0500

----------------------------------------------------------------------
 hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt     |  3 +++
 .../org/apache/hadoop/hdfs/DFSInputStream.java  |  3 +++
 .../apache/hadoop/hdfs/TestDFSInputStream.java  | 25 ++++++++++++++++++++
 3 files changed, 31 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/f0f277dd/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
index 3665ca9..f121ff4 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
+++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
@@ -509,6 +509,9 @@ Release 2.8.0 - UNRELEASED
     HDFS-3716. Purger should remove stale fsimage ckpt files
     (J.Andreina via vinayakumarb)
 
+    HDFS-8463. Calling DFSInputStream.seekToNewSource just after stream creation
+    causes NullPointerException (Masatake Iwasaki via kihwal)
+
 Release 2.7.1 - UNRELEASED
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/f0f277dd/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSInputStream.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSInputStream.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSInputStream.java
index 8a3f730..6563d7b 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSInputStream.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSInputStream.java
@@ -1533,6 +1533,9 @@ implements ByteBufferReadable, CanSetDropBehind, CanSetReadahead,
    */
   @Override
   public synchronized boolean seekToNewSource(long targetPos) throws IOException {
+    if (currentNode == null) {
+      return seekToBlockSource(targetPos);
+    }
     boolean markedDead = deadNodes.containsKey(currentNode);
     addToDeadNodes(currentNode);
     DatanodeInfo oldNode = currentNode;

http://git-wip-us.apache.org/repos/asf/hadoop/blob/f0f277dd/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSInputStream.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSInputStream.java
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSInputStream.java
index b9ec2ce..26412c8 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSInputStream.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSInputStream.java
@@ -18,6 +18,8 @@
 package org.apache.hadoop.hdfs;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
 import static org.hamcrest.CoreMatchers.equalTo;
 
 import java.io.File;
@@ -28,6 +30,7 @@ import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FSDataOutputStream;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hdfs.client.HdfsClientConfigKeys;
+import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
 import org.apache.hadoop.net.unix.DomainSocket;
 import org.apache.hadoop.net.unix.TemporarySocketDirectory;
 import org.junit.Assume;
@@ -111,4 +114,26 @@ public class TestDFSInputStream {
     }
   }
 
+  @Test(timeout=60000)
+  public void testSeekToNewSource() throws IOException {
+    Configuration conf = new Configuration();
+    MiniDFSCluster cluster =
+        new MiniDFSCluster.Builder(conf).numDataNodes(3).build();
+    DistributedFileSystem fs = cluster.getFileSystem();
+    Path path = new Path("/testfile");
+    DFSTestUtil.createFile(fs, path, 1024, (short) 3, 0);
+    DFSInputStream fin = fs.dfs.open("/testfile");
+    try {
+      fin.seekToNewSource(100);
+      assertEquals(100, fin.getPos());
+      DatanodeInfo firstNode = fin.getCurrentDatanode();
+      assertNotNull(firstNode);
+      fin.seekToNewSource(100);
+      assertEquals(100, fin.getPos());
+      assertFalse(firstNode.equals(fin.getCurrentDatanode()));
+    } finally {
+      fin.close();
+      cluster.shutdown();
+    }
+  }
 }


Mime
View raw message