Esempio n. 1
0
        /// <summary>
        /// Make sure that clients will receive StandbyExceptions even when a
        /// checkpoint is in progress on the SBN, and therefore the StandbyCheckpointer
        /// thread will have FSNS lock.
        /// </summary>
        /// <remarks>
        /// Make sure that clients will receive StandbyExceptions even when a
        /// checkpoint is in progress on the SBN, and therefore the StandbyCheckpointer
        /// thread will have FSNS lock. Regression test for HDFS-4591.
        /// </remarks>
        /// <exception cref="System.Exception"/>
        public virtual void TestStandbyExceptionThrownDuringCheckpoint()
        {
            // Set it up so that we know when the SBN checkpoint starts and ends.
            FSImage spyImage1 = NameNodeAdapter.SpyOnFsImage(nn1);

            GenericTestUtils.DelayAnswer answerer = new GenericTestUtils.DelayAnswer(Log);
            Org.Mockito.Mockito.DoAnswer(answerer).When(spyImage1).SaveNamespace(Org.Mockito.Mockito
                                                                                 .Any <FSNamesystem>(), Org.Mockito.Mockito.Eq(NNStorage.NameNodeFile.Image), Org.Mockito.Mockito
                                                                                 .Any <Canceler>());
            // Perform some edits and wait for a checkpoint to start on the SBN.
            DoEdits(0, 1000);
            nn0.GetRpcServer().RollEditLog();
            answerer.WaitForCall();
            NUnit.Framework.Assert.IsTrue("SBN is not performing checkpoint but it should be."
                                          , answerer.GetFireCount() == 1 && answerer.GetResultCount() == 0);
            // Make sure that the lock has actually been taken by the checkpointing
            // thread.
            ThreadUtil.SleepAtLeastIgnoreInterrupts(1000);
            try
            {
                // Perform an RPC to the SBN and make sure it throws a StandbyException.
                nn1.GetRpcServer().GetFileInfo("/");
                NUnit.Framework.Assert.Fail("Should have thrown StandbyException, but instead succeeded."
                                            );
            }
            catch (StandbyException se)
            {
                GenericTestUtils.AssertExceptionContains("is not supported", se);
            }
            // Make sure new incremental block reports are processed during
            // checkpointing on the SBN.
            NUnit.Framework.Assert.AreEqual(0, cluster.GetNamesystem(1).GetPendingDataNodeMessageCount
                                                ());
            DoCreate();
            Sharpen.Thread.Sleep(1000);
            NUnit.Framework.Assert.IsTrue(cluster.GetNamesystem(1).GetPendingDataNodeMessageCount
                                              () > 0);
            // Make sure that the checkpoint is still going on, implying that the client
            // RPC to the SBN happened during the checkpoint.
            NUnit.Framework.Assert.IsTrue("SBN should have still been checkpointing.", answerer
                                          .GetFireCount() == 1 && answerer.GetResultCount() == 0);
            answerer.Proceed();
            answerer.WaitForResult();
            NUnit.Framework.Assert.IsTrue("SBN should have finished checkpointing.", answerer
                                          .GetFireCount() == 1 && answerer.GetResultCount() == 1);
        }
Esempio n. 2
0
        /// <exception cref="System.Exception"/>
        public virtual void TestReadsAllowedDuringCheckpoint()
        {
            // Set it up so that we know when the SBN checkpoint starts and ends.
            FSImage spyImage1 = NameNodeAdapter.SpyOnFsImage(nn1);

            GenericTestUtils.DelayAnswer answerer = new GenericTestUtils.DelayAnswer(Log);
            Org.Mockito.Mockito.DoAnswer(answerer).When(spyImage1).SaveNamespace(Org.Mockito.Mockito
                                                                                 .Any <FSNamesystem>(), Org.Mockito.Mockito.Any <NNStorage.NameNodeFile>(), Org.Mockito.Mockito
                                                                                 .Any <Canceler>());
            // Perform some edits and wait for a checkpoint to start on the SBN.
            DoEdits(0, 1000);
            nn0.GetRpcServer().RollEditLog();
            answerer.WaitForCall();
            NUnit.Framework.Assert.IsTrue("SBN is not performing checkpoint but it should be."
                                          , answerer.GetFireCount() == 1 && answerer.GetResultCount() == 0);
            // Make sure that the lock has actually been taken by the checkpointing
            // thread.
            ThreadUtil.SleepAtLeastIgnoreInterrupts(1000);
            // Perform an RPC that needs to take the write lock.
            Sharpen.Thread t = new _Thread_404(this);
            t.Start();
            // Make sure that our thread is waiting for the lock.
            ThreadUtil.SleepAtLeastIgnoreInterrupts(1000);
            NUnit.Framework.Assert.IsFalse(nn1.GetNamesystem().GetFsLockForTests().HasQueuedThreads
                                               ());
            NUnit.Framework.Assert.IsFalse(nn1.GetNamesystem().GetFsLockForTests().IsWriteLocked
                                               ());
            NUnit.Framework.Assert.IsTrue(nn1.GetNamesystem().GetCpLockForTests().HasQueuedThreads
                                              ());
            // Get /jmx of the standby NN web UI, which will cause the FSNS read lock to
            // be taken.
            string pageContents = DFSTestUtil.UrlGet(new Uri("http://" + nn1.GetHttpAddress()
                                                             .GetHostName() + ":" + nn1.GetHttpAddress().Port + "/jmx"));

            NUnit.Framework.Assert.IsTrue(pageContents.Contains("NumLiveDataNodes"));
            // Make sure that the checkpoint is still going on, implying that the client
            // RPC to the SBN happened during the checkpoint.
            NUnit.Framework.Assert.IsTrue("SBN should have still been checkpointing.", answerer
                                          .GetFireCount() == 1 && answerer.GetResultCount() == 0);
            answerer.Proceed();
            answerer.WaitForResult();
            NUnit.Framework.Assert.IsTrue("SBN should have finished checkpointing.", answerer
                                          .GetFireCount() == 1 && answerer.GetResultCount() == 1);
            t.Join();
        }