Пример #1
0
        /// <exception cref="System.IO.IOException"/>
        private TestFailureToReadEdits.LimitedEditLogAnswer CauseFailureOnEditLogRead()
        {
            FSEditLog spyEditLog = NameNodeAdapter.SpyOnEditLog(nn1);

            TestFailureToReadEdits.LimitedEditLogAnswer answer = new TestFailureToReadEdits.LimitedEditLogAnswer
                                                                     ();
            Org.Mockito.Mockito.DoAnswer(answer).When(spyEditLog).SelectInputStreams(Matchers.AnyLong
                                                                                         (), Matchers.AnyLong(), (MetaRecoveryContext)Matchers.AnyObject(), Matchers.AnyBoolean
                                                                                         ());
            return(answer);
        }
Пример #2
0
 public virtual void TestFailuretoReadEdits()
 {
     NUnit.Framework.Assert.IsTrue(fs.Mkdirs(new Path(TestDir1)));
     HATestUtil.WaitForStandbyToCatchUp(nn0, nn1);
     // If these two ops are applied twice, the first op will throw an
     // exception the second time its replayed.
     fs.SetOwner(new Path(TestDir1), "foo", "bar");
     NUnit.Framework.Assert.IsTrue(fs.Delete(new Path(TestDir1), true));
     // This op should get applied just fine.
     NUnit.Framework.Assert.IsTrue(fs.Mkdirs(new Path(TestDir2)));
     // This is the op the mocking will cause to fail to be read.
     NUnit.Framework.Assert.IsTrue(fs.Mkdirs(new Path(TestDir3)));
     TestFailureToReadEdits.LimitedEditLogAnswer answer = CauseFailureOnEditLogRead();
     try
     {
         HATestUtil.WaitForStandbyToCatchUp(nn0, nn1);
         NUnit.Framework.Assert.Fail("Standby fully caught up, but should not have been able to"
                                     );
     }
     catch (HATestUtil.CouldNotCatchUpException)
     {
     }
     // Expected. The NN did not exit.
     // Null because it was deleted.
     NUnit.Framework.Assert.IsNull(NameNodeAdapter.GetFileInfo(nn1, TestDir1, false));
     // Should have been successfully created.
     NUnit.Framework.Assert.IsTrue(NameNodeAdapter.GetFileInfo(nn1, TestDir2, false).IsDir
                                       ());
     // Null because it hasn't been created yet.
     NUnit.Framework.Assert.IsNull(NameNodeAdapter.GetFileInfo(nn1, TestDir3, false));
     // Now let the standby read ALL the edits.
     answer.SetThrowExceptionOnRead(false);
     HATestUtil.WaitForStandbyToCatchUp(nn0, nn1);
     // Null because it was deleted.
     NUnit.Framework.Assert.IsNull(NameNodeAdapter.GetFileInfo(nn1, TestDir1, false));
     // Should have been successfully created.
     NUnit.Framework.Assert.IsTrue(NameNodeAdapter.GetFileInfo(nn1, TestDir2, false).IsDir
                                       ());
     // Should now have been successfully created.
     NUnit.Framework.Assert.IsTrue(NameNodeAdapter.GetFileInfo(nn1, TestDir3, false).IsDir
                                       ());
 }