Explorar o código

Merge -r 537938:537939 from trunk to 0.13 branch. Fixes: HADOOP-1345.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/branches/branch-0.13@537941 13f79535-47bb-0310-9956-ffa450edef68
Doug Cutting %!s(int64=18) %!d(string=hai) anos
pai
achega
8ef816748e
Modificáronse 2 ficheiros con 10 adicións e 5 borrados
  1. 3 0
      CHANGES.txt
  2. 7 5
      src/java/org/apache/hadoop/fs/ChecksumFileSystem.java

+ 3 - 0
CHANGES.txt

@@ -375,6 +375,9 @@ Branch 0.13 (unreleased changes)
 111. HADOOP-1350.  Fix shuffle performance problem caused by forcing
      chunked encoding of map outputs.  (Devaraj Das via cutting)
 
+112. HADOOP-1345.  Fix HDFS to correctly retry another replica when a
+     checksum error is encountered.  (Hairong Kuang via cutting)
+
 
 Release 0.12.3 - 2007-04-06
 

+ 7 - 5
src/java/org/apache/hadoop/fs/ChecksumFileSystem.java

@@ -134,13 +134,17 @@ public abstract class ChecksumFileSystem extends FilterFileSystem {
       }
     }
 
+    private long getChecksumFilePos( long dataPos ) {
+      return HEADER_LENGTH + 4*(dataPos/bytesPerSum);
+    }
+    
     public void seek(long desired) throws IOException {
       // seek to a checksum boundary
       long checksumBoundary = desired/bytesPerSum*bytesPerSum;
       if (checksumBoundary != getPos()) {
         datas.seek(checksumBoundary);
         if (sums != null) {
-          sums.seek(HEADER_LENGTH + 4*(checksumBoundary/bytesPerSum));
+          sums.seek(getChecksumFilePos(checksumBoundary));
         }
       }
       
@@ -226,13 +230,11 @@ public abstract class ChecksumFileSystem extends FilterFileSystem {
               throw ce;
             }
             
-            sums.seek(oldSumsPos);
-            datas.seek(oldPos);
-            
             if (seekToNewSource(oldPos)) {
               // Since at least one of the sources is different, 
               // the read might succeed, so we'll retry.
               retry = true;
+              seek(oldPos); //make sure Checksum sum's value gets restored
             } else {
               // Neither the data stream nor the checksum stream are being read
               // from different sources, meaning we'll still get a checksum error 
@@ -320,7 +322,7 @@ public abstract class ChecksumFileSystem extends FilterFileSystem {
     @Override
     public boolean seekToNewSource(long targetPos) throws IOException {
       boolean newDataSource = datas.seekToNewSource(targetPos);
-      return sums.seekToNewSource(targetPos/bytesPerSum) || newDataSource;
+      return sums.seekToNewSource(getChecksumFilePos(targetPos)) || newDataSource;
     }
 
   }