Пример #1
0
        public virtual void TestUnderReplicationAfterVolFailure()
        {
            // This test relies on denying access to data volumes to simulate data volume
            // failure.  This doesn't work on Windows, because an owner of an object
            // always has the ability to read and change permissions on the object.
            Assume.AssumeTrue(!Path.Windows);
            // Bring up one more datanode
            cluster.StartDataNodes(conf, 1, true, null, null);
            cluster.WaitActive();
            BlockManager bm    = cluster.GetNamesystem().GetBlockManager();
            Path         file1 = new Path("/test1");

            DFSTestUtil.CreateFile(fs, file1, 1024, (short)3, 1L);
            DFSTestUtil.WaitReplication(fs, file1, (short)3);
            // Fail the first volume on both datanodes
            FilePath dn1Vol1 = new FilePath(dataDir, "data" + (2 * 0 + 1));
            FilePath dn2Vol1 = new FilePath(dataDir, "data" + (2 * 1 + 1));

            DataNodeTestUtils.InjectDataDirFailure(dn1Vol1, dn2Vol1);
            Path file2 = new Path("/test2");

            DFSTestUtil.CreateFile(fs, file2, 1024, (short)3, 1L);
            DFSTestUtil.WaitReplication(fs, file2, (short)3);
            // underReplicatedBlocks are due to failed volumes
            int underReplicatedBlocks = BlockManagerTestUtil.CheckHeartbeatAndGetUnderReplicatedBlocksCount
                                            (cluster.GetNamesystem(), bm);

            NUnit.Framework.Assert.IsTrue("There is no under replicated block after volume failure"
                                          , underReplicatedBlocks > 0);
        }