Ejemplo n.º 1
0
        /// <summary>
        /// Calculate the md5sum of an image after zeroing out the transaction ID
        /// field in the header.
        /// </summary>
        /// <remarks>
        /// Calculate the md5sum of an image after zeroing out the transaction ID
        /// field in the header. This is useful for tests that want to verify
        /// that two checkpoints have identical namespaces.
        /// </remarks>
        /// <exception cref="System.IO.IOException"/>
        public static string GetImageFileMD5IgnoringTxId(FilePath imageFile)
        {
            FilePath tmpFile = FilePath.CreateTempFile("hadoop_imagefile_tmp", "fsimage");

            tmpFile.DeleteOnExit();
            try
            {
                Files.Copy(imageFile, tmpFile);
                RandomAccessFile raf = new RandomAccessFile(tmpFile, "rw");
                try
                {
                    raf.Seek(ImageTxidPos);
                    raf.WriteLong(0);
                }
                finally
                {
                    IOUtils.CloseStream(raf);
                }
                return(GetFileMD5(tmpFile));
            }
            finally
            {
                tmpFile.Delete();
            }
        }
Ejemplo n.º 2
0
        public virtual void TestValidateEditLogWithCorruptHeader()
        {
            FilePath testDir = new FilePath(TestDir, "testValidateEditLogWithCorruptHeader");
            SortedDictionary <long, long> offsetToTxId = Maps.NewTreeMap();
            FilePath         logFile = PrepareUnfinalizedTestEditLog(testDir, 2, offsetToTxId);
            RandomAccessFile rwf     = new RandomAccessFile(logFile, "rw");

            try
            {
                rwf.Seek(0);
                rwf.WriteLong(42);
            }
            finally
            {
                // corrupt header
                rwf.Close();
            }
            FSEditLogLoader.EditLogValidation validation = EditLogFileInputStream.ValidateEditLog
                                                               (logFile);
            NUnit.Framework.Assert.IsTrue(validation.HasCorruptHeader());
        }