public virtual void TestReplQueuesActiveAfterStartupSafemode() { Configuration conf = new Configuration(); FSEditLog fsEditLog = Org.Mockito.Mockito.Mock <FSEditLog>(); FSImage fsImage = Org.Mockito.Mockito.Mock <FSImage>(); Org.Mockito.Mockito.When(fsImage.GetEditLog()).ThenReturn(fsEditLog); FSNamesystem fsNamesystem = new FSNamesystem(conf, fsImage); FSNamesystem fsn = Org.Mockito.Mockito.Spy(fsNamesystem); //Make shouldPopulaeReplQueues return true HAContext haContext = Org.Mockito.Mockito.Mock <HAContext>(); HAState haState = Org.Mockito.Mockito.Mock <HAState>(); Org.Mockito.Mockito.When(haContext.GetState()).ThenReturn(haState); Org.Mockito.Mockito.When(haState.ShouldPopulateReplQueues()).ThenReturn(true); Whitebox.SetInternalState(fsn, "haContext", haContext); //Make NameNode.getNameNodeMetrics() not return null NameNode.InitMetrics(conf, HdfsServerConstants.NamenodeRole.Namenode); fsn.EnterSafeMode(false); NUnit.Framework.Assert.IsTrue("FSNamesystem didn't enter safemode", fsn.IsInSafeMode ()); NUnit.Framework.Assert.IsTrue("Replication queues were being populated during very first " + "safemode", !fsn.IsPopulatingReplQueues()); fsn.LeaveSafeMode(); NUnit.Framework.Assert.IsTrue("FSNamesystem didn't leave safemode", !fsn.IsInSafeMode ()); NUnit.Framework.Assert.IsTrue("Replication queues weren't being populated even after leaving " + "safemode", fsn.IsPopulatingReplQueues()); fsn.EnterSafeMode(false); NUnit.Framework.Assert.IsTrue("FSNamesystem didn't enter safemode", fsn.IsInSafeMode ()); NUnit.Framework.Assert.IsTrue("Replication queues weren't being populated after entering " + "safemode 2nd time", fsn.IsPopulatingReplQueues()); }
/// <exception cref="Org.Apache.Hadoop.Ipc.StandbyException"/> public override void CheckOperation(HAContext context, NameNode.OperationCategory op) { if (op == NameNode.OperationCategory.Unchecked || (op == NameNode.OperationCategory .Read && context.AllowStaleReads())) { return; } string msg = "Operation category " + op + " is not supported in state " + context .GetState(); throw new StandbyException(msg); }