/// <summary>Load the snapshots section from fsimage.</summary> /// <remarks> /// Load the snapshots section from fsimage. Also add snapshottable feature /// to snapshottable directories. /// </remarks> /// <exception cref="System.IO.IOException"/> public void LoadSnapshotSection(InputStream @in) { SnapshotManager sm = fsn.GetSnapshotManager(); FsImageProto.SnapshotSection section = FsImageProto.SnapshotSection.ParseDelimitedFrom (@in); int snum = section.GetNumSnapshots(); sm.SetNumSnapshots(snum); sm.SetSnapshotCounter(section.GetSnapshotCounter()); foreach (long sdirId in 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.SnapshotLimit); } sm.AddSnapshottable(dir); } LoadSnapshots(@in, snum); }
/// <exception cref="System.IO.IOException"/> private void DumpSnapshotSection(InputStream @in) { @out.Write("<SnapshotSection>"); FsImageProto.SnapshotSection s = FsImageProto.SnapshotSection.ParseDelimitedFrom( @in); O("snapshotCounter", s.GetSnapshotCounter()); if (s.GetSnapshottableDirCount() > 0) { @out.Write("<snapshottableDir>"); foreach (long id in s.GetSnapshottableDirList()) { O("dir", id); } @out.Write("</snapshottableDir>\n"); } for (int i = 0; i < s.GetNumSnapshots(); ++i) { FsImageProto.SnapshotSection.Snapshot pbs = FsImageProto.SnapshotSection.Snapshot .ParseDelimitedFrom(@in); O("snapshot", pbs.GetSnapshotId()); } @out.Write("</SnapshotSection>\n"); }