Example #1
0
        /// <summary>Create a snapshot of the given path.</summary>
        /// <remarks>
        /// Create a snapshot of the given path.
        /// It is assumed that the caller will perform synchronization.
        /// </remarks>
        /// <param name="iip">the INodes resolved from the snapshottable directory's path</param>
        /// <param name="snapshotName">The name of the snapshot.</param>
        /// <exception cref="System.IO.IOException">
        /// Throw IOException when 1) the given path does not lead to an
        /// existing snapshottable directory, and/or 2) there exists a
        /// snapshot with the given name for the directory, and/or 3)
        /// snapshot number exceeds quota
        /// </exception>
        public virtual string CreateSnapshot(INodesInPath iip, string snapshotRoot, string
                                             snapshotName)
        {
            INodeDirectory srcRoot = GetSnapshottableRoot(iip);

            if (snapshotCounter == GetMaxSnapshotID())
            {
                // We have reached the maximum allowable snapshot ID and since we don't
                // handle rollover we will fail all subsequent snapshot creation
                // requests.
                //
                throw new SnapshotException("Failed to create the snapshot. The FileSystem has run out of "
                                            + "snapshot IDs and ID rollover is not supported.");
            }
            srcRoot.AddSnapshot(snapshotCounter, snapshotName);
            //create success, update id
            snapshotCounter++;
            numSnapshots.GetAndIncrement();
            return(Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot.GetSnapshotPath(snapshotRoot
                                                                                            , snapshotName));
        }