mBlockStore.putBlock(blockId, BlockMeta.newBuilder().setLength(length).build()); BlockInfoEntry blockInfo = BlockInfoEntry.newBuilder().setBlockId(blockId).setLength(length).build(); journalContext.append(JournalEntry.newBuilder().setBlockInfo(blockInfo).build());
@Override public void commitBlockInUFS(long blockId, long length) throws UnavailableException { LOG.debug("Commit block in ufs. blockId: {}, length: {}", blockId, length); try (JournalContext journalContext = createJournalContext(); LockResource lr = lockBlock(blockId)) { if (mBlockStore.getBlock(blockId).isPresent()) { // Block metadata already exists, so do not need to create a new one. return; } mBlockStore.putBlock(blockId, BlockMeta.newBuilder().setLength(length).build()); BlockInfoEntry blockInfo = BlockInfoEntry.newBuilder().setBlockId(blockId).setLength(length).build(); journalContext.append(JournalEntry.newBuilder().setBlockInfo(blockInfo).build()); } }
@Override public void commitBlockInUFS(long blockId, long length) throws UnavailableException { LOG.debug("Commit block in ufs. blockId: {}, length: {}", blockId, length); if (mBlocks.get(blockId) != null) { // Block metadata already exists, so do not need to create a new one. return; } // The block has not been committed previously, so add the metadata to commit the block. MasterBlockInfo block = new MasterBlockInfo(blockId, length); try (JournalContext journalContext = createJournalContext()) { synchronized (block) { if (mBlocks.putIfAbsent(blockId, block) == null) { // Successfully added the new block metadata. Append a journal entry for the new metadata. BlockInfoEntry blockInfo = BlockInfoEntry.newBuilder().setBlockId(blockId).setLength(length).build(); journalContext.append(JournalEntry.newBuilder().setBlockInfo(blockInfo).build()); } } } }
BlockInfoEntry.newBuilder().setBlockId(blockId).setLength(length).build(); journalContext.append(JournalEntry.newBuilder().setBlockInfo(blockInfo).build());
public Builder mergeFrom(alluxio.proto.journal.Block.BlockInfoEntry other) { if (other == alluxio.proto.journal.Block.BlockInfoEntry.getDefaultInstance()) return this; if (other.hasBlockId()) { setBlockId(other.getBlockId()); } if (other.hasLength()) { setLength(other.getLength()); } this.mergeUnknownFields(other.getUnknownFields()); return this; }
@Override public JournalEntry next() { if (!hasNext()) { throw new NoSuchElementException(); } MasterBlockInfo info = it.next(); BlockInfoEntry blockInfoEntry = BlockInfoEntry.newBuilder().setBlockId(info.getBlockId()) .setLength(info.getLength()).build(); return JournalEntry.newBuilder().setBlockInfo(blockInfoEntry).build(); }
public Builder mergeFrom(alluxio.proto.journal.Block.BlockInfoEntry other) { if (other == alluxio.proto.journal.Block.BlockInfoEntry.getDefaultInstance()) return this; if (other.hasBlockId()) { setBlockId(other.getBlockId()); } if (other.hasLength()) { setLength(other.getLength()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }