/** * Get the meta info of a block stored in volumeMap. Block is looked up * without matching the generation stamp. * @param bpid block pool Id * @param blkid block Id * @return the meta replica information; null if block was not found * @throws ReplicaNotFoundException if no entry is in the map or * there is a generation stamp mismatch */ @VisibleForTesting ReplicaInfo getReplicaInfo(String bpid, long blkid) throws ReplicaNotFoundException { ReplicaInfo info = volumeMap.get(bpid, blkid); if (info == null) { throw new ReplicaNotFoundException( ReplicaNotFoundException.NON_EXISTENT_REPLICA + bpid + ":" + blkid); } return info; }
+ blocks[TEMPORARY]); } catch (ReplicaNotFoundException e) { Assert.assertTrue(e.getMessage().startsWith( ReplicaNotFoundException.UNFINALIZED_AND_NONRBW_REPLICA)); Assert.fail("Should not have recovered close an RWR replica" + blocks[RWR]); } catch (ReplicaNotFoundException e) { Assert.assertTrue(e.getMessage().startsWith( ReplicaNotFoundException.UNFINALIZED_AND_NONRBW_REPLICA)); Assert.fail("Should not have recovered close an RUR replica" + blocks[RUR]); } catch (ReplicaNotFoundException e) { Assert.assertTrue(e.getMessage().startsWith( ReplicaNotFoundException.UNFINALIZED_AND_NONRBW_REPLICA)); blocks[NON_EXISTENT]); } catch (ReplicaNotFoundException e) { Assert.assertTrue(e.getMessage().startsWith( ReplicaNotFoundException.NON_EXISTENT_REPLICA));
blocks[FINALIZED]); } catch (ReplicaNotFoundException e) { Assert.assertTrue(e.getMessage().startsWith( ReplicaNotFoundException.NON_RBW_REPLICA)); blocks[TEMPORARY]); } catch (ReplicaNotFoundException e) { Assert.assertTrue(e.getMessage().startsWith( ReplicaNotFoundException.NON_RBW_REPLICA)); Assert.fail("Should not have recovered a RWR replica " + blocks[RWR]); } catch (ReplicaNotFoundException e) { Assert.assertTrue(e.getMessage().startsWith( ReplicaNotFoundException.NON_RBW_REPLICA)); Assert.fail("Should not have recovered a RUR replica " + blocks[RUR]); } catch (ReplicaNotFoundException e) { Assert.assertTrue(e.getMessage().startsWith( ReplicaNotFoundException.NON_RBW_REPLICA)); } catch (ReplicaNotFoundException e) { Assert.assertTrue( e.getMessage().contains(ReplicaNotFoundException.NON_EXISTENT_REPLICA));
private static Replica getReplica(ExtendedBlock block, DataNode datanode) throws ReplicaNotFoundException { Replica replica = datanode.data.getReplica(block.getBlockPoolId(), block.getBlockId()); if (replica == null) { throw new ReplicaNotFoundException(block); } return replica; }
} catch (ReplicaNotFoundException e) { Assert.assertEquals(ReplicaNotFoundException.UNFINALIZED_REPLICA + blocks[TEMPORARY], e.getMessage()); } catch (ReplicaNotFoundException e) { Assert.assertEquals(ReplicaNotFoundException.UNFINALIZED_REPLICA + blocks[RBW], e.getMessage()); } catch (ReplicaNotFoundException e) { Assert.assertEquals(ReplicaNotFoundException.UNFINALIZED_REPLICA + blocks[RWR], e.getMessage()); } catch (ReplicaNotFoundException e) { Assert.assertEquals(ReplicaNotFoundException.UNFINALIZED_REPLICA + blocks[RUR], e.getMessage()); } catch (ReplicaNotFoundException e) { Assert.assertEquals(ReplicaNotFoundException.NON_EXISTENT_REPLICA + blocks[NON_EXISTENT], e.getMessage()); + blocks[TEMPORARY]); } catch (ReplicaNotFoundException e) { Assert.assertTrue(e.getMessage().startsWith( ReplicaNotFoundException.UNFINALIZED_AND_NONRBW_REPLICA)); Assert.fail("Should not have appended to an RWR replica" + blocks[RWR]); } catch (ReplicaNotFoundException e) { Assert.assertTrue(e.getMessage().startsWith( ReplicaNotFoundException.UNFINALIZED_AND_NONRBW_REPLICA));
/** * Get the meta info of a block stored in volumeMap. To find a block, * block pool Id, block Id and generation stamp must match. * @param b extended block * @return the meta replica information * @throws ReplicaNotFoundException if no entry is in the map or * there is a generation stamp mismatch */ ReplicaInfo getReplicaInfo(ExtendedBlock b) throws ReplicaNotFoundException { ReplicaInfo info = volumeMap.get(b.getBlockPoolId(), b.getLocalBlock()); if (info == null) { if (volumeMap.get(b.getBlockPoolId(), b.getLocalBlock().getBlockId()) == null) { throw new ReplicaNotFoundException( ReplicaNotFoundException.NON_EXISTENT_REPLICA + b); } else { throw new ReplicaNotFoundException( ReplicaNotFoundException.UNEXPECTED_GS_REPLICA + b); } } return info; }
+ blocks[TEMPORARY]); } catch (ReplicaNotFoundException e) { Assert.assertTrue(e.getMessage().startsWith( ReplicaNotFoundException.UNFINALIZED_AND_NONRBW_REPLICA)); Assert.fail("Should not have recovered close an RWR replica" + blocks[RWR]); } catch (ReplicaNotFoundException e) { Assert.assertTrue(e.getMessage().startsWith( ReplicaNotFoundException.UNFINALIZED_AND_NONRBW_REPLICA)); Assert.fail("Should not have recovered close an RUR replica" + blocks[RUR]); } catch (ReplicaNotFoundException e) { Assert.assertTrue(e.getMessage().startsWith( ReplicaNotFoundException.UNFINALIZED_AND_NONRBW_REPLICA)); blocks[NON_EXISTENT]); } catch (ReplicaNotFoundException e) { Assert.assertTrue(e.getMessage().startsWith( ReplicaNotFoundException.NON_EXISTENT_REPLICA));
b.getLocalBlock()); if (replicaInfo == null) { throw new ReplicaNotFoundException(b);
blocks[FINALIZED]); } catch (ReplicaNotFoundException e) { Assert.assertTrue(e.getMessage().startsWith( ReplicaNotFoundException.NON_RBW_REPLICA)); blocks[TEMPORARY]); } catch (ReplicaNotFoundException e) { Assert.assertTrue(e.getMessage().startsWith( ReplicaNotFoundException.NON_RBW_REPLICA)); Assert.fail("Should not have recovered a RWR replica " + blocks[RWR]); } catch (ReplicaNotFoundException e) { Assert.assertTrue(e.getMessage().startsWith( ReplicaNotFoundException.NON_RBW_REPLICA)); Assert.fail("Should not have recovered a RUR replica " + blocks[RUR]); } catch (ReplicaNotFoundException e) { Assert.assertTrue(e.getMessage().startsWith( ReplicaNotFoundException.NON_RBW_REPLICA)); } catch (ReplicaNotFoundException e) { Assert.assertTrue( e.getMessage().contains(ReplicaNotFoundException.NON_EXISTENT_REPLICA));
@Override // FsDatasetSpi public BlockLocalPathInfo getBlockLocalPathInfo(ExtendedBlock block) throws IOException { try (AutoCloseableLock lock = datasetLock.acquire()) { final Replica replica = volumeMap.get(block.getBlockPoolId(), block.getBlockId()); if (replica == null) { throw new ReplicaNotFoundException(block); } if (replica.getGenerationStamp() < block.getGenerationStamp()) { throw new IOException( "Replica generation stamp < block generation stamp, block=" + block + ", replica=" + replica); } else if (replica.getGenerationStamp() > block.getGenerationStamp()) { block.setGenerationStamp(replica.getGenerationStamp()); } } ReplicaInfo r = getBlockReplica(block); File blockFile = new File(r.getBlockURI()); File metaFile = new File(r.getMetadataURI()); BlockLocalPathInfo info = new BlockLocalPathInfo(block, blockFile.getAbsolutePath(), metaFile.toString()); return info; }
} catch (ReplicaNotFoundException e) { Assert.assertEquals(ReplicaNotFoundException.UNFINALIZED_REPLICA + blocks[TEMPORARY], e.getMessage()); } catch (ReplicaNotFoundException e) { Assert.assertEquals(ReplicaNotFoundException.UNFINALIZED_REPLICA + blocks[RBW], e.getMessage()); } catch (ReplicaNotFoundException e) { Assert.assertEquals(ReplicaNotFoundException.UNFINALIZED_REPLICA + blocks[RWR], e.getMessage()); } catch (ReplicaNotFoundException e) { Assert.assertEquals(ReplicaNotFoundException.UNFINALIZED_REPLICA + blocks[RUR], e.getMessage()); } catch (ReplicaNotFoundException e) { Assert.assertEquals(ReplicaNotFoundException.NON_EXISTENT_REPLICA + blocks[NON_EXISTENT], e.getMessage()); + blocks[TEMPORARY]); } catch (ReplicaNotFoundException e) { Assert.assertTrue(e.getMessage().startsWith( ReplicaNotFoundException.UNFINALIZED_AND_NONRBW_REPLICA)); Assert.fail("Should not have appended to an RWR replica" + blocks[RWR]); } catch (ReplicaNotFoundException e) { Assert.assertTrue(e.getMessage().startsWith( ReplicaNotFoundException.UNFINALIZED_AND_NONRBW_REPLICA));
@Override // FsDatasetSpi public ReplicaHandler recoverRbw( ExtendedBlock b, long newGS, long minBytesRcvd, long maxBytesRcvd) throws IOException { LOG.info("Recover RBW replica " + b); while (true) { try { try (AutoCloseableLock lock = datasetLock.acquire()) { ReplicaInfo replicaInfo = getReplicaInfo(b.getBlockPoolId(), b.getBlockId()); // check the replica's state if (replicaInfo.getState() != ReplicaState.RBW) { throw new ReplicaNotFoundException( ReplicaNotFoundException.NON_RBW_REPLICA + replicaInfo); } ReplicaInPipeline rbw = (ReplicaInPipeline)replicaInfo; if (!rbw.attemptToSetWriter(null, Thread.currentThread())) { throw new MustStopExistingWriter(rbw); } LOG.info("At " + datanode.getDisplayName() + ", Recovering " + rbw); return recoverRbwImpl(rbw, b, newGS, minBytesRcvd, maxBytesRcvd); } } catch (MustStopExistingWriter e) { e.getReplicaInPipeline().stopWriter( datanode.getDnConf().getXceiverStopTimeout()); } } }
/** * Moves a given block from one volume to another volume. This is used by disk * balancer. * * @param block - ExtendedBlock * @param destination - Destination volume * @return Old replica info */ @Override public ReplicaInfo moveBlockAcrossVolumes(ExtendedBlock block, FsVolumeSpi destination) throws IOException { ReplicaInfo replicaInfo = getReplicaInfo(block); if (replicaInfo.getState() != ReplicaState.FINALIZED) { throw new ReplicaNotFoundException( ReplicaNotFoundException.UNFINALIZED_REPLICA + block); } FsVolumeReference volumeRef = null; try (AutoCloseableLock lock = datasetLock.acquire()) { volumeRef = destination.obtainReference(); } try { moveBlock(block, replicaInfo, volumeRef); } finally { if (volumeRef != null) { volumeRef.close(); } } return replicaInfo; }
LOG.info("Appending to " + replicaInfo); if (replicaInfo.getState() != ReplicaState.FINALIZED) { throw new ReplicaNotFoundException( ReplicaNotFoundException.UNFINALIZED_REPLICA + b);
throw new ReplicaNotFoundException( ReplicaNotFoundException.UNFINALIZED_AND_NONRBW_REPLICA + replicaInfo); if (replicaGenerationStamp < b.getGenerationStamp() || replicaGenerationStamp > newGS) { throw new ReplicaNotFoundException( ReplicaNotFoundException.UNEXPECTED_GS_REPLICA + replicaGenerationStamp + ". Expected GS range is [" + b.getGenerationStamp() + ", " +
if (replicaGenerationStamp < b.getGenerationStamp() || replicaGenerationStamp > newGS) { throw new ReplicaNotFoundException( ReplicaNotFoundException.UNEXPECTED_GS_REPLICA + b + ". Expected GS range is [" + b.getGenerationStamp() + ", " + long numBytes = rbw.getNumBytes(); if (bytesAcked < minBytesRcvd || numBytes > maxBytesRcvd) { throw new ReplicaNotFoundException("Unmatched length replica " + rbw + ": BytesAcked = " + bytesAcked + " BytesRcvd = " + numBytes + " are not in the range of [" + throw new ReplicaNotFoundException("Found fewer bytesOnDisk than " + "bytesAcked for replica " + rbw);
throw new ReplicaNotFoundException( ReplicaNotFoundException.NON_EXISTENT_REPLICA + b);
ReplicaInfo replicaInfo = getReplicaInfo(block); if (replicaInfo.getState() != ReplicaState.FINALIZED) { throw new ReplicaNotFoundException( ReplicaNotFoundException.UNFINALIZED_REPLICA + block);
throw new ReplicaNotFoundException(oldBlock);
/** * Get the meta info of a block stored in volumeMap. Block is looked up * without matching the generation stamp. * @param bpid block pool Id * @param blkid block Id * @return the meta replica information; null if block was not found * @throws ReplicaNotFoundException if no entry is in the map or * there is a generation stamp mismatch */ private ReplicaInfo getReplicaInfo(String bpid, long blkid) throws ReplicaNotFoundException { ReplicaInfo info = volumeMap.get(bpid, blkid); if (info == null) { throw new ReplicaNotFoundException( ReplicaNotFoundException.NON_EXISTENT_REPLICA + bpid + ":" + blkid); } return info; }