/** * Gets the maximum sequentially allocated striped block ID for this * filesystem */ public long getLastAllocatedStripedBlockId() { return blockGroupIdGenerator.getCurrentValue(); }
/** * Sets the maximum allocated striped block ID for this filesystem. This is * the basis for allocating new block IDs. */ public void setLastAllocatedStripedBlockId(long blockId) { blockGroupIdGenerator.skipTo(blockId); }
@Override // NumberGenerator public long nextValue() { skipTo((getCurrentValue() & ~BLOCK_GROUP_INDEX_MASK) + MAX_BLOCKS_IN_GROUP); // Make sure there's no conflict with existing random block IDs final Block b = new Block(getCurrentValue()); while (hasValidBlockInRange(b)) { skipTo(getCurrentValue() + MAX_BLOCKS_IN_GROUP); b.setBlockId(getCurrentValue()); } if (b.getBlockId() >= 0) { throw new IllegalStateException("All negative block group IDs are used, " + "growing into positive IDs, " + "which might conflict with non-erasure coded blocks."); } return getCurrentValue(); }
/** * Increments, logs and then returns the block ID */ long nextBlockId(BlockType blockType) { switch(blockType) { case CONTIGUOUS: return blockIdGenerator.nextValue(); case STRIPED: return blockGroupIdGenerator.nextValue(); default: throw new IllegalArgumentException( "nextBlockId called with an unsupported BlockType"); } }
public BlockIdManager(BlockManager blockManager) { this.legacyGenerationStampLimit = HdfsConstants.GRANDFATHER_GENERATION_STAMP; this.blockIdGenerator = new SequentialBlockIdGenerator(blockManager); this.blockGroupIdGenerator = new SequentialBlockGroupIdGenerator(blockManager); }
void clear() { legacyGenerationStamp.setCurrentValue(GenerationStamp.LAST_RESERVED_STAMP); generationStamp.setCurrentValue(GenerationStamp.LAST_RESERVED_STAMP); getBlockIdGenerator().setCurrentValue(SequentialBlockIdGenerator .LAST_RESERVED_BLOCK_ID); getBlockGroupIdGenerator().setCurrentValue(Long.MIN_VALUE); legacyGenerationStampLimit = HdfsConstants.GRANDFATHER_GENERATION_STAMP; }