Пример #1
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();
                }
            }
        }
Пример #2
0
        /// <summary>Set headers for content length, and, if available, md5.</summary>
        /// <exception cref="System.IO.IOException"></exception>
        public static void SetVerificationHeadersForGet(HttpServletResponse response, FilePath
                                                        file)
        {
            response.SetHeader(TransferFsImage.ContentLength, file.Length().ToString());
            MD5Hash hash = MD5FileUtils.ReadStoredMd5ForFile(file);

            if (hash != null)
            {
                response.SetHeader(TransferFsImage.Md5Header, hash.ToString());
            }
        }
Пример #3
0
        /// <summary>Set headers for image length and if available, md5.</summary>
        /// <exception cref="System.IO.IOException"/>
        internal static void SetVerificationHeadersForPut(HttpURLConnection connection, FilePath
                                                          file)
        {
            connection.SetRequestProperty(TransferFsImage.ContentLength, file.Length().ToString
                                              ());
            MD5Hash hash = MD5FileUtils.ReadStoredMd5ForFile(file);

            if (hash != null)
            {
                connection.SetRequestProperty(TransferFsImage.Md5Header, hash.ToString());
            }
        }