/*
         * Finalize the block pool storage by deleting <BP>/previous directory
         * that holds the snapshot.
         */
        /// <exception cref="System.IO.IOException"/>
        internal virtual void DoFinalize(FilePath dnCurDir)
        {
            FilePath bpRoot = GetBpRoot(blockpoolID, dnCurDir);

            Storage.StorageDirectory bpSd = new Storage.StorageDirectory(bpRoot);
            // block pool level previous directory
            FilePath prevDir = bpSd.GetPreviousDir();

            if (!prevDir.Exists())
            {
                return;
            }
            // already finalized
            string dataDirPath = bpSd.GetRoot().GetCanonicalPath();

            Log.Info("Finalizing upgrade for storage directory " + dataDirPath + ".\n   cur LV = "
                     + this.GetLayoutVersion() + "; cur CTime = " + this.GetCTime());
            System.Diagnostics.Debug.Assert(bpSd.GetCurrentDir().Exists(), "Current directory must exist."
                                            );
            // rename previous to finalized.tmp
            FilePath tmpDir = bpSd.GetFinalizedTmp();

            Rename(prevDir, tmpDir);
            // delete finalized.tmp dir in a separate thread
            new Daemon(new _Runnable_618(tmpDir, dataDirPath)).Start();
        }
Exemple #2
0
        /// <summary>Finalize the upgrade.</summary>
        /// <remarks>
        /// Finalize the upgrade. The previous dir, if any, will be renamed and
        /// removed. After this is completed, rollback is no longer allowed.
        /// </remarks>
        /// <param name="sd">the storage directory to finalize</param>
        /// <exception cref="System.IO.IOException">in the event of error</exception>
        internal static void DoFinalize(Storage.StorageDirectory sd)
        {
            FilePath prevDir = sd.GetPreviousDir();

            if (!prevDir.Exists())
            {
                // already discarded
                Log.Info("Directory " + prevDir + " does not exist.");
                Log.Info("Finalize upgrade for " + sd.GetRoot() + " is not required.");
                return;
            }
            Log.Info("Finalizing upgrade of storage directory " + sd.GetRoot());
            Preconditions.CheckState(sd.GetCurrentDir().Exists(), "Current directory must exist."
                                     );
            FilePath tmpDir = sd.GetFinalizedTmp();

            // rename previous to tmp and remove
            NNStorage.Rename(prevDir, tmpDir);
            NNStorage.DeleteDir(tmpDir);
            Log.Info("Finalize upgrade for " + sd.GetRoot() + " is complete.");
        }