|
@@ -70,7 +70,8 @@ public class DFSStripedInputStream extends DFSInputStream {
|
|
private final int groupSize;
|
|
private final int groupSize;
|
|
/** the buffer for a complete stripe. */
|
|
/** the buffer for a complete stripe. */
|
|
private ByteBuffer curStripeBuf;
|
|
private ByteBuffer curStripeBuf;
|
|
- private ByteBuffer parityBuf;
|
|
|
|
|
|
+ @VisibleForTesting
|
|
|
|
+ protected ByteBuffer parityBuf;
|
|
private final ErasureCodingPolicy ecPolicy;
|
|
private final ErasureCodingPolicy ecPolicy;
|
|
private RawErasureDecoder decoder;
|
|
private RawErasureDecoder decoder;
|
|
|
|
|
|
@@ -129,7 +130,7 @@ public class DFSStripedInputStream extends DFSInputStream {
|
|
curStripeRange = new StripeRange(0, 0);
|
|
curStripeRange = new StripeRange(0, 0);
|
|
}
|
|
}
|
|
|
|
|
|
- protected ByteBuffer getParityBuffer() {
|
|
|
|
|
|
+ protected synchronized ByteBuffer getParityBuffer() {
|
|
if (parityBuf == null) {
|
|
if (parityBuf == null) {
|
|
parityBuf = BUFFER_POOL.getBuffer(useDirectBuffer(),
|
|
parityBuf = BUFFER_POOL.getBuffer(useDirectBuffer(),
|
|
cellSize * parityBlkNum);
|
|
cellSize * parityBlkNum);
|
|
@@ -554,4 +555,17 @@ public class DFSStripedInputStream extends DFSInputStream {
|
|
throw new UnsupportedOperationException(
|
|
throw new UnsupportedOperationException(
|
|
"Not support enhanced byte buffer access.");
|
|
"Not support enhanced byte buffer access.");
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public synchronized void unbuffer() {
|
|
|
|
+ super.unbuffer();
|
|
|
|
+ if (curStripeBuf != null) {
|
|
|
|
+ BUFFER_POOL.putBuffer(curStripeBuf);
|
|
|
|
+ curStripeBuf = null;
|
|
|
|
+ }
|
|
|
|
+ if (parityBuf != null) {
|
|
|
|
+ BUFFER_POOL.putBuffer(parityBuf);
|
|
|
|
+ parityBuf = null;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|