@Override public void process() throws IOException { // No header for this section type. LOG.debug("Processing SnapshotDiffSection"); while (true) { XMLEvent ev = expectTag("[diff start tag]", true); if (ev.isEndElement()) { String name = ev.asEndElement().getName().getLocalPart(); if (name.equals(SNAPSHOT_DIFF_SECTION_NAME)) { break; } throw new IOException("Got unexpected end tag for " + name); } String tagName = ev.asStartElement().getName().getLocalPart(); if (tagName.equals(SNAPSHOT_DIFF_SECTION_DIR_DIFF_ENTRY)) { processDirDiffEntry(); } else if (tagName.equals(SNAPSHOT_DIFF_SECTION_FILE_DIFF_ENTRY)) { processFileDiffEntry(); } else { throw new IOException("SnapshotDiffSection contained unexpected " + "tag " + tagName); } } recordSectionLength(SectionName.SNAPSHOT_DIFF.name()); }
/** * Write the string table to the fsimage. * @throws IOException */ private void writeStringTableSection() throws IOException { FsImageProto.StringTableSection sectionHeader = FsImageProto.StringTableSection.newBuilder(). setNumEntry(stringTable.size()).build(); if (LOG.isDebugEnabled()) { LOG.debug(SectionName.STRING_TABLE.name() + " writing header: {" + TextFormat.printToString(sectionHeader) + "}"); } sectionHeader.writeDelimitedTo(out); // The entries don't have to be in any particular order, so iterating // over the hash table is fine. for (Map.Entry<String, Integer> entry : stringTable.entrySet()) { FsImageProto.StringTableSection.Entry stEntry = FsImageProto.StringTableSection.Entry.newBuilder(). setStr(entry.getKey()). setId(entry.getValue()). build(); if (LOG.isTraceEnabled()) { LOG.trace("Writing string table entry: {" + TextFormat.printToString(stEntry) + "}"); } stEntry.writeDelimitedTo(out); } recordSectionLength(SectionName.STRING_TABLE.name()); }
recordSectionLength(SectionName.CACHE_MANAGER.name());
recordSectionLength(SectionName.SECRET_MANAGER.name());
section.writeDelimitedTo(out); node.verifyNoRemainingKeys("ErasureCodingSection"); recordSectionLength(SectionName.ERASURE_CODING.name());
recordSectionLength(SectionName.SNAPSHOT.name());
bld.build().writeDelimitedTo(out); recordSectionLength(SectionName.INODE_DIR.name());
recordSectionLength(SectionName.INODE.name());
bld.build().writeDelimitedTo(out); recordSectionLength(SectionName.INODE_REFERENCE.name());
@Override public void process() throws IOException { // No header for this section type. // Process the repeated files under construction elements. while (true) { XMLEvent ev = expectTag(INODE_SECTION_INODE, true); if (ev.isEndElement()) { break; } Node fileUnderConstruction = new Node(); loadNodeChildren(fileUnderConstruction, "file under construction"); FileUnderConstructionEntry.Builder bld = FileUnderConstructionEntry.newBuilder(); Long id = fileUnderConstruction.removeChildLong(SECTION_ID); if (id != null) { bld.setInodeId(id); } String fullpath = fileUnderConstruction.removeChildStr(SECTION_PATH); if (fullpath != null) { bld.setFullPath(fullpath); } fileUnderConstruction.verifyNoRemainingKeys("inode"); bld.build().writeDelimitedTo(out); } recordSectionLength(SectionName.FILES_UNDERCONSTRUCTION.name()); } }