Esempio n. 1
0
        /// <summary>Verify that the new current directory is the old previous.</summary>
        /// <remarks>
        /// Verify that the new current directory is the old previous.
        /// It is assumed that the server has recovered and rolled back.
        /// </remarks>
        /// <exception cref="System.Exception"/>
        internal virtual void CheckResult(HdfsServerConstants.NodeType nodeType, string[]
                                          baseDirs)
        {
            IList <FilePath> curDirs = Lists.NewArrayList();

            foreach (string baseDir in baseDirs)
            {
                FilePath curDir = new FilePath(baseDir, "current");
                curDirs.AddItem(curDir);
                switch (nodeType)
                {
                case HdfsServerConstants.NodeType.NameNode:
                {
                    FSImageTestUtil.AssertReasonableNameCurrentDir(curDir);
                    break;
                }

                case HdfsServerConstants.NodeType.DataNode:
                {
                    NUnit.Framework.Assert.AreEqual(UpgradeUtilities.ChecksumContents(nodeType, curDir
                                                                                      , false), UpgradeUtilities.ChecksumMasterDataNodeContents());
                    break;
                }
                }
            }
            FSImageTestUtil.AssertParallelFilesAreIdentical(curDirs, Sharpen.Collections.EmptySet
                                                            <string>());
            for (int i = 0; i < baseDirs.Length; i++)
            {
                NUnit.Framework.Assert.IsFalse(new FilePath(baseDirs[i], "previous").IsDirectory(
                                                   ));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Verify that the current directory exists and that the previous directory
        /// does not exist.
        /// </summary>
        /// <remarks>
        /// Verify that the current directory exists and that the previous directory
        /// does not exist.  Verify that current hasn't been modified by comparing
        /// the checksum of all it's containing files with their original checksum.
        /// </remarks>
        /// <exception cref="System.Exception"/>
        internal static void CheckResult(string[] nameNodeDirs, string[] dataNodeDirs, string
                                         bpid)
        {
            IList <FilePath> dirs = Lists.NewArrayList();

            for (int i = 0; i < nameNodeDirs.Length; i++)
            {
                FilePath curDir = new FilePath(nameNodeDirs[i], "current");
                dirs.AddItem(curDir);
                FSImageTestUtil.AssertReasonableNameCurrentDir(curDir);
            }
            FSImageTestUtil.AssertParallelFilesAreIdentical(dirs, Sharpen.Collections.EmptySet
                                                            <string>());
            FilePath[] dnCurDirs = new FilePath[dataNodeDirs.Length];
            for (int i_1 = 0; i_1 < dataNodeDirs.Length; i_1++)
            {
                dnCurDirs[i_1] = new FilePath(dataNodeDirs[i_1], "current");
                NUnit.Framework.Assert.AreEqual(UpgradeUtilities.ChecksumContents(HdfsServerConstants.NodeType
                                                                                  .DataNode, dnCurDirs[i_1], false), UpgradeUtilities.ChecksumMasterDataNodeContents
                                                    ());
            }
            for (int i_2 = 0; i_2 < nameNodeDirs.Length; i_2++)
            {
                NUnit.Framework.Assert.IsFalse(new FilePath(nameNodeDirs[i_2], "previous").IsDirectory
                                                   ());
            }
            if (bpid == null)
            {
                for (int i_3 = 0; i_3 < dataNodeDirs.Length; i_3++)
                {
                    NUnit.Framework.Assert.IsFalse(new FilePath(dataNodeDirs[i_3], "previous").IsDirectory
                                                       ());
                }
            }
            else
            {
                for (int i_3 = 0; i_3 < dataNodeDirs.Length; i_3++)
                {
                    FilePath bpRoot = BlockPoolSliceStorage.GetBpRoot(bpid, dnCurDirs[i_3]);
                    NUnit.Framework.Assert.IsFalse(new FilePath(bpRoot, "previous").IsDirectory());
                    FilePath bpCurFinalizeDir = new FilePath(bpRoot, "current/" + DataStorage.StorageDirFinalized
                                                             );
                    NUnit.Framework.Assert.AreEqual(UpgradeUtilities.ChecksumContents(HdfsServerConstants.NodeType
                                                                                      .DataNode, bpCurFinalizeDir, true), UpgradeUtilities.ChecksumMasterBlockPoolFinalizedContents
                                                        ());
                }
            }
        }