/// <summary>Set the given snapshottable directory to non-snapshottable.</summary> /// <exception cref="Org.Apache.Hadoop.Hdfs.Protocol.SnapshotException">if there are snapshots in the directory. /// </exception> /// <exception cref="System.IO.IOException"/> public virtual void ResetSnapshottable(string path) { INodesInPath iip = fsdir.GetINodesInPath4Write(path); INodeDirectory d = INodeDirectory.ValueOf(iip.GetLastINode(), path); DirectorySnapshottableFeature sf = d.GetDirectorySnapshottableFeature(); if (sf == null) { // the directory is already non-snapshottable return; } if (sf.GetNumSnapshots() > 0) { throw new SnapshotException("The directory " + path + " has snapshot(s). " + "Please redo the operation after removing all the snapshots." ); } if (d == fsdir.GetRoot()) { d.SetSnapshotQuota(0); } else { d.RemoveSnapshottableFeature(); } RemoveSnapshottable(d); }
/// <summary>Save snapshots and snapshot quota for a snapshottable directory.</summary> /// <param name="current">The directory that the snapshots belongs to.</param> /// <param name="out"> /// The /// <see cref="System.IO.DataOutput"/> /// to write. /// </param> /// <exception cref="System.IO.IOException"/> public static void SaveSnapshots(INodeDirectory current, DataOutput @out) { DirectorySnapshottableFeature sf = current.GetDirectorySnapshottableFeature(); Preconditions.CheckArgument(sf != null); // list of snapshots in snapshotsByNames ReadOnlyList <Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot> snapshots = sf.GetSnapshotList(); @out.WriteInt(snapshots.Size()); foreach (Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot s in snapshots) { // write the snapshot id @out.WriteInt(s.GetId()); } // snapshot quota @out.WriteInt(sf.GetSnapshotQuota()); }
/// <summary>Load snapshots and snapshotQuota for a Snapshottable directory.</summary> /// <param name="snapshottableParent">The snapshottable directory for loading.</param> /// <param name="numSnapshots">The number of snapshots that the directory has.</param> /// <param name="loader">The loader</param> /// <exception cref="System.IO.IOException"/> public static void LoadSnapshotList(INodeDirectory snapshottableParent, int numSnapshots , DataInput @in, FSImageFormat.Loader loader) { DirectorySnapshottableFeature sf = snapshottableParent.GetDirectorySnapshottableFeature (); Preconditions.CheckArgument(sf != null); for (int i = 0; i < numSnapshots; i++) { // read snapshots Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot s = loader.GetSnapshot(@in ); s.GetRoot().SetParent(snapshottableParent); sf.AddSnapshot(s); } int snapshotQuota = @in.ReadInt(); snapshottableParent.SetSnapshotQuota(snapshotQuota); }
public _IEnumerable_416(DirectorySnapshottableFeature _enclosing) { this._enclosing = _enclosing; }