Esempio n. 1
0
        /// <summary>
        /// Run `hdfs dfsadmin -fetchImage ...' and verify that the downloaded image is
        /// correct.
        /// </summary>
        /// <exception cref="System.Exception"/>
        private static void RunFetchImage(DFSAdmin dfsAdmin, MiniDFSCluster cluster)
        {
            int retVal = dfsAdmin.Run(new string[] { "-fetchImage", FetchedImageFile.GetPath(
                                                         ) });

            NUnit.Framework.Assert.AreEqual(0, retVal);
            FilePath highestImageOnNn = GetHighestFsImageOnCluster(cluster);
            MD5Hash  expected         = MD5FileUtils.ComputeMd5ForFile(highestImageOnNn);
            MD5Hash  actual           = MD5FileUtils.ComputeMd5ForFile(new FilePath(FetchedImageFile, highestImageOnNn
                                                                                    .GetName()));

            NUnit.Framework.Assert.AreEqual(expected, actual);
        }
            /// <exception cref="System.IO.IOException"/>
            internal void Load(FilePath file)
            {
                long start = Time.MonotonicNow();

                imgDigest = MD5FileUtils.ComputeMd5ForFile(file);
                RandomAccessFile raFile = new RandomAccessFile(file, "r");
                FileInputStream  fin    = new FileInputStream(file);

                try
                {
                    LoadInternal(raFile, fin);
                    long end = Time.MonotonicNow();
                    Log.Info("Loaded FSImage in " + (end - start) / 1000 + " seconds.");
                }
                finally
                {
                    fin.Close();
                    raFile.Close();
                }
            }
Esempio n. 3
0
 /// <summary>This function returns a md5 hash of a file.</summary>
 /// <param name="file">input file</param>
 /// <returns>The md5 string</returns>
 /// <exception cref="System.IO.IOException"/>
 public static string GetFileMD5(FilePath file)
 {
     return(MD5FileUtils.ComputeMd5ForFile(file).ToString());
 }
Esempio n. 4
0
        public virtual void TestDigest()
        {
            Configuration  conf    = new Configuration();
            MiniDFSCluster cluster = null;

            try
            {
                cluster = new MiniDFSCluster.Builder(conf).NumDataNodes(0).Build();
                DistributedFileSystem fs = cluster.GetFileSystem();
                fs.SetSafeMode(HdfsConstants.SafeModeAction.SafemodeEnter);
                fs.SaveNamespace();
                fs.SetSafeMode(HdfsConstants.SafeModeAction.SafemodeLeave);
                FilePath currentDir = FSImageTestUtil.GetNameNodeCurrentDirs(cluster, 0)[0];
                FilePath fsimage    = FSImageTestUtil.FindNewestImageFile(currentDir.GetAbsolutePath
                                                                              ());
                NUnit.Framework.Assert.AreEqual(MD5FileUtils.ReadStoredMd5ForFile(fsimage), MD5FileUtils
                                                .ComputeMd5ForFile(fsimage));
            }
            finally
            {
                if (cluster != null)
                {
                    cluster.Shutdown();
                }
            }
        }