hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From szets...@apache.org
Subject svn commit: r1195731 - in /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs: CHANGES.txt src/main/java/org/apache/hadoop/hdfs/DFSClient.java src/test/java/org/apache/hadoop/hdfs/TestDistributedFileSystem.java
Date Tue, 01 Nov 2011 00:38:57 GMT
Author: szetszwo
Date: Tue Nov  1 00:38:57 2011
New Revision: 1195731

URL: http://svn.apache.org/viewvc?rev=1195731&view=rev
Log:
HDFS-2065. Add null checks in DFSClient.getFileChecksum(..).  Contributed by Uma Maheswara
Rao G

Modified:
    hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
    hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java
    hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDistributedFileSystem.java

Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1195731&r1=1195730&r2=1195731&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Tue Nov  1 00:38:57 2011
@@ -1232,6 +1232,9 @@ Release 0.23.0 - Unreleased
     getFileStatus on non-existing files; fix bugs in getBlockLocations; and
     changed getFileChecksum json response root to "FileChecksum".  (szetszwo)
 
+    HDFS-2065. Add null checks in DFSClient.getFileChecksum(..).  (Uma
+    Maheswara Rao G via szetszwo)
+
   BREAKDOWN OF HDFS-1073 SUBTASKS
 
     HDFS-1521. Persist transaction ID on disk between NN restarts.

Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java?rev=1195731&r1=1195730&r2=1195731&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java
(original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java
Tue Nov  1 00:38:57 2011
@@ -1106,8 +1106,11 @@ public class DFSClient implements java.i
       ClientProtocol namenode, SocketFactory socketFactory, int socketTimeout
       ) throws IOException {
     //get all block locations
-    List<LocatedBlock> locatedblocks
-        = callGetBlockLocations(namenode, src, 0, Long.MAX_VALUE).getLocatedBlocks();
+    LocatedBlocks blockLocations = callGetBlockLocations(namenode, src, 0, Long.MAX_VALUE);
+    if (null == blockLocations) {
+      throw new FileNotFoundException("File does not exist: " + src);
+    }
+    List<LocatedBlock> locatedblocks = blockLocations.getLocatedBlocks();
     final DataOutputBuffer md5out = new DataOutputBuffer();
     int bytesPerCRC = 0;
     long crcPerBlock = 0;
@@ -1117,8 +1120,11 @@ public class DFSClient implements java.i
     //get block checksum for each block
     for(int i = 0; i < locatedblocks.size(); i++) {
       if (refetchBlocks) {  // refetch to get fresh tokens
-        locatedblocks = callGetBlockLocations(namenode, src, 0, Long.MAX_VALUE)
-            .getLocatedBlocks();
+        blockLocations = callGetBlockLocations(namenode, src, 0, Long.MAX_VALUE);
+        if (null == blockLocations) {
+          throw new FileNotFoundException("File does not exist: " + src);
+        }
+        locatedblocks = blockLocations.getLocatedBlocks();
         refetchBlocks = false;
       }
       LocatedBlock lb = locatedblocks.get(i);

Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDistributedFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDistributedFileSystem.java?rev=1195731&r1=1195730&r2=1195731&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDistributedFileSystem.java
(original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDistributedFileSystem.java
Tue Nov  1 00:38:57 2011
@@ -412,6 +412,25 @@ public class TestDistributedFileSystem {
     final UserGroupInformation ugi = UserGroupInformation.createUserForTesting(
         current.getShortUserName() + "x", new String[]{"user"});
     
+    try {
+      ((DistributedFileSystem) hdfs).getFileChecksum(new Path(
+          "/test/TestNonExistingFile"));
+      fail("Expecting FileNotFoundException");
+    } catch (FileNotFoundException e) {
+      assertTrue("Not throwing the intended exception message", e.getMessage()
+          .contains("File does not exist: /test/TestNonExistingFile"));
+    }
+
+    try {
+      Path path = new Path("/test/TestExistingDir/");
+      hdfs.mkdirs(path);
+      ((DistributedFileSystem) hdfs).getFileChecksum(path);
+      fail("Expecting FileNotFoundException");
+    } catch (FileNotFoundException e) {
+      assertTrue("Not throwing the intended exception message", e.getMessage()
+          .contains("File does not exist: /test/TestExistingDir"));
+    }
+    
     //hftp
     final String hftpuri = "hftp://" + nnAddr;
     System.out.println("hftpuri=" + hftpuri);



Mime
View raw message