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>Compute the checksum of all the files in the specified directory.</summary>
        /// <remarks>
        /// Compute the checksum of all the files in the specified directory.
        /// This method provides an easy way to ensure equality between the contents
        /// of two directories.
        /// </remarks>
        /// <param name="nodeType">
        /// if DATA_NODE then any file named "VERSION" is ignored.
        /// This is because this file file is changed every time
        /// the Datanode is started.
        /// </param>
        /// <param name="dir">must be a directory</param>
        /// <param name="recursive">whether or not to consider subdirectories</param>
        /// <exception cref="System.ArgumentException">if specified directory is not a directory
        ///     </exception>
        /// <exception cref="System.IO.IOException">if an IOException occurs while reading the files
        ///     </exception>
        /// <returns>the computed checksum value</returns>
        public static long ChecksumContents(HdfsServerConstants.NodeType nodeType, FilePath
                                            dir, bool recursive)
        {
            CRC32 checksum = new CRC32();

            ChecksumContentsHelper(nodeType, dir, checksum, recursive);
            return(checksum.GetValue());
        }
Esempio n. 3
0
 public StorageInfo(int layoutV, int nsID, string cid, long cT, HdfsServerConstants.NodeType
                    type)
 {
     // layout version of the storage data
     // id of the file system
     // id of the cluster
     // creation time of the file system state
     // Type of the node using this storage
     layoutVersion = layoutV;
     clusterID     = cid;
     namespaceID   = nsID;
     cTime         = cT;
     storageType   = type;
 }
        /// <summary>Writes an INFO log message containing the parameters.</summary>
        internal virtual void Log(string label, HdfsServerConstants.NodeType nodeType, int
                                  testCase, TestDFSStartupVersions.StorageData sd)
        {
            string testCaseLine = string.Empty;

            if (testCase != null)
            {
                testCaseLine = " testCase=" + testCase;
            }
            Log.Info("============================================================");
            Log.Info("***TEST*** " + label + ":" + testCaseLine + " nodeType=" + nodeType + " layoutVersion="
                     + sd.storageInfo.GetLayoutVersion() + " namespaceID=" + sd.storageInfo.GetNamespaceID
                         () + " fsscTime=" + sd.storageInfo.GetCTime() + " clusterID=" + sd.storageInfo.GetClusterID
                         () + " BlockPoolID=" + sd.blockPoolId);
        }
Esempio n. 5
0
 /// <summary>
 /// Validate and set storage type from
 /// <see cref="Sharpen.Properties"/>
 ///
 /// </summary>
 /// <exception cref="Org.Apache.Hadoop.Hdfs.Server.Common.InconsistentFSStateException
 ///     "/>
 protected internal virtual void CheckStorageType(Properties props, Storage.StorageDirectory
                                                  sd)
 {
     if (storageType == null)
     {
         //don't care about storage type
         return;
     }
     HdfsServerConstants.NodeType type = HdfsServerConstants.NodeType.ValueOf(GetProperty
                                                                                  (props, sd, "storageType"));
     if (!storageType.Equals(type))
     {
         throw new InconsistentFSStateException(sd.root, "Incompatible node types: storageType="
                                                + storageType + " but StorageDirectory type=" + type);
     }
 }
Esempio n. 6
0
 /// <exception cref="System.IO.IOException"/>
 public static void ChecksumContentsHelper(HdfsServerConstants.NodeType nodeType,
                                           FilePath dir, CRC32 checksum, bool recursive)
 {
     if (!dir.IsDirectory())
     {
         throw new ArgumentException("Given argument is not a directory:" + dir);
     }
     FilePath[] list = dir.ListFiles();
     Arrays.Sort(list);
     for (int i = 0; i < list.Length; i++)
     {
         if (!list[i].IsFile())
         {
             if (recursive)
             {
                 ChecksumContentsHelper(nodeType, list[i], checksum, recursive);
             }
             continue;
         }
         // skip VERSION and dfsUsed file for DataNodes
         if (nodeType == HdfsServerConstants.NodeType.DataNode && (list[i].GetName().Equals
                                                                       ("VERSION") || list[i].GetName().Equals("dfsUsed")))
         {
             continue;
         }
         FileInputStream fis = null;
         try
         {
             fis = new FileInputStream(list[i]);
             byte[] buffer = new byte[1024];
             int    bytesRead;
             while ((bytesRead = fis.Read(buffer)) != -1)
             {
                 checksum.Update(buffer, 0, bytesRead);
             }
         }
         finally
         {
             if (fis != null)
             {
                 fis.Close();
             }
         }
     }
 }
Esempio n. 7
0
 public StorageInfo(HdfsServerConstants.NodeType type)
     : this(0, 0, string.Empty, 0L, type)
 {
 }
Esempio n. 8
0
 private static StorageInfo GetStorageInfo(HdfsServerConstants.NodeType type)
 {
     return(new StorageInfo(1, 2, "cid", 3, type));
 }