void loadINodeDirectorySection(InputStream in) throws IOException { final List<INodeReference> refList = parent.getLoaderContext() .getRefList(); while (true) { INodeDirectorySection.DirEntry e = INodeDirectorySection.DirEntry .parseDelimitedFrom(in); // note that in is a LimitedInputStream if (e == null) { break; } INodeDirectory p = dir.getInode(e.getParent()).asDirectory(); for (long id : e.getChildrenList()) { INode child = dir.getInode(id); addToParent(p, child); } for (int refId : e.getRefChildrenList()) { INodeReference ref = refList.get(refId); addToParent(p, ref); } } }
private void dumpINodeDirectorySection(InputStream in) throws IOException { out.print("<INodeDirectorySection>"); while (true) { INodeDirectorySection.DirEntry e = INodeDirectorySection.DirEntry .parseDelimitedFrom(in); // note that in is a LimitedInputStream if (e == null) { break; } out.print("<directory>"); o("parent", e.getParent()); for (long id : e.getChildrenList()) { o("inode", id); } for (int refId : e.getRefChildrenList()) { o("inodereference-index", refId); } out.print("</directory>\n"); } out.print("</INodeDirectorySection>\n"); }
void serializeINodeDirectorySection(OutputStream out) throws IOException { Iterator<INodeWithAdditionalFields> iter = fsn.getFSDirectory() .getINodeMap().getMapIterator(); final ArrayList<INodeReference> refList = parent.getSaverContext() .getRefList(); int i = 0; while (iter.hasNext()) { INodeWithAdditionalFields n = iter.next(); if (!n.isDirectory()) { continue; } ReadOnlyList<INode> children = n.asDirectory().getChildrenList( Snapshot.CURRENT_STATE_ID); if (children.size() > 0) { INodeDirectorySection.DirEntry.Builder b = INodeDirectorySection. DirEntry.newBuilder().setParent(n.getId()); for (INode inode : children) { if (!inode.isReference()) { b.addChildren(inode.getId()); } else { refList.add(inode.asReference()); b.addRefChildren(refList.size() - 1); } } INodeDirectorySection.DirEntry e = b.build(); e.writeDelimitedTo(out); } ++i; if (i % FSImageFormatProtobuf.Saver.CHECK_CANCEL_INTERVAL == 0) { context.checkCancelled(); } } parent.commitSection(summary, FSImageFormatProtobuf.SectionName.INODE_DIR); }
private void loadINodeDirectorySection(InputStream in) throws IOException { if (LOG.isDebugEnabled()) { LOG.debug("Loading directory section"); } while (true) { INodeDirectorySection.DirEntry e = INodeDirectorySection.DirEntry .parseDelimitedFrom(in); // note that in is a LimitedInputStream if (e == null) { break; } long[] l = new long[e.getChildrenCount() + e.getRefChildrenCount()]; for (int i = 0; i < e.getChildrenCount(); ++i) { l[i] = e.getChildren(i); } for (int i = e.getChildrenCount(); i < l.length; i++) { int refId = e.getRefChildren(i - e.getChildrenCount()); l[i] = refList.get(refId).getReferredId(); } dirmap.put(e.getParent(), l); if (LOG.isDebugEnabled()) { LOG.debug("Loaded directory (parent " + e.getParent() + ") with " + e.getChildrenCount() + " children and " + e.getRefChildrenCount() + " reference children"); } } if (LOG.isDebugEnabled()) { LOG.debug("Loaded " + dirmap.size() + " directories"); } }