コード例 #1
0
 /// <summary>
 /// For NameNode, verify that the current and/or previous exist as indicated by
 /// the method parameters.
 /// </summary>
 /// <remarks>
 /// For NameNode, verify that the current and/or previous exist as indicated by
 /// the method parameters.  If previous exists, verify that
 /// it hasn't been modified by comparing the checksum of all it's
 /// containing files with their original checksum.  It is assumed that
 /// the server has recovered.
 /// </remarks>
 /// <exception cref="System.IO.IOException"/>
 internal virtual void CheckResultNameNode(string[] baseDirs, bool currentShouldExist
                                           , bool previousShouldExist)
 {
     if (currentShouldExist)
     {
         for (int i = 0; i < baseDirs.Length; i++)
         {
             NUnit.Framework.Assert.IsTrue(new FilePath(baseDirs[i], "current").IsDirectory());
             NUnit.Framework.Assert.IsTrue(new FilePath(baseDirs[i], "current/VERSION").IsFile
                                               ());
             NUnit.Framework.Assert.IsNotNull(FSImageTestUtil.FindNewestImageFile(baseDirs[i]
                                                                                  + "/current"));
             NUnit.Framework.Assert.IsTrue(new FilePath(baseDirs[i], "current/seen_txid").IsFile
                                               ());
         }
     }
     if (previousShouldExist)
     {
         for (int i = 0; i < baseDirs.Length; i++)
         {
             NUnit.Framework.Assert.IsTrue(new FilePath(baseDirs[i], "previous").IsDirectory()
                                           );
             NUnit.Framework.Assert.AreEqual(UpgradeUtilities.ChecksumContents(HdfsServerConstants.NodeType
                                                                               .NameNode, new FilePath(baseDirs[i], "previous"), false), UpgradeUtilities.ChecksumMasterNameNodeContents
                                                 ());
         }
     }
 }
コード例 #2
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(
                                                   ));
            }
        }
コード例 #3
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
                                                        ());
                }
            }
        }
コード例 #4
0
 /// <summary>For namenode, Verify that the current and previous directories exist.</summary>
 /// <remarks>
 /// For namenode, Verify that the current and previous directories exist.
 /// Verify that previous hasn't been modified by comparing the checksum of all
 /// its files with their original checksum. It is assumed that the
 /// server has recovered and upgraded.
 /// </remarks>
 /// <exception cref="System.IO.IOException"/>
 internal virtual void CheckNameNode(string[] baseDirs, long imageTxId)
 {
     foreach (string baseDir in baseDirs)
     {
         Log.Info("Checking namenode directory " + baseDir);
         Log.Info("==== Contents ====:\n  " + Joiner.On("  \n").Join(new FilePath(baseDir,
                                                                                  "current").List()));
         Log.Info("==================");
         GenericTestUtils.AssertExists(new FilePath(baseDir, "current"));
         GenericTestUtils.AssertExists(new FilePath(baseDir, "current/VERSION"));
         GenericTestUtils.AssertExists(new FilePath(baseDir, "current/" + NNStorage.GetInProgressEditsFileName
                                                        (imageTxId + 1)));
         GenericTestUtils.AssertExists(new FilePath(baseDir, "current/" + NNStorage.GetImageFileName
                                                        (imageTxId)));
         GenericTestUtils.AssertExists(new FilePath(baseDir, "current/seen_txid"));
         FilePath previous = new FilePath(baseDir, "previous");
         GenericTestUtils.AssertExists(previous);
         NUnit.Framework.Assert.AreEqual(UpgradeUtilities.ChecksumContents(HdfsServerConstants.NodeType
                                                                           .NameNode, previous, false), UpgradeUtilities.ChecksumMasterNameNodeContents());
     }
 }
