/** * Load the snapshots section from fsimage. Also add snapshottable feature * to snapshottable directories. */ public void loadSnapshotSection(InputStream in) throws IOException { SnapshotManager sm = fsn.getSnapshotManager(); SnapshotSection section = SnapshotSection.parseDelimitedFrom(in); int snum = section.getNumSnapshots(); sm.setNumSnapshots(snum); sm.setSnapshotCounter(section.getSnapshotCounter()); for (long sdirId : section.getSnapshottableDirList()) { INodeDirectory dir = fsDir.getInode(sdirId).asDirectory(); if (!dir.isSnapshottable()) { dir.addSnapshottableFeature(); } else { // dir is root, and admin set root to snapshottable before dir.setSnapshotQuota(DirectorySnapshottableFeature.SNAPSHOT_LIMIT); } sm.addSnapshottable(dir); } loadSnapshots(in, snum); }
private void dumpSnapshotSection(InputStream in) throws IOException { out.print("<SnapshotSection>"); SnapshotSection s = SnapshotSection.parseDelimitedFrom(in); o("snapshotCounter", s.getSnapshotCounter()); if (s.getSnapshottableDirCount() > 0) { out.print("<snapshottableDir>"); for (long id : s.getSnapshottableDirList()) { o("dir", id); } out.print("</snapshottableDir>\n"); } for (int i = 0; i < s.getNumSnapshots(); ++i) { SnapshotSection.Snapshot pbs = SnapshotSection.Snapshot .parseDelimitedFrom(in); o("snapshot", pbs.getSnapshotId()); } out.print("</SnapshotSection>\n"); }
/** * Load the snapshots section from fsimage. Also convert snapshottable * directories into {@link INodeDirectorySnapshottable}. * */ public void loadSnapshotSection(InputStream in) throws IOException { SnapshotManager sm = fsn.getSnapshotManager(); SnapshotSection section = SnapshotSection.parseDelimitedFrom(in); int snum = section.getNumSnapshots(); sm.setNumSnapshots(snum); sm.setSnapshotCounter(section.getSnapshotCounter()); for (long sdirId : section.getSnapshottableDirList()) { INodeDirectory dir = fsDir.getInode(sdirId).asDirectory(); final INodeDirectorySnapshottable sdir; if (!dir.isSnapshottable()) { sdir = new INodeDirectorySnapshottable(dir); fsDir.addToInodeMap(sdir); } else { // dir is root, and admin set root to snapshottable before sdir = (INodeDirectorySnapshottable) dir; sdir.setSnapshotQuota(INodeDirectorySnapshottable.SNAPSHOT_LIMIT); } sm.addSnapshottable(sdir); } loadSnapshots(in, snum); }