Jelajahi Sumber

HADOOP-4499. DFSClient should invoke checksumOk only once. (Raghu Angadi)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/branches/branch-0.19@708724 13f79535-47bb-0310-9956-ffa450edef68
Raghu Angadi 17 tahun lalu
induk
melakukan
630b674f34
2 mengubah file dengan 8 tambahan dan 3 penghapusan
  1. 2 0
      CHANGES.txt
  2. 6 3
      src/hdfs/org/apache/hadoop/hdfs/DFSClient.java

+ 2 - 0
CHANGES.txt

@@ -962,6 +962,8 @@ Release 0.19.0 - Unreleased
     HADOOP-4525. Fix ipc.server.ipcnodelay originally missed in in HADOOP-2232.
     (cdouglas via Clint Morgan)
 
+    HADOOP-4499. DFSClient should invoke checksumOk only once. (Raghu Angadi)
+
 Release 0.18.2 - Unreleased
 
   BUG FIXES

+ 6 - 3
src/hdfs/org/apache/hadoop/hdfs/DFSClient.java

@@ -1024,7 +1024,7 @@ public class DFSClient implements FSConstants, java.io.Closeable {
     private int bytesPerChecksum;
     private int checksumSize;
     private boolean gotEOS = false;
-    private boolean sentChecksumOk = false;
+    private boolean sentChecksumOk = false; //temp : to be removed in 0.20.0
     
     byte[] skipBuf = null;
     ByteBuffer checksumBytes = null;
@@ -1057,12 +1057,15 @@ public class DFSClient implements FSConstants, java.io.Closeable {
         }
       }
       
+      boolean eosBefore = gotEOS;
       int nRead = super.read(buf, off, len);
-      if (nRead >= 0 && gotEOS && needChecksum()) {
+      
+      // if gotEOS was set in the previous read and checksum is enabled :
+      if (gotEOS && !eosBefore && nRead >= 0 && needChecksum()) {
         if (sentChecksumOk) {
            // this should not happen; log the error for the debugging purpose
            LOG.info(StringUtils.stringifyException(new IOException(
-             "Checksum ok was sent and should not be sent again")));  
+             "Checksum ok was sent and should not be sent again"))); 
         } else {
           //checksum is verified and there are no errors.
           checksumOk(dnSock);