コード例 #5
0
 /// <summary>
 /// For datanode, for a block pool, verify that the current and previous
 /// directories exist.
 /// </summary>
 /// <remarks>
 /// For datanode, for a block pool, verify that the current and previous
 /// directories exist. Verify that previous hasn't been modified by comparing
 /// the checksum of all its files with their original checksum. It
 /// is assumed that the server has recovered and upgraded.
 /// </remarks>
 /// <exception cref="System.IO.IOException"/>
 internal virtual void CheckDataNode(string[] baseDirs, string bpid)
 {
     for (int i = 0; i < baseDirs.Length; i++)
     {
         FilePath current = new FilePath(baseDirs[i], "current/" + bpid + "/current");
         NUnit.Framework.Assert.AreEqual(UpgradeUtilities.ChecksumContents(HdfsServerConstants.NodeType
                                                                           .DataNode, current, false), UpgradeUtilities.ChecksumMasterDataNodeContents());
         // block files are placed under <sd>/current/<bpid>/current/finalized
         FilePath currentFinalized = MiniDFSCluster.GetFinalizedDir(new FilePath(baseDirs[
                                                                                     i]), bpid);
         NUnit.Framework.Assert.AreEqual(UpgradeUtilities.ChecksumContents(HdfsServerConstants.NodeType
                                                                           .DataNode, currentFinalized, true), UpgradeUtilities.ChecksumMasterBlockPoolFinalizedContents
                                             ());
         FilePath previous = new FilePath(baseDirs[i], "current/" + bpid + "/previous");
         NUnit.Framework.Assert.IsTrue(previous.IsDirectory());
         NUnit.Framework.Assert.AreEqual(UpgradeUtilities.ChecksumContents(HdfsServerConstants.NodeType
                                                                           .DataNode, previous, false), UpgradeUtilities.ChecksumMasterDataNodeContents());
         FilePath previousFinalized = new FilePath(baseDirs[i], "current/" + bpid + "/previous"
                                                   + "/finalized");
         NUnit.Framework.Assert.AreEqual(UpgradeUtilities.ChecksumContents(HdfsServerConstants.NodeType
                                                                           .DataNode, previousFinalized, true), UpgradeUtilities.ChecksumMasterBlockPoolFinalizedContents
                                             ());
     }
 }
コード例 #6
0
 /// <summary>
 /// For block pool, verify that the current and/or previous exist as indicated
 /// by the method parameters.
 /// </summary>
 /// <remarks>
 /// For block pool, verify that the current and/or previous exist as indicated
 /// by the method parameters.  If previous exists, verify that
 /// it hasn't been modified by comparing the checksum of all it's
 /// containing files with their original checksum.  It is assumed that
 /// the server has recovered.
 /// </remarks>
 /// <param name="baseDirs">directories pointing to block pool storage</param>
 /// <param name="bpid">block pool Id</param>
 /// <param name="currentShouldExist">current directory exists under storage</param>
 /// <param name="currentShouldExist">previous directory exists under storage</param>
 /// <exception cref="System.IO.IOException"/>
 internal virtual void CheckResultBlockPool(string[] baseDirs, bool currentShouldExist
                                            , bool previousShouldExist)
 {
     if (currentShouldExist)
     {
         for (int i = 0; i < baseDirs.Length; i++)
         {
             FilePath bpCurDir = new FilePath(baseDirs[i], Storage.StorageDirCurrent);
             NUnit.Framework.Assert.AreEqual(UpgradeUtilities.ChecksumContents(HdfsServerConstants.NodeType
                                                                               .DataNode, bpCurDir, false), UpgradeUtilities.ChecksumMasterBlockPoolContents());
         }
     }
     if (previousShouldExist)
     {
         for (int i = 0; i < baseDirs.Length; i++)
         {
             FilePath bpPrevDir = new FilePath(baseDirs[i], Storage.StorageDirPrevious);
             NUnit.Framework.Assert.IsTrue(bpPrevDir.IsDirectory());
             NUnit.Framework.Assert.AreEqual(UpgradeUtilities.ChecksumContents(HdfsServerConstants.NodeType
                                                                               .DataNode, bpPrevDir, false), UpgradeUtilities.ChecksumMasterBlockPoolContents()
                                             );
         }
     }
 }
コード例 #7
0
 /// <summary>
 /// For datanode, verify that the current and/or previous exist as indicated by
 /// the method parameters.
 /// </summary>
 /// <remarks>
 /// For datanode, verify that the current and/or previous exist as indicated by
 /// the method parameters.  If previous exists, verify that
 /// it hasn't been modified by comparing the checksum of all it's
 /// containing files with their original checksum.  It is assumed that
 /// the server has recovered.
 /// </remarks>
 /// <exception cref="System.IO.IOException"/>
 internal virtual void CheckResultDataNode(string[] baseDirs, bool currentShouldExist
                                           , bool previousShouldExist)
 {
     if (currentShouldExist)
     {
         for (int i = 0; i < baseDirs.Length; i++)
         {
             NUnit.Framework.Assert.AreEqual(UpgradeUtilities.ChecksumContents(HdfsServerConstants.NodeType
                                                                               .DataNode, new FilePath(baseDirs[i], "current"), false), UpgradeUtilities.ChecksumMasterDataNodeContents
                                                 ());
         }
     }
     if (previousShouldExist)
     {
         for (int i = 0; i < baseDirs.Length; i++)
         {
             NUnit.Framework.Assert.IsTrue(new FilePath(baseDirs[i], "previous").IsDirectory()
                                           );
             NUnit.Framework.Assert.AreEqual(UpgradeUtilities.ChecksumContents(HdfsServerConstants.NodeType
                                                                               .DataNode, new FilePath(baseDirs[i], "previous"), false), UpgradeUtilities.ChecksumMasterDataNodeContents
                                                 ());
         }
     }
 }