HDFS-11541. Call RawErasureEncoder and RawErasureDecoder release() methods. Contributed by SammiChen.

This commit is contained in:
Rakesh Radhakrishnan 2017-03-29 11:41:48 +05:30
parent 0e6f8e4bc6
commit 84d787b9d5
5 changed files with 43 additions and 27 deletions

View File

@ -177,7 +177,9 @@ public class DFSStripedInputStream extends DFSInputStream {
@Override
public synchronized void close() throws IOException {
try {
super.close();
} finally {
if (curStripeBuf != null) {
BUFFER_POOL.putBuffer(curStripeBuf);
curStripeBuf = null;
@ -186,6 +188,8 @@ public class DFSStripedInputStream extends DFSInputStream {
BUFFER_POOL.putBuffer(parityBuf);
parityBuf = null;
}
decoder.release();
}
}
/**

View File

@ -1033,6 +1033,7 @@ public class DFSStripedOutputStream extends DFSOutputStream {
setClosed();
// shutdown executor of flushAll tasks
flushAllExecutor.shutdownNow();
encoder.release();
}
}

View File

@ -75,6 +75,7 @@ public class StripedBlockChecksumReconstructor extends StripedReconstructor {
public void reconstruct() throws IOException {
MessageDigest digester = MD5Hash.getDigester();
long maxTargetLength = getMaxTargetLength();
try {
while (requestedLen > 0 && getPositionInBlock() < maxTargetLength) {
long remaining = maxTargetLength - getPositionInBlock();
final int toReconstructLen = (int) Math
@ -98,6 +99,9 @@ public class StripedBlockChecksumReconstructor extends StripedReconstructor {
byte[] digest = digester.digest();
md5 = new MD5Hash(digest);
md5.write(checksumWriter);
} finally {
cleanup();
}
}
private long checksumWithTargetOutput(byte[] outputData, int toReconstructLen,

View File

@ -74,6 +74,7 @@ class StripedBlockReconstructor extends StripedReconstructor
metrics.incrECReconstructionBytesWritten(getBytesWritten());
getStripedReader().close();
stripedWriter.close();
cleanup();
}
}

View File

@ -253,6 +253,12 @@ abstract class StripedReconstructor {
return decoder;
}
void cleanup() {
if (decoder != null) {
decoder.release();
}
}
StripedReader getStripedReader() {
return stripedReader;
}