|
@@ -75,29 +75,33 @@ public class StripedBlockChecksumReconstructor extends StripedReconstructor {
|
|
public void reconstruct() throws IOException {
|
|
public void reconstruct() throws IOException {
|
|
MessageDigest digester = MD5Hash.getDigester();
|
|
MessageDigest digester = MD5Hash.getDigester();
|
|
long maxTargetLength = getMaxTargetLength();
|
|
long maxTargetLength = getMaxTargetLength();
|
|
- while (requestedLen > 0 && getPositionInBlock() < maxTargetLength) {
|
|
|
|
- long remaining = maxTargetLength - getPositionInBlock();
|
|
|
|
- final int toReconstructLen = (int) Math
|
|
|
|
- .min(getStripedReader().getBufferSize(), remaining);
|
|
|
|
- // step1: read from minimum source DNs required for reconstruction.
|
|
|
|
- // The returned success list is the source DNs we do real read from
|
|
|
|
- getStripedReader().readMinimumSources(toReconstructLen);
|
|
|
|
-
|
|
|
|
- // step2: decode to reconstruct targets
|
|
|
|
- reconstructTargets(toReconstructLen);
|
|
|
|
-
|
|
|
|
- // step3: calculate checksum
|
|
|
|
- checksumDataLen += checksumWithTargetOutput(targetBuffer.array(),
|
|
|
|
- toReconstructLen, digester);
|
|
|
|
-
|
|
|
|
- updatePositionInBlock(toReconstructLen);
|
|
|
|
- requestedLen -= toReconstructLen;
|
|
|
|
- clearBuffers();
|
|
|
|
- }
|
|
|
|
|
|
+ try {
|
|
|
|
+ while (requestedLen > 0 && getPositionInBlock() < maxTargetLength) {
|
|
|
|
+ long remaining = maxTargetLength - getPositionInBlock();
|
|
|
|
+ final int toReconstructLen = (int) Math
|
|
|
|
+ .min(getStripedReader().getBufferSize(), remaining);
|
|
|
|
+ // step1: read from minimum source DNs required for reconstruction.
|
|
|
|
+ // The returned success list is the source DNs we do real read from
|
|
|
|
+ getStripedReader().readMinimumSources(toReconstructLen);
|
|
|
|
+
|
|
|
|
+ // step2: decode to reconstruct targets
|
|
|
|
+ reconstructTargets(toReconstructLen);
|
|
|
|
+
|
|
|
|
+ // step3: calculate checksum
|
|
|
|
+ checksumDataLen += checksumWithTargetOutput(targetBuffer.array(),
|
|
|
|
+ toReconstructLen, digester);
|
|
|
|
+
|
|
|
|
+ updatePositionInBlock(toReconstructLen);
|
|
|
|
+ requestedLen -= toReconstructLen;
|
|
|
|
+ clearBuffers();
|
|
|
|
+ }
|
|
|
|
|
|
- byte[] digest = digester.digest();
|
|
|
|
- md5 = new MD5Hash(digest);
|
|
|
|
- md5.write(checksumWriter);
|
|
|
|
|
|
+ byte[] digest = digester.digest();
|
|
|
|
+ md5 = new MD5Hash(digest);
|
|
|
|
+ md5.write(checksumWriter);
|
|
|
|
+ } finally {
|
|
|
|
+ cleanup();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
private long checksumWithTargetOutput(byte[] outputData, int toReconstructLen,
|
|
private long checksumWithTargetOutput(byte[] outputData, int toReconstructLen,
|