HDFS-8550. Erasure Coding: Fix FindBugs Multithreaded correctness Warning. Contributed by Rakesh R.

Change-Id: Ic248999a7f8e5e740d49c9b10abcf16f66dd0f98
This commit is contained in:
Zhe Zhang 2015-09-18 11:04:06 -07:00
parent 82a88b92b4
commit c457095206
4 changed files with 12 additions and 8 deletions

View File

@ -435,3 +435,6 @@
HDFS-9086. Rename dfs.datanode.stripedread.threshold.millis to HDFS-9086. Rename dfs.datanode.stripedread.threshold.millis to
dfs.datanode.stripedread.timeout.millis. (wang via zhz) dfs.datanode.stripedread.timeout.millis. (wang via zhz)
HDFS-8550. Erasure Coding: Fix FindBugs Multithreaded correctness Warning.
(Rakesh R via zhz)

View File

@ -112,7 +112,6 @@ public class DFSStripedInputStream extends DFSInputStream {
* offsets for all the block readers so that we can skip data if necessary. * offsets for all the block readers so that we can skip data if necessary.
*/ */
long blockReaderOffset; long blockReaderOffset;
LocatedBlock targetBlock;
/** /**
* We use this field to indicate whether we should use this reader. In case * We use this field to indicate whether we should use this reader. In case
* we hit any issue with this reader, we set this field to true and avoid * we hit any issue with this reader, we set this field to true and avoid
@ -120,10 +119,8 @@ public class DFSStripedInputStream extends DFSInputStream {
*/ */
boolean shouldSkip = false; boolean shouldSkip = false;
BlockReaderInfo(BlockReader reader, LocatedBlock targetBlock, BlockReaderInfo(BlockReader reader, DatanodeInfo dn, long offset) {
DatanodeInfo dn, long offset) {
this.reader = reader; this.reader = reader;
this.targetBlock = targetBlock;
this.datanode = dn; this.datanode = dn;
this.blockReaderOffset = offset; this.blockReaderOffset = offset;
} }
@ -649,8 +646,8 @@ public class DFSStripedInputStream extends DFSInputStream {
} }
} }
if (reader != null) { if (reader != null) {
readerInfos[chunkIndex] = new BlockReaderInfo(reader, block, readerInfos[chunkIndex] = new BlockReaderInfo(reader, dnInfo.info,
dnInfo.info, alignedStripe.getOffsetInBlock()); alignedStripe.getOffsetInBlock());
return true; return true;
} }
} }
@ -826,7 +823,10 @@ public class DFSStripedInputStream extends DFSInputStream {
void prepareDecodeInputs() { void prepareDecodeInputs() {
if (decodeInputs == null) { if (decodeInputs == null) {
decodeInputs = new ByteBuffer[dataBlkNum + parityBlkNum]; decodeInputs = new ByteBuffer[dataBlkNum + parityBlkNum];
ByteBuffer cur = curStripeBuf.duplicate(); final ByteBuffer cur;
synchronized (DFSStripedInputStream.this) {
cur = curStripeBuf.duplicate();
}
StripedBlockUtil.VerticalRange range = alignedStripe.range; StripedBlockUtil.VerticalRange range = alignedStripe.range;
for (int i = 0; i < dataBlkNum; i++) { for (int i = 0; i < dataBlkNum; i++) {
cur.limit(cur.capacity()); cur.limit(cur.capacity());

View File

@ -971,6 +971,7 @@ public class BlockManager implements BlockStatsMXBean {
if (isBlockTokenEnabled()) { if (isBlockTokenEnabled()) {
// Use cached UGI if serving RPC calls. // Use cached UGI if serving RPC calls.
if (b.isStriped()) { if (b.isStriped()) {
Preconditions.checkState(b instanceof LocatedStripedBlock);
LocatedStripedBlock sb = (LocatedStripedBlock) b; LocatedStripedBlock sb = (LocatedStripedBlock) b;
int[] indices = sb.getBlockIndices(); int[] indices = sb.getBlockIndices();
Token<BlockTokenIdentifier>[] blockTokens = new Token[indices.length]; Token<BlockTokenIdentifier>[] blockTokens = new Token[indices.length];

View File

@ -372,7 +372,7 @@ public class StripedBlockUtil {
// Step 4: calculate each chunk's position in destination buffer. Since the // Step 4: calculate each chunk's position in destination buffer. Since the
// whole read range is within a single stripe, the logic is simpler here. // whole read range is within a single stripe, the logic is simpler here.
int bufOffset = (int) (rangeStartInBlockGroup % (cellSize * dataBlkNum)); int bufOffset = (int) (rangeStartInBlockGroup % ((long) cellSize * dataBlkNum));
for (StripingCell cell : cells) { for (StripingCell cell : cells) {
long cellStart = cell.idxInInternalBlk * cellSize + cell.offset; long cellStart = cell.idxInInternalBlk * cellSize + cell.offset;
long cellEnd = cellStart + cell.size - 1; long cellEnd = cellStart + cell.size - 1;