/** * Load the under-construction files section, and update the lease map */ void loadFilesUnderConstructionSection(InputStream in) throws IOException { while (true) { FileUnderConstructionEntry entry = FileUnderConstructionEntry .parseDelimitedFrom(in); if (entry == null) { break; } // update the lease manager INodeFile file = dir.getInode(entry.getInodeId()).asFile(); FileUnderConstructionFeature uc = file.getFileUnderConstructionFeature(); Preconditions.checkState(uc != null); // file must be under-construction fsn.leaseManager.addLease(uc.getClientName(), entry.getInodeId()); } }
void serializeFilesUCSection(OutputStream out) throws IOException { Collection<Long> filesWithUC = fsn.getLeaseManager() .getINodeIdWithLeases(); for (Long id : filesWithUC) { INode inode = fsn.getFSDirectory().getInode(id); if (inode == null) { LOG.warn("Fail to find inode " + id + " when saving the leases."); continue; } INodeFile file = inode.asFile(); if (!file.isUnderConstruction()) { LOG.warn("Fail to save the lease for inode id " + id + " as the file is not under construction"); continue; } String path = file.getFullPathName(); FileUnderConstructionEntry.Builder b = FileUnderConstructionEntry .newBuilder().setInodeId(file.getId()).setFullPath(path); FileUnderConstructionEntry e = b.build(); e.writeDelimitedTo(out); } parent.commitSection(summary, FSImageFormatProtobuf.SectionName.FILES_UNDERCONSTRUCTION); }
/** * Load the under-construction files section, and update the lease map */ void loadFilesUnderConstructionSection(InputStream in) throws IOException { while (true) { FileUnderConstructionEntry entry = FileUnderConstructionEntry .parseDelimitedFrom(in); if (entry == null) { break; } // update the lease manager INodeFile file = dir.getInode(entry.getInodeId()).asFile(); FileUnderConstructionFeature uc = file.getFileUnderConstructionFeature(); Preconditions.checkState(uc != null); // file must be under-construction fsn.leaseManager.addLease(uc.getClientName(), entry.getFullPath()); } }
void serializeFilesUCSection(OutputStream out) throws IOException { Map<String, INodeFile> ucMap = fsn.getFilesUnderConstruction(); for (Map.Entry<String, INodeFile> entry : ucMap.entrySet()) { String path = entry.getKey(); INodeFile file = entry.getValue(); FileUnderConstructionEntry.Builder b = FileUnderConstructionEntry .newBuilder().setInodeId(file.getId()).setFullPath(path); FileUnderConstructionEntry e = b.build(); e.writeDelimitedTo(out); } parent.commitSection(summary, FSImageFormatProtobuf.SectionName.FILES_UNDERCONSTRUCTION); }
private void dumpFileUnderConstructionSection(InputStream in) throws IOException { out.print("<FileUnderConstructionSection>"); while (true) { FileUnderConstructionEntry e = FileUnderConstructionEntry .parseDelimitedFrom(in); if (e == null) { break; } out.print("<inode>"); o("id", e.getInodeId()).o("path", e.getFullPath()); out.print("</inode>\n"); } out.print("</FileUnderConstructionSection>\n"); }