HDFS-15709. Socket file descriptor leak in StripedBlockChecksumReconstructor. (#2518)
(cherry picked from commit 40f7543a6d
)
This commit is contained in:
parent
6a5864ee4a
commit
edd9b659ca
@ -700,14 +700,14 @@ private void recalculateChecksum(int errBlkIndex, long blockLength)
|
||||
blockGroup, ecPolicy, blockIndices, datanodes, errIndices);
|
||||
BlockChecksumType groupChecksumType =
|
||||
getBlockChecksumOptions().getBlockChecksumType();
|
||||
final StripedBlockChecksumReconstructor checksumRecon =
|
||||
try (StripedBlockChecksumReconstructor checksumRecon =
|
||||
groupChecksumType == BlockChecksumType.COMPOSITE_CRC ?
|
||||
new StripedBlockChecksumCompositeCrcReconstructor(
|
||||
getDatanode().getErasureCodingWorker(), stripedReconInfo,
|
||||
blockChecksumBuf, blockLength) :
|
||||
new StripedBlockChecksumMd5CrcReconstructor(
|
||||
getDatanode().getErasureCodingWorker(), stripedReconInfo,
|
||||
blockChecksumBuf, blockLength);
|
||||
blockChecksumBuf, blockLength)) {
|
||||
checksumRecon.reconstruct();
|
||||
|
||||
DataChecksum checksum = checksumRecon.getChecksum();
|
||||
@ -719,6 +719,7 @@ private void recalculateChecksum(int errBlkIndex, long blockLength)
|
||||
LOG.debug("Recalculated checksum for the block index:{}, checksum={}",
|
||||
errBlkIndex, checksumRecon.getDigestObject());
|
||||
}
|
||||
}
|
||||
|
||||
private void setOrVerifyChecksumProperties(int blockIdx, int bpc,
|
||||
final long cpb, DataChecksum.Type ct) throws IOException {
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
package org.apache.hadoop.hdfs.server.datanode.erasurecode;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
@ -32,7 +33,7 @@
|
||||
*/
|
||||
@InterfaceAudience.Private
|
||||
public abstract class StripedBlockChecksumReconstructor
|
||||
extends StripedReconstructor {
|
||||
extends StripedReconstructor implements Closeable {
|
||||
private ByteBuffer targetBuffer;
|
||||
private final byte[] targetIndices;
|
||||
|
||||
@ -73,7 +74,6 @@ private void init() throws IOException {
|
||||
public void reconstruct() throws IOException {
|
||||
prepareDigester();
|
||||
long maxTargetLength = getMaxTargetLength();
|
||||
try {
|
||||
while (requestedLen > 0 && getPositionInBlock() < maxTargetLength) {
|
||||
long remaining = maxTargetLength - getPositionInBlock();
|
||||
final int toReconstructLen = (int) Math
|
||||
@ -95,9 +95,6 @@ public void reconstruct() throws IOException {
|
||||
}
|
||||
|
||||
commitDigest();
|
||||
} finally {
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -222,4 +219,10 @@ private static byte[] getBufferArray(ByteBuffer buffer) {
|
||||
}
|
||||
return buff;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
getStripedReader().close();
|
||||
cleanup();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user