@Override public void processJournalEntry(JournalEntry entry) throws IOException { // TODO(gene): A better way to process entries besides a huge switch? if (entry.hasBlockContainerIdGenerator()) { mJournaledNextContainerId = (entry.getBlockContainerIdGenerator()).getNextContainerId(); mBlockContainerIdGenerator.setNextContainerId((mJournaledNextContainerId)); } else if (entry.hasDeleteBlock()) { mBlockStore.removeBlock(entry.getDeleteBlock().getBlockId()); } else if (entry.hasBlockInfo()) { BlockInfoEntry blockInfoEntry = entry.getBlockInfo(); long length = blockInfoEntry.getLength(); Optional<BlockMeta> block = mBlockStore.getBlock(blockInfoEntry.getBlockId()); if (block.isPresent()) { long oldLen = block.get().getLength(); if (oldLen != Constants.UNKNOWN_SIZE) { LOG.warn("Attempting to update block length ({}) to a different length ({}).", oldLen, length); return; } } mBlockStore.putBlock(blockInfoEntry.getBlockId(), BlockMeta.newBuilder().setLength(blockInfoEntry.getLength()).build()); } else { throw new IOException(ExceptionMessage.UNEXPECTED_JOURNAL_ENTRY.getMessage(entry)); } }
mBlockStore.putBlock(blockId, BlockMeta.newBuilder().setLength(length).build()); BlockInfoEntry blockInfo = BlockInfoEntry.newBuilder().setBlockId(blockId).setLength(length).build(); journalContext.append(JournalEntry.newBuilder().setBlockInfo(blockInfo).build());
/** * <code>optional .alluxio.proto.journal.BlockInfoEntry block_info = 4;</code> */ public Builder mergeBlockInfo(alluxio.proto.journal.Block.BlockInfoEntry value) { if (blockInfoBuilder_ == null) { if (((bitField0_ & 0x00000040) == 0x00000040) && blockInfo_ != null && blockInfo_ != alluxio.proto.journal.Block.BlockInfoEntry.getDefaultInstance()) { blockInfo_ = alluxio.proto.journal.Block.BlockInfoEntry.newBuilder(blockInfo_).mergeFrom(value).buildPartial(); } else { blockInfo_ = value; } onChanged(); } else { blockInfoBuilder_.mergeFrom(value); } bitField0_ |= 0x00000040; return this; } /**
blockInfo_ = alluxio.proto.journal.Block.BlockInfoEntry.getDefaultInstance(); } else { blockInfoBuilder_.clear();
BlockInfoEntry.newBuilder().setBlockId(blockId).setLength(length).build(); journalContext.append(JournalEntry.newBuilder().setBlockInfo(blockInfo).build());
com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { initFields(); int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = break; default: { if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { done = true; } finally { this.unknownFields = unknownFields.build(); makeExtensionsImmutable();
private void initFields() { sequenceNumber_ = 0L; addMountPoint_ = alluxio.proto.journal.File.AddMountPointEntry.getDefaultInstance(); asyncPersistRequest_ = alluxio.proto.journal.File.AsyncPersistRequestEntry.getDefaultInstance(); blockContainerIdGenerator_ = alluxio.proto.journal.Block.BlockContainerIdGeneratorEntry.getDefaultInstance(); blockInfo_ = alluxio.proto.journal.Block.BlockInfoEntry.getDefaultInstance(); completeFile_ = alluxio.proto.journal.File.CompleteFileEntry.getDefaultInstance(); completePartition_ = alluxio.proto.journal.KeyValue.CompletePartitionEntry.getDefaultInstance(); completeStore_ = alluxio.proto.journal.KeyValue.CompleteStoreEntry.getDefaultInstance(); createStore_ = alluxio.proto.journal.KeyValue.CreateStoreEntry.getDefaultInstance(); deleteBlock_ = alluxio.proto.journal.Block.DeleteBlockEntry.getDefaultInstance(); deleteFile_ = alluxio.proto.journal.File.DeleteFileEntry.getDefaultInstance(); deleteLineage_ = alluxio.proto.journal.Lineage.DeleteLineageEntry.getDefaultInstance(); deleteMountPoint_ = alluxio.proto.journal.File.DeleteMountPointEntry.getDefaultInstance(); deleteStore_ = alluxio.proto.journal.KeyValue.DeleteStoreEntry.getDefaultInstance(); inodeDirectory_ = alluxio.proto.journal.File.InodeDirectoryEntry.getDefaultInstance(); inodeDirectoryIdGenerator_ = alluxio.proto.journal.File.InodeDirectoryIdGeneratorEntry.getDefaultInstance(); inodeFile_ = alluxio.proto.journal.File.InodeFileEntry.getDefaultInstance(); inodeLastModificationTime_ = alluxio.proto.journal.File.InodeLastModificationTimeEntry.getDefaultInstance(); lineage_ = alluxio.proto.journal.Lineage.LineageEntry.getDefaultInstance(); lineageIdGenerator_ = alluxio.proto.journal.Lineage.LineageIdGeneratorEntry.getDefaultInstance(); mergeStore_ = alluxio.proto.journal.KeyValue.MergeStoreEntry.getDefaultInstance(); persistDirectory_ = alluxio.proto.journal.File.PersistDirectoryEntry.getDefaultInstance(); reinitializeFile_ = alluxio.proto.journal.File.ReinitializeFileEntry.getDefaultInstance(); rename_ = alluxio.proto.journal.File.RenameEntry.getDefaultInstance(); renameStore_ = alluxio.proto.journal.KeyValue.RenameStoreEntry.getDefaultInstance(); setAttribute_ = alluxio.proto.journal.File.SetAttributeEntry.getDefaultInstance(); updateUfsMode_ = alluxio.proto.journal.File.UpdateUfsModeEntry.getDefaultInstance(); } private byte memoizedIsInitialized = -1;
@Override public void processJournalEntry(JournalEntry entry) throws IOException { // TODO(gene): A better way to process entries besides a huge switch? if (entry.hasBlockContainerIdGenerator()) { mJournaledNextContainerId = (entry.getBlockContainerIdGenerator()).getNextContainerId(); mBlockContainerIdGenerator.setNextContainerId((mJournaledNextContainerId)); } else if (entry.hasDeleteBlock()) { mBlocks.remove(entry.getDeleteBlock().getBlockId()); } else if (entry.hasBlockInfo()) { BlockInfoEntry blockInfoEntry = entry.getBlockInfo(); if (mBlocks.containsKey(blockInfoEntry.getBlockId())) { // Update the existing block info. MasterBlockInfo blockInfo = mBlocks.get(blockInfoEntry.getBlockId()); blockInfo.updateLength(blockInfoEntry.getLength()); } else { mBlocks.put(blockInfoEntry.getBlockId(), new MasterBlockInfo(blockInfoEntry.getBlockId(), blockInfoEntry.getLength())); } } else { throw new IOException(ExceptionMessage.UNEXPECTED_JOURNAL_ENTRY.getMessage(entry)); } }
@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()); } } } }
/** * <code>optional .alluxio.proto.journal.BlockInfoEntry block_info = 4;</code> */ public Builder mergeBlockInfo(alluxio.proto.journal.Block.BlockInfoEntry value) { if (blockInfoBuilder_ == null) { if (((bitField0_ & 0x00000010) == 0x00000010) && blockInfo_ != alluxio.proto.journal.Block.BlockInfoEntry.getDefaultInstance()) { blockInfo_ = alluxio.proto.journal.Block.BlockInfoEntry.newBuilder(blockInfo_).mergeFrom(value).buildPartial(); } else { blockInfo_ = value; } onChanged(); } else { blockInfoBuilder_.mergeFrom(value); } bitField0_ |= 0x00000010; return this; } /**
public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder(alluxio.proto.journal.Block.BlockInfoEntry prototype) {
public Builder toBuilder() { return newBuilder(this); }
public alluxio.proto.journal.Block.BlockInfoEntry buildPartial() { alluxio.proto.journal.Block.BlockInfoEntry result = new alluxio.proto.journal.Block.BlockInfoEntry(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0; if (((from_bitField0_ & 0x00000001) == 0x00000001)) { to_bitField0_ |= 0x00000001; } result.blockId_ = blockId_; if (((from_bitField0_ & 0x00000002) == 0x00000002)) { to_bitField0_ |= 0x00000002; } result.length_ = length_; result.bitField0_ = to_bitField0_; onBuilt(); return result; }
/** * <code>optional .alluxio.proto.journal.BlockInfoEntry block_info = 4;</code> */ public Builder clearBlockInfo() { if (blockInfoBuilder_ == null) { blockInfo_ = alluxio.proto.journal.Block.BlockInfoEntry.getDefaultInstance(); onChanged(); } else { blockInfoBuilder_.clear(); } bitField0_ = (bitField0_ & ~0x00000010); return this; } /**
public alluxio.proto.journal.Block.BlockInfoEntry getDefaultInstanceForType() { return alluxio.proto.journal.Block.BlockInfoEntry.getDefaultInstance(); }
public alluxio.proto.journal.Block.BlockInfoEntry build() { alluxio.proto.journal.Block.BlockInfoEntry result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; }
public static Builder newBuilder(alluxio.proto.journal.Block.BlockInfoEntry prototype) { return newBuilder().mergeFrom(prototype); } public Builder toBuilder() { return newBuilder(this); }
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(); }
break; default: { if (!parseUnknownField( input, unknownFields, extensionRegistry, tag)) { done = true; } finally { this.unknownFields = unknownFields.build(); makeExtensionsImmutable();