/** * TODO: the current implementation depends on the assumption that the * parity cells are only generated based on the full stripe. This is not * true after we support hflush. */ @VisibleForTesting long getSafeLength(Map<Long, BlockRecord> syncBlocks) { final int dataBlkNum = ecPolicy.getNumDataUnits(); Preconditions.checkArgument(syncBlocks.size() >= dataBlkNum); long[] blockLengths = new long[syncBlocks.size()]; int i = 0; for (BlockRecord r : syncBlocks.values()) { ReplicaRecoveryInfo rInfo = r.getReplicaRecoveryInfo(); blockLengths[i++] = rInfo.getNumBytes(); } return StripedBlockUtil.getSafeLength(ecPolicy, blockLengths); }
@Override public String toString() { return super.toString() + "[numBytes=" + this.getNumBytes() + ",originalReplicaState=" + this.originalState.name() + "]"; } }
if (info != null && info.getGenerationStamp() >= block.getGenerationStamp() && info.getNumBytes() > 0) {
long finalizedLength = -1; for (BlockRecord r : syncList) { assert r.rInfo.getNumBytes() > 0 : "zero length replica"; ReplicaState rState = r.rInfo.getOriginalReplicaState(); if (rState.getValue() < bestState.getValue()) { if (finalizedLength > 0 && finalizedLength != r.rInfo.getNumBytes()) { throw new IOException("Inconsistent size of finalized replicas. " + "Replica " + r.rInfo + " expected size: " + finalizedLength); finalizedLength = r.rInfo.getNumBytes(); if (rState == ReplicaState.FINALIZED || rState == ReplicaState.RBW && r.rInfo.getNumBytes() == finalizedLength) { participatingList.add(r); LOG.debug("syncBlock replicaInfo: block=" + block + ", from datanode " + r.id + ", receivedState=" + rState.name() + ", receivedLength=" + r.rInfo.getNumBytes() + ", bestState=FINALIZED, finalizedLength=" + finalizedLength); ReplicaState rState = r.rInfo.getOriginalReplicaState(); if(rState == bestState) { minLength = Math.min(minLength, r.rInfo.getNumBytes()); participatingList.add(r); LOG.debug("syncBlock replicaInfo: block=" + block + ", from datanode " + r.id + ", receivedState=" + rState.name() +
info.getNumBytes() > 0) { final BlockRecord existing = syncBlocks.get(blockId); if (existing == null || info.getNumBytes() > existing.rInfo.getNumBytes()) { long newSize = getInternalBlockLength(safeLength, ecPolicy.getCellSize(), dataBlkNum, blockIndex); if (r.rInfo.getNumBytes() >= newSize) { rurList.add(r);
long finalizedLength = -1; for(BlockRecord r : syncList) { assert r.rInfo.getNumBytes() > 0 : "zero length replica"; ReplicaState rState = r.rInfo.getOriginalReplicaState(); if(rState.getValue() < bestState.getValue()) bestState = rState; if(rState == ReplicaState.FINALIZED) { if(finalizedLength > 0 && finalizedLength != r.rInfo.getNumBytes()) throw new IOException("Inconsistent size of finalized replicas. " + "Replica " + r.rInfo + " expected size: " + finalizedLength); finalizedLength = r.rInfo.getNumBytes(); if(rState == ReplicaState.FINALIZED || rState == ReplicaState.RBW && r.rInfo.getNumBytes() == finalizedLength) participatingList.add(r); ReplicaState rState = r.rInfo.getOriginalReplicaState(); if(rState == bestState) { minLength = Math.min(minLength, r.rInfo.getNumBytes()); participatingList.add(r);
long finalizedLength = -1; for(BlockRecord r : syncList) { assert r.rInfo.getNumBytes() > 0 : "zero length replica"; ReplicaState rState = r.rInfo.getOriginalReplicaState(); if(rState.getValue() < bestState.getValue()) bestState = rState; if(rState == ReplicaState.FINALIZED) { if(finalizedLength > 0 && finalizedLength != r.rInfo.getNumBytes()) throw new IOException("Inconsistent size of finalized replicas. " + "Replica " + r.rInfo + " expected size: " + finalizedLength); finalizedLength = r.rInfo.getNumBytes(); if(rState == ReplicaState.FINALIZED || rState == ReplicaState.RBW && r.rInfo.getNumBytes() == finalizedLength) participatingList.add(r); ReplicaState rState = r.rInfo.getOriginalReplicaState(); if(rState == bestState) { minLength = Math.min(minLength, r.rInfo.getNumBytes()); participatingList.add(r);
if (info != null && info.getGenerationStamp() >= block.getGenerationStamp() && info.getNumBytes() > 0) { syncList.add(new BlockRecord(id, datanode, info));
if (info != null && info.getGenerationStamp() >= block.getGenerationStamp() && info.getNumBytes() > 0) { syncList.add(new BlockRecord(id, datanode, info));
private static void assertEquals(ReplicaInfo originalInfo, ReplicaRecoveryInfo recoveryInfo) { Assert.assertEquals(originalInfo.getBlockId(), recoveryInfo.getBlockId()); Assert.assertEquals(originalInfo.getGenerationStamp(), recoveryInfo.getGenerationStamp()); Assert.assertEquals(originalInfo.getBytesOnDisk(), recoveryInfo.getNumBytes()); Assert.assertEquals(originalInfo.getState(), recoveryInfo.getOriginalReplicaState()); }
private static void assertEquals(ReplicaInfo originalInfo, ReplicaRecoveryInfo recoveryInfo) { Assert.assertEquals(originalInfo.getBlockId(), recoveryInfo.getBlockId()); Assert.assertEquals(originalInfo.getGenerationStamp(), recoveryInfo.getGenerationStamp()); Assert.assertEquals(originalInfo.getBytesOnDisk(), recoveryInfo.getNumBytes()); Assert.assertEquals(originalInfo.getState(), recoveryInfo.getOriginalReplicaState()); }
final Block tmp = new Block(rri.getBlockId(), rri.getNumBytes() - 1, rri.getGenerationStamp()); try {
.getBlockId(), rri.getNumBytes() - 1, rri.getGenerationStamp()); try {