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

This commit is contained in:
boli2 2015-07-13 00:41:36 -04:00
parent e692c7dd92
commit f4098dfae4
4 changed files with 10 additions and 5 deletions

View File

@ -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)

View File

@ -419,7 +419,7 @@ protected synchronized void writeChunk(byte[] b, int offset, int len,
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

View File

@ -259,10 +259,10 @@ synchronized int getNumChunks() {
}
/**
* 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;
}
/**

View File

@ -389,11 +389,13 @@ private List<DFSPacket> generatePackets(
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;