Przeglądaj źródła

HDFS-8744. Erasure Coding: the number of chunks in packet is not updated when writing parity data. Contributed by Li Bo

boli2 10 lat temu
rodzic
commit
f4098dfae4

+ 3 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-EC-7285.txt

@@ -341,3 +341,6 @@
 
     HDFS-8484. Erasure coding: Two contiguous blocks occupy IDs belong to same
     striped group. (Walter Su via jing9)
+
+    HDFS-8744. Erasure Coding: the number of chunks in packet is not updated
+    when writing parity data. (Li Bo)

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSOutputStream.java

@@ -419,7 +419,7 @@ public class DFSOutputStream extends FSOutputSummer
 
     currentPacket.writeChecksum(checksum, ckoff, cklen);
     currentPacket.writeData(b, offset, len);
-    currentPacket.incNumChunks();
+    currentPacket.incNumChunks(1);
     streamer.incBytesCurBlock(len);
 
     // If packet is full, enqueue it for transmission

+ 3 - 3
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSPacket.java

@@ -259,10 +259,10 @@ public class DFSPacket {
   }
 
   /**
-   * increase the number of chunks by one
+   * increase the number of chunks by n
    */
-  synchronized void incNumChunks() {
-    numChunks++;
+  synchronized void incNumChunks(int n) {
+    numChunks += n;
   }
 
   /**

+ 3 - 1
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSStripedOutputStream.java

@@ -389,11 +389,13 @@ public class DFSStripedOutputStream extends DFSOutputStream {
       int maxBytesToPacket = p.getMaxChunks() * bytesPerChecksum;
       int toWrite = byteBuffer.remaining() > maxBytesToPacket ?
           maxBytesToPacket: byteBuffer.remaining();
-      int ckLen = ((toWrite - 1) / bytesPerChecksum + 1) * getChecksumSize();
+      int chunks = (toWrite - 1) / bytesPerChecksum + 1;
+      int ckLen = chunks * getChecksumSize();
       p.writeChecksum(checksumBuf, ckOff, ckLen);
       ckOff += ckLen;
       p.writeData(byteBuffer, toWrite);
       getCurrentStreamer().incBytesCurBlock(toWrite);
+      p.incNumChunks(chunks);
       packets.add(p);
     }
     return packets;