private void truncatePartialBlock(List<BlockRecord> rurList, long safeLength) throws IOException { int cellSize = ecPolicy.getCellSize(); int dataBlkNum = ecPolicy.getNumDataUnits(); List<DatanodeID> failedList = new ArrayList<>(); for (BlockRecord r : rurList) { int blockIndex = (int) (r.rInfo.getBlockId() & BLOCK_GROUP_INDEX_MASK); long newSize = getInternalBlockLength(safeLength, cellSize, dataBlkNum, blockIndex); try { r.updateReplicaUnderRecovery(bpid, recoveryId, r.rInfo.getBlockId(), newSize); } catch (IOException e) { InterDatanodeProtocol.LOG.warn("Failed to updateBlock (newblock=" + ", datanode=" + r.id + ")", e); failedList.add(r.id); } } // If any of the data-nodes failed, the recovery fails, because // we never know the actual state of the replica on failed data-nodes. // The recovery should be started over. if (!failedList.isEmpty()) { throw new IOException("Cannot recover " + block + ", the following datanodes failed: " + failedList); } }
int blockIndex = (int) (r.rInfo.getBlockId() & BLOCK_GROUP_INDEX_MASK); long newSize = getInternalBlockLength(safeLength, ecPolicy.getCellSize(), dataBlkNum, blockIndex); int index = (int) (r.rInfo.getBlockId() & HdfsServerConstants.BLOCK_GROUP_INDEX_MASK); newLocs[index] = r.id;
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 { rri.getBlockId(), newlength); assertTrue(r != null); assertTrue(r.getStorageUuid() != null);