Esempio n. 1
0
        /// <summary>Create a snapshot</summary>
        /// <param name="snapshotRoot">The directory path where the snapshot is taken</param>
        /// <param name="snapshotName">The name of the snapshot</param>
        /// <exception cref="System.IO.IOException"/>
        internal static string CreateSnapshot(FSDirectory fsd, SnapshotManager snapshotManager
                                              , string snapshotRoot, string snapshotName, bool logRetryCache)
        {
            INodesInPath iip = fsd.GetINodesInPath4Write(snapshotRoot);

            if (fsd.IsPermissionEnabled())
            {
                FSPermissionChecker pc = fsd.GetPermissionChecker();
                fsd.CheckOwner(pc, iip);
            }
            if (snapshotName == null || snapshotName.IsEmpty())
            {
                snapshotName = Org.Apache.Hadoop.Hdfs.Server.Namenode.Snapshot.Snapshot.GenerateDefaultSnapshotName
                                   ();
            }
            else
            {
                if (!DFSUtil.IsValidNameForComponent(snapshotName))
                {
                    throw new InvalidPathException("Invalid snapshot name: " + snapshotName);
                }
            }
            string snapshotPath = null;

            VerifySnapshotName(fsd, snapshotName, snapshotRoot);
            fsd.WriteLock();
            try
            {
                snapshotPath = snapshotManager.CreateSnapshot(iip, snapshotRoot, snapshotName);
            }
            finally
            {
                fsd.WriteUnlock();
            }
            fsd.GetEditLog().LogCreateSnapshot(snapshotRoot, snapshotName, logRetryCache);
            return(snapshotPath);
        }
Esempio n. 2
0
        public long CreateSnapshot([FromBody] CreateSnapshotContract data)
        {
            m_authorizationManager.AuthorizeBook(data.ProjectId, PermissionFlag.EditProject);

            return(m_snapshotManager.CreateSnapshot(data));
        }