public boolean isLegacyBlock(Block block) { return blockIdManager.isLegacyBlock(block); }
/** * Return true if the block is a striped block. * * Before HDFS-4645, block ID was randomly generated (legacy), so it is * possible that legacy block ID to be negative, which should not be * considered as striped block ID. * * @see #isLegacyBlock(Block) detecting legacy block IDs. */ public boolean isStripedBlock(Block block) { return isStripedBlockID(block.getBlockId()) && !isLegacyBlock(block); }
boolean isGenStampInFuture(Block block) { if (isLegacyBlock(block)) { return block.getGenerationStamp() > getLegacyGenerationStamp(); } else { return block.getGenerationStamp() > getGenerationStamp(); } }
public boolean isGenStampInFuture(Block block) { if (isLegacyBlock(block)) { return block.getGenerationStamp() > getGenerationStampV1(); } else { return block.getGenerationStamp() > getGenerationStampV2(); } }
public boolean isGenStampInFuture(Block block) { if (isLegacyBlock(block)) { return block.getGenerationStamp() > getGenerationStampV1(); } else { return block.getGenerationStamp() > getGenerationStampV2(); } }
/** * Test that the block type (legacy or not) can be correctly detected * based on its generation stamp. * * @throws IOException */ @Test public void testBlockTypeDetection() throws IOException { // Setup a mock object and stub out a few routines to // retrieve the generation stamp counters. BlockIdManager bid = mock(BlockIdManager.class); final long maxGenStampForLegacyBlocks = 10000; when(bid.getGenerationStampV1Limit()) .thenReturn(maxGenStampForLegacyBlocks); Block legacyBlock = spy(new Block()); when(legacyBlock.getGenerationStamp()) .thenReturn(maxGenStampForLegacyBlocks/2); Block newBlock = spy(new Block()); when(newBlock.getGenerationStamp()) .thenReturn(maxGenStampForLegacyBlocks+1); // Make sure that isLegacyBlock() can correctly detect // legacy and new blocks. when(bid.isLegacyBlock(any(Block.class))).thenCallRealMethod(); assertThat(bid.isLegacyBlock(legacyBlock), is(true)); assertThat(bid.isLegacyBlock(newBlock), is(false)); }
block.setGenerationStamp(nextGenerationStamp(blockIdManager.isLegacyBlock(block.getLocalBlock()))); locatedBlock = new LocatedBlock(block, new DatanodeInfo[0]); blockManager.setBlockToken(locatedBlock, AccessMode.WRITE);
block.setGenerationStamp(nextGenerationStamp(blockIdManager.isLegacyBlock(block.getLocalBlock()))); locatedBlock = new LocatedBlock(block, new DatanodeInfo[0]); blockManager.setBlockToken(locatedBlock, AccessMode.WRITE);
long blockRecoveryId = nextGenerationStamp(blockIdManager.isLegacyBlock(uc)); lease = reassignLease(lease, src, recoveryLeaseHolder, pendingFile); if(copyOnTruncate) {
newBlock = (shouldCopyOnTruncate) ? createNewBlock() : new Block(oldBlock.getBlockId(), oldBlock.getNumBytes(), nextGenerationStamp(blockIdManager.isLegacyBlock(oldBlock)));
long blockRecoveryId = nextGenerationStamp(blockIdManager.isLegacyBlock(uc)); lease = reassignLease(lease, src, recoveryLeaseHolder, pendingFile); if(copyOnTruncate) {
newBlock = (shouldCopyOnTruncate) ? createNewBlock() : new Block(oldBlock.getBlockId(), oldBlock.getNumBytes(), nextGenerationStamp(blockIdManager.isLegacyBlock(oldBlock)));