public virtual void TestDnRestartWithUnsavedReplicas()
        {
            StartUpCluster(true, 1);
            FsDatasetTestUtil.StopLazyWriter(cluster.GetDataNodes()[0]);
            string MethodName = GenericTestUtils.GetMethodName();
            Path   path1      = new Path("/" + MethodName + ".01.dat");

            MakeTestFile(path1, BlockSize, true);
            EnsureFileReplicasOnStorageType(path1, StorageType.RamDisk);
            Log.Info("Restarting the DataNode");
            cluster.RestartDataNode(0, true);
            cluster.WaitActive();
            // Ensure that the replica is still on transient storage.
            EnsureFileReplicasOnStorageType(path1, StorageType.RamDisk);
        }
        public virtual void TestDeleteBeforePersist()
        {
            StartUpCluster(true, -1);
            string MethodName = GenericTestUtils.GetMethodName();

            FsDatasetTestUtil.StopLazyWriter(cluster.GetDataNodes()[0]);
            Path path = new Path("/" + MethodName + ".dat");

            MakeTestFile(path, BlockSize, true);
            LocatedBlocks locatedBlocks = EnsureFileReplicasOnStorageType(path, StorageType.RamDisk
                                                                          );

            // Delete before persist
            client.Delete(path.ToString(), false);
            NUnit.Framework.Assert.IsFalse(fs.Exists(path));
            Assert.AssertThat(VerifyDeletedBlocks(locatedBlocks), IS.Is(true));
            VerifyRamDiskJMXMetric("RamDiskBlocksDeletedBeforeLazyPersisted", 1);
        }
        public virtual void TestRamDiskEvictionBeforePersist()
        {
            StartUpCluster(true, 1);
            string MethodName = GenericTestUtils.GetMethodName();
            Path   path1      = new Path("/" + MethodName + ".01.dat");
            Path   path2      = new Path("/" + MethodName + ".02.dat");
            int    Seed       = 0XFADED;

            // Stop lazy writer to ensure block for path1 is not persisted to disk.
            FsDatasetTestUtil.StopLazyWriter(cluster.GetDataNodes()[0]);
            MakeRandomTestFile(path1, BlockSize, true, Seed);
            EnsureFileReplicasOnStorageType(path1, StorageType.RamDisk);
            // Create second file with a replica on RAM_DISK.
            MakeTestFile(path2, BlockSize, true);
            // Eviction should not happen for block of the first file that is not
            // persisted yet.
            EnsureFileReplicasOnStorageType(path1, StorageType.RamDisk);
            EnsureFileReplicasOnStorageType(path2, StorageType.Default);
            System.Diagnostics.Debug.Assert((fs.Exists(path1)));
            System.Diagnostics.Debug.Assert((fs.Exists(path2)));
            NUnit.Framework.Assert.IsTrue(VerifyReadRandomFile(path1, BlockSize, Seed));
        }