/// <exception cref="System.IO.IOException"/> public virtual void TransitionToStandby(HAServiceProtocol.StateChangeRequestInfo reqInfo) { lock (this) { // call refreshAdminAcls before HA state transition // for the case that adminAcls have been updated in previous active RM try { RefreshAdminAcls(false); } catch (YarnException ex) { throw new ServiceFailedException("Can not execute refreshAdminAcls", ex); } UserGroupInformation user = CheckAccess("transitionToStandby"); CheckHaStateChange(reqInfo); try { rm.TransitionToStandby(true); RMAuditLogger.LogSuccess(user.GetShortUserName(), "transitionToStandby", "RMHAProtocolService" ); } catch (Exception e) { RMAuditLogger.LogFailure(user.GetShortUserName(), "transitionToStandby", string.Empty , "RMHAProtocolService", "Exception transitioning to standby"); throw new ServiceFailedException("Error when transitioning to Standby mode", e); } } }
/// <exception cref="System.Exception"/> public virtual void TestTransitionedToStandbyShouldNotHang() { configuration.SetBoolean(YarnConfiguration.AutoFailoverEnabled, false); Configuration conf = new YarnConfiguration(configuration); MemoryRMStateStore memStore = new _MemoryRMStateStore_464(); memStore.Init(conf); rm = new _MockRM_472(conf, memStore); rm.Init(conf); HAServiceProtocol.StateChangeRequestInfo requestInfo = new HAServiceProtocol.StateChangeRequestInfo (HAServiceProtocol.RequestSource.RequestByUser); NUnit.Framework.Assert.AreEqual(StateErr, HAServiceProtocol.HAServiceState.Initializing , rm.adminService.GetServiceStatus().GetState()); NUnit.Framework.Assert.IsFalse("RM is ready to become active before being started" , rm.adminService.GetServiceStatus().IsReadyToBecomeActive()); CheckMonitorHealth(); rm.Start(); CheckMonitorHealth(); CheckStandbyRMFunctionality(); // 2. Transition to Active. rm.adminService.TransitionToActive(requestInfo); // 3. Try Transition to standby Sharpen.Thread t = new Sharpen.Thread(new _Runnable_498(this)); // TODO Auto-generated catch block t.Start(); rm.GetRMContext().GetStateStore().UpdateApplicationState(null); t.Join(); // wait for thread to finish rm.adminService.TransitionToStandby(requestInfo); CheckStandbyRMFunctionality(); rm.Stop(); }
private HAServiceProtocolProtos.HAStateChangeRequestInfoProto Convert(HAServiceProtocol.StateChangeRequestInfo reqInfo) { HAServiceProtocolProtos.HARequestSource src; switch (reqInfo.GetSource()) { case HAServiceProtocol.RequestSource.RequestByUser: { src = HAServiceProtocolProtos.HARequestSource.RequestByUser; break; } case HAServiceProtocol.RequestSource.RequestByUserForced: { src = HAServiceProtocolProtos.HARequestSource.RequestByUserForced; break; } case HAServiceProtocol.RequestSource.RequestByZkfc: { src = HAServiceProtocolProtos.HARequestSource.RequestByZkfc; break; } default: { throw new ArgumentException("Bad source: " + reqInfo.GetSource()); } } return((HAServiceProtocolProtos.HAStateChangeRequestInfoProto)HAServiceProtocolProtos.HAStateChangeRequestInfoProto .NewBuilder().SetReqSource(src).Build()); }
// Other stuff is verified in the regular web-services related tests /// <summary>Test to verify the following RM HA transitions to the following states.</summary> /// <remarks> /// Test to verify the following RM HA transitions to the following states. /// 1. Standby: Should be a no-op /// 2. Active: Active services should start /// 3. Active: Should be a no-op. /// While active, submit a couple of jobs /// 4. Standby: Active services should stop /// 5. Active: Active services should start /// 6. Stop the RM: All services should stop and RM should not be ready to /// become Active /// </remarks> /// <exception cref="System.Exception"/> public virtual void TestFailoverAndTransitions() { configuration.SetBoolean(YarnConfiguration.AutoFailoverEnabled, false); Configuration conf = new YarnConfiguration(configuration); rm = new MockRM(conf); rm.Init(conf); HAServiceProtocol.StateChangeRequestInfo requestInfo = new HAServiceProtocol.StateChangeRequestInfo (HAServiceProtocol.RequestSource.RequestByUser); NUnit.Framework.Assert.AreEqual(StateErr, HAServiceProtocol.HAServiceState.Initializing , rm.adminService.GetServiceStatus().GetState()); NUnit.Framework.Assert.IsFalse("RM is ready to become active before being started" , rm.adminService.GetServiceStatus().IsReadyToBecomeActive()); CheckMonitorHealth(); rm.Start(); CheckMonitorHealth(); CheckStandbyRMFunctionality(); VerifyClusterMetrics(0, 0, 0, 0, 0, 0); // 1. Transition to Standby - must be a no-op rm.adminService.TransitionToStandby(requestInfo); CheckMonitorHealth(); CheckStandbyRMFunctionality(); VerifyClusterMetrics(0, 0, 0, 0, 0, 0); // 2. Transition to active rm.adminService.TransitionToActive(requestInfo); CheckMonitorHealth(); CheckActiveRMFunctionality(); VerifyClusterMetrics(1, 1, 1, 1, 2048, 1); // 3. Transition to active - no-op rm.adminService.TransitionToActive(requestInfo); CheckMonitorHealth(); CheckActiveRMFunctionality(); VerifyClusterMetrics(1, 2, 2, 2, 2048, 2); // 4. Transition to standby rm.adminService.TransitionToStandby(requestInfo); CheckMonitorHealth(); CheckStandbyRMFunctionality(); VerifyClusterMetrics(0, 0, 0, 0, 0, 0); // 5. Transition to active to check Active->Standby->Active works rm.adminService.TransitionToActive(requestInfo); CheckMonitorHealth(); CheckActiveRMFunctionality(); VerifyClusterMetrics(1, 1, 1, 1, 2048, 1); // 6. Stop the RM. All services should stop and RM should not be ready to // become active rm.Stop(); NUnit.Framework.Assert.AreEqual(StateErr, HAServiceProtocol.HAServiceState.Stopping , rm.adminService.GetServiceStatus().GetState()); NUnit.Framework.Assert.IsFalse("RM is ready to become active even after it is stopped" , rm.adminService.GetServiceStatus().IsReadyToBecomeActive()); NUnit.Framework.Assert.IsFalse("Active RM services are started", rm.AreActiveServicesRunning ()); CheckMonitorHealth(); }
public virtual void TestZKRootPathAcls() { HAServiceProtocol.StateChangeRequestInfo req = new HAServiceProtocol.StateChangeRequestInfo (HAServiceProtocol.RequestSource.RequestByUser); string rootPath = YarnConfiguration.DefaultZkRmStateStoreParentPath + "/" + ZKRMStateStore .RootZnodeName; // Start RM with HA enabled Configuration conf = CreateHARMConf("rm1,rm2", "rm1", 1234); conf.SetBoolean(YarnConfiguration.AutoFailoverEnabled, false); ResourceManager rm = new MockRM(conf); rm.Start(); rm.GetRMContext().GetRMAdminService().TransitionToActive(req); Stat stat = new Stat(); IList <ACL> acls = ((ZKRMStateStore)rm.GetRMContext().GetStateStore()).GetACLWithRetries (rootPath, stat); NUnit.Framework.Assert.AreEqual(acls.Count, 2); // CREATE and DELETE permissions for root node based on RM ID VerifyZKACL("digest", "localhost", ZooDefs.Perms.Create | ZooDefs.Perms.Delete, acls ); VerifyZKACL("world", "anyone", ZooDefs.Perms.All ^ (ZooDefs.Perms.Create | ZooDefs.Perms .Delete), acls); rm.Close(); // Now start RM with HA disabled. NoAuth Exception should not be thrown. conf.SetBoolean(YarnConfiguration.RmHaEnabled, false); rm = new MockRM(conf); rm.Start(); rm.GetRMContext().GetRMAdminService().TransitionToActive(req); acls = ((ZKRMStateStore)rm.GetRMContext().GetStateStore()).GetACLWithRetries(rootPath , stat); NUnit.Framework.Assert.AreEqual(acls.Count, 1); VerifyZKACL("world", "anyone", ZooDefs.Perms.All, acls); rm.Close(); // Start RM with HA enabled. conf.SetBoolean(YarnConfiguration.RmHaEnabled, true); rm = new MockRM(conf); rm.Start(); rm.GetRMContext().GetRMAdminService().TransitionToActive(req); acls = ((ZKRMStateStore)rm.GetRMContext().GetStateStore()).GetACLWithRetries(rootPath , stat); NUnit.Framework.Assert.AreEqual(acls.Count, 2); VerifyZKACL("digest", "localhost", ZooDefs.Perms.Create | ZooDefs.Perms.Delete, acls ); VerifyZKACL("world", "anyone", ZooDefs.Perms.All ^ (ZooDefs.Perms.Create | ZooDefs.Perms .Delete), acls); rm.Close(); }
/// <exception cref="System.IO.IOException"/> public virtual void TransitionToStandby(HAServiceProtocol.StateChangeRequestInfo reqInfo) { try { HAServiceProtocolProtos.TransitionToStandbyRequestProto req = ((HAServiceProtocolProtos.TransitionToStandbyRequestProto )HAServiceProtocolProtos.TransitionToStandbyRequestProto.NewBuilder().SetReqInfo (Convert(reqInfo)).Build()); rpcProxy.TransitionToStandby(NullController, req); } catch (ServiceException e) { throw ProtobufHelper.GetRemoteException(e); } }
public virtual void TestRMDispatcherForHA() { string errorMessageForEventHandler = "Expect to get the same number of handlers"; string errorMessageForService = "Expect to get the same number of services"; configuration.SetBoolean(YarnConfiguration.AutoFailoverEnabled, false); Configuration conf = new YarnConfiguration(configuration); rm = new _MockRM_313(conf); rm.Init(conf); int expectedEventHandlerCount = ((TestRMHA.MyCountingDispatcher)rm.GetRMContext() .GetDispatcher()).GetEventHandlerCount(); int expectedServiceCount = rm.GetServices().Count; NUnit.Framework.Assert.IsTrue(expectedEventHandlerCount != 0); HAServiceProtocol.StateChangeRequestInfo requestInfo = new HAServiceProtocol.StateChangeRequestInfo (HAServiceProtocol.RequestSource.RequestByUser); NUnit.Framework.Assert.AreEqual(StateErr, HAServiceProtocol.HAServiceState.Initializing , rm.adminService.GetServiceStatus().GetState()); NUnit.Framework.Assert.IsFalse("RM is ready to become active before being started" , rm.adminService.GetServiceStatus().IsReadyToBecomeActive()); rm.Start(); //call transitions to standby and active a couple of times rm.adminService.TransitionToStandby(requestInfo); rm.adminService.TransitionToActive(requestInfo); rm.adminService.TransitionToStandby(requestInfo); rm.adminService.TransitionToActive(requestInfo); rm.adminService.TransitionToStandby(requestInfo); TestRMHA.MyCountingDispatcher dispatcher = (TestRMHA.MyCountingDispatcher)rm.GetRMContext ().GetDispatcher(); NUnit.Framework.Assert.IsTrue(!dispatcher.IsStopped()); rm.adminService.TransitionToActive(requestInfo); NUnit.Framework.Assert.AreEqual(errorMessageForEventHandler, expectedEventHandlerCount , ((TestRMHA.MyCountingDispatcher)rm.GetRMContext().GetDispatcher()).GetEventHandlerCount ()); NUnit.Framework.Assert.AreEqual(errorMessageForService, expectedServiceCount, rm. GetServices().Count); // Keep the dispatcher reference before transitioning to standby dispatcher = (TestRMHA.MyCountingDispatcher)rm.GetRMContext().GetDispatcher(); rm.adminService.TransitionToStandby(requestInfo); NUnit.Framework.Assert.AreEqual(errorMessageForEventHandler, expectedEventHandlerCount , ((TestRMHA.MyCountingDispatcher)rm.GetRMContext().GetDispatcher()).GetEventHandlerCount ()); NUnit.Framework.Assert.AreEqual(errorMessageForService, expectedServiceCount, rm. GetServices().Count); NUnit.Framework.Assert.IsTrue(dispatcher.IsStopped()); rm.Stop(); }
public virtual void TestFailoverClearsRMContext() { configuration.SetBoolean(YarnConfiguration.AutoFailoverEnabled, false); configuration.SetBoolean(YarnConfiguration.RecoveryEnabled, true); Configuration conf = new YarnConfiguration(configuration); MemoryRMStateStore memStore = new MemoryRMStateStore(); memStore.Init(conf); // 1. start RM rm = new MockRM(conf, memStore); rm.Init(conf); rm.Start(); HAServiceProtocol.StateChangeRequestInfo requestInfo = new HAServiceProtocol.StateChangeRequestInfo (HAServiceProtocol.RequestSource.RequestByUser); CheckMonitorHealth(); CheckStandbyRMFunctionality(); // 2. Transition to active rm.adminService.TransitionToActive(requestInfo); CheckMonitorHealth(); CheckActiveRMFunctionality(); VerifyClusterMetrics(1, 1, 1, 1, 2048, 1); NUnit.Framework.Assert.AreEqual(1, rm.GetRMContext().GetRMNodes().Count); NUnit.Framework.Assert.AreEqual(1, rm.GetRMContext().GetRMApps().Count); // 3. Create new RM rm = new _MockRM_550(conf, memStore); rm.Init(conf); rm.Start(); CheckMonitorHealth(); CheckStandbyRMFunctionality(); // 4. Try Transition to active, throw exception try { rm.adminService.TransitionToActive(requestInfo); NUnit.Framework.Assert.Fail("Transitioned to Active should throw exception."); } catch (Exception e) { NUnit.Framework.Assert.IsTrue("Error when transitioning to Active mode".Contains( e.Message)); } // 5. Clears the metrics VerifyClusterMetrics(0, 0, 0, 0, 0, 0); NUnit.Framework.Assert.AreEqual(0, rm.GetRMContext().GetRMNodes().Count); NUnit.Framework.Assert.AreEqual(0, rm.GetRMContext().GetRMApps().Count); }
/// <exception cref="System.IO.IOException"/> public virtual void TransitionToActive(HAServiceProtocol.StateChangeRequestInfo reqInfo ) { lock (this) { // call refreshAdminAcls before HA state transition // for the case that adminAcls have been updated in previous active RM try { RefreshAdminAcls(false); } catch (YarnException ex) { throw new ServiceFailedException("Can not execute refreshAdminAcls", ex); } UserGroupInformation user = CheckAccess("transitionToActive"); CheckHaStateChange(reqInfo); try { rm.TransitionToActive(); } catch (Exception e) { RMAuditLogger.LogFailure(user.GetShortUserName(), "transitionToActive", string.Empty , "RMHAProtocolService", "Exception transitioning to active"); throw new ServiceFailedException("Error when transitioning to Active mode", e); } try { // call all refresh*s for active RM to get the updated configurations. RefreshAll(); } catch (Exception e) { Log.Error("RefreshAll failed so firing fatal event", e); rmContext.GetDispatcher().GetEventHandler().Handle(new RMFatalEvent(RMFatalEventType .TransitionToActiveFailed, e)); throw new ServiceFailedException("Error on refreshAll during transistion to Active" , e); } RMAuditLogger.LogSuccess(user.GetShortUserName(), "transitionToActive", "RMHAProtocolService" ); } }
public virtual void TestFencing() { HAServiceProtocol.StateChangeRequestInfo req = new HAServiceProtocol.StateChangeRequestInfo (HAServiceProtocol.RequestSource.RequestByUser); Configuration conf1 = CreateHARMConf("rm1,rm2", "rm1", 1234); conf1.SetBoolean(YarnConfiguration.AutoFailoverEnabled, false); ResourceManager rm1 = new ResourceManager(); rm1.Init(conf1); rm1.Start(); rm1.GetRMContext().GetRMAdminService().TransitionToActive(req); NUnit.Framework.Assert.AreEqual("RM with ZKStore didn't start", Service.STATE.Started , rm1.GetServiceState()); NUnit.Framework.Assert.AreEqual("RM should be Active", HAServiceProtocol.HAServiceState .Active, rm1.GetRMContext().GetRMAdminService().GetServiceStatus().GetState()); Configuration conf2 = CreateHARMConf("rm1,rm2", "rm2", 5678); conf2.SetBoolean(YarnConfiguration.AutoFailoverEnabled, false); ResourceManager rm2 = new ResourceManager(); rm2.Init(conf2); rm2.Start(); rm2.GetRMContext().GetRMAdminService().TransitionToActive(req); NUnit.Framework.Assert.AreEqual("RM with ZKStore didn't start", Service.STATE.Started , rm2.GetServiceState()); NUnit.Framework.Assert.AreEqual("RM should be Active", HAServiceProtocol.HAServiceState .Active, rm2.GetRMContext().GetRMAdminService().GetServiceStatus().GetState()); for (int i = 0; i < ZkTimeoutMs / 50; i++) { if (HAServiceProtocol.HAServiceState.Active == rm1.GetRMContext().GetRMAdminService ().GetServiceStatus().GetState()) { Sharpen.Thread.Sleep(100); } } NUnit.Framework.Assert.AreEqual("RM should have been fenced", HAServiceProtocol.HAServiceState .Standby, rm1.GetRMContext().GetRMAdminService().GetServiceStatus().GetState()); NUnit.Framework.Assert.AreEqual("RM should be Active", HAServiceProtocol.HAServiceState .Active, rm2.GetRMContext().GetRMAdminService().GetServiceStatus().GetState()); }
/// <exception cref="System.Exception"/> public virtual void TestTransitionedToActiveRefreshFail() { configuration.SetBoolean(YarnConfiguration.AutoFailoverEnabled, false); YarnConfiguration conf = new YarnConfiguration(configuration); configuration = new CapacitySchedulerConfiguration(conf); rm = new _MockRM_588(this, configuration); rm.Init(configuration); rm.Start(); HAServiceProtocol.StateChangeRequestInfo requestInfo = new HAServiceProtocol.StateChangeRequestInfo (HAServiceProtocol.RequestSource.RequestByUser); configuration.Set("yarn.scheduler.capacity.root.default.capacity", "100"); rm.adminService.TransitionToStandby(requestInfo); NUnit.Framework.Assert.AreEqual(HAServiceProtocol.HAServiceState.Standby, rm.GetRMContext ().GetHAServiceState()); configuration.Set("yarn.scheduler.capacity.root.default.capacity", "200"); try { rm.adminService.TransitionToActive(requestInfo); } catch (Exception e) { NUnit.Framework.Assert.IsTrue("Error on refreshAll during transistion to Active". Contains(e.Message)); } TestRMHA.FailFastDispatcher dispatcher = ((TestRMHA.FailFastDispatcher)rm.rmContext .GetDispatcher()); dispatcher.Await(); NUnit.Framework.Assert.AreEqual(1, dispatcher.GetEventCount()); // Making correct conf and check the state configuration.Set("yarn.scheduler.capacity.root.default.capacity", "100"); rm.adminService.TransitionToActive(requestInfo); NUnit.Framework.Assert.AreEqual(HAServiceProtocol.HAServiceState.Active, rm.GetRMContext ().GetHAServiceState()); rm.adminService.TransitionToStandby(requestInfo); NUnit.Framework.Assert.AreEqual(HAServiceProtocol.HAServiceState.Standby, rm.GetRMContext ().GetHAServiceState()); }
/// <exception cref="System.Exception"/> public virtual void TestFailoverWhenTransitionToActiveThrowException() { configuration.SetBoolean(YarnConfiguration.AutoFailoverEnabled, false); Configuration conf = new YarnConfiguration(configuration); MemoryRMStateStore memStore = new _MemoryRMStateStore_414(); // first time throw exception // start RM memStore.Init(conf); rm = new MockRM(conf, memStore); rm.Init(conf); HAServiceProtocol.StateChangeRequestInfo requestInfo = new HAServiceProtocol.StateChangeRequestInfo (HAServiceProtocol.RequestSource.RequestByUser); NUnit.Framework.Assert.AreEqual(StateErr, HAServiceProtocol.HAServiceState.Initializing , rm.adminService.GetServiceStatus().GetState()); NUnit.Framework.Assert.IsFalse("RM is ready to become active before being started" , rm.adminService.GetServiceStatus().IsReadyToBecomeActive()); CheckMonitorHealth(); rm.Start(); CheckMonitorHealth(); CheckStandbyRMFunctionality(); // 2. Try Transition to active, throw exception try { rm.adminService.TransitionToActive(requestInfo); NUnit.Framework.Assert.Fail("Transitioned to Active should throw exception."); } catch (Exception e) { NUnit.Framework.Assert.IsTrue("Error when transitioning to Active mode".Contains( e.Message)); } // 3. Transition to active, success rm.adminService.TransitionToActive(requestInfo); CheckMonitorHealth(); CheckActiveRMFunctionality(); }
/// <summary>Check that a request to change this node's HA state is valid.</summary> /// <remarks> /// Check that a request to change this node's HA state is valid. /// In particular, verifies that, if auto failover is enabled, non-forced /// requests from the HAAdmin CLI are rejected, and vice versa. /// </remarks> /// <param name="req">the request to check</param> /// <exception cref="Org.Apache.Hadoop.Security.AccessControlException">if the request is disallowed /// </exception> private void CheckHaStateChange(HAServiceProtocol.StateChangeRequestInfo req) { switch (req.GetSource()) { case HAServiceProtocol.RequestSource.RequestByUser: { if (autoFailoverEnabled) { throw new AccessControlException("Manual failover for this ResourceManager is disallowed, " + "because automatic failover is enabled."); } break; } case HAServiceProtocol.RequestSource.RequestByUserForced: { if (autoFailoverEnabled) { Log.Warn("Allowing manual failover from " + Org.Apache.Hadoop.Ipc.Server.GetRemoteAddress () + " even though automatic failover is enabled, because the user " + "specified the force flag" ); } break; } case HAServiceProtocol.RequestSource.RequestByZkfc: { if (!autoFailoverEnabled) { throw new AccessControlException("Request from ZK failover controller at " + Org.Apache.Hadoop.Ipc.Server .GetRemoteAddress() + " denied " + "since automatic failover is not enabled"); } break; } } }
public virtual void TestTransitionsWhenAutomaticFailoverEnabled() { string ErrUnforcedRequest = "User request succeeded even when " + "automatic failover is enabled"; Configuration conf = new YarnConfiguration(configuration); rm = new MockRM(conf); rm.Init(conf); rm.Start(); HAServiceProtocol.StateChangeRequestInfo requestInfo = new HAServiceProtocol.StateChangeRequestInfo (HAServiceProtocol.RequestSource.RequestByUser); // Transition to standby try { rm.adminService.TransitionToStandby(requestInfo); NUnit.Framework.Assert.Fail(ErrUnforcedRequest); } catch (AccessControlException) { } // expected CheckMonitorHealth(); CheckStandbyRMFunctionality(); // Transition to active try { rm.adminService.TransitionToActive(requestInfo); NUnit.Framework.Assert.Fail(ErrUnforcedRequest); } catch (AccessControlException) { } // expected CheckMonitorHealth(); CheckStandbyRMFunctionality(); string ErrForcedRequest = "Forced request by user should work " + "even if automatic failover is enabled"; requestInfo = new HAServiceProtocol.StateChangeRequestInfo(HAServiceProtocol.RequestSource .RequestByUserForced); // Transition to standby try { rm.adminService.TransitionToStandby(requestInfo); } catch (AccessControlException) { NUnit.Framework.Assert.Fail(ErrForcedRequest); } CheckMonitorHealth(); CheckStandbyRMFunctionality(); // Transition to active try { rm.adminService.TransitionToActive(requestInfo); } catch (AccessControlException) { NUnit.Framework.Assert.Fail(ErrForcedRequest); } CheckMonitorHealth(); CheckActiveRMFunctionality(); }
public virtual void TestRMHAWithFileSystemBasedConfiguration() { HAServiceProtocol.StateChangeRequestInfo requestInfo = new HAServiceProtocol.StateChangeRequestInfo (HAServiceProtocol.RequestSource.RequestByUser); configuration.Set(YarnConfiguration.RmConfigurationProviderClass, "org.apache.hadoop.yarn.FileSystemBasedConfigurationProvider" ); configuration.SetBoolean(YarnConfiguration.RmHaEnabled, true); configuration.SetBoolean(YarnConfiguration.AutoFailoverEnabled, false); configuration.Set(YarnConfiguration.RmHaIds, "rm1,rm2"); int @base = 100; foreach (string confKey in YarnConfiguration.GetServiceAddressConfKeys(configuration )) { configuration.Set(HAUtil.AddSuffix(confKey, "rm1"), "0.0.0.0:" + (@base + 20)); configuration.Set(HAUtil.AddSuffix(confKey, "rm2"), "0.0.0.0:" + (@base + 40)); @base = @base * 2; } Configuration conf1 = new Configuration(configuration); conf1.Set(YarnConfiguration.RmHaId, "rm1"); Configuration conf2 = new Configuration(configuration); conf2.Set(YarnConfiguration.RmHaId, "rm2"); // upload default configurations UploadDefaultConfiguration(); MockRM rm1 = null; MockRM rm2 = null; try { rm1 = new MockRM(conf1); rm1.Init(conf1); rm1.Start(); NUnit.Framework.Assert.IsTrue(rm1.GetRMContext().GetHAServiceState() == HAServiceProtocol.HAServiceState .Standby); rm2 = new MockRM(conf2); rm2.Init(conf1); rm2.Start(); NUnit.Framework.Assert.IsTrue(rm2.GetRMContext().GetHAServiceState() == HAServiceProtocol.HAServiceState .Standby); rm1.adminService.TransitionToActive(requestInfo); NUnit.Framework.Assert.IsTrue(rm1.GetRMContext().GetHAServiceState() == HAServiceProtocol.HAServiceState .Active); CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration(); csConf.Set("yarn.scheduler.capacity.maximum-applications", "5000"); UploadConfiguration(csConf, "capacity-scheduler.xml"); rm1.adminService.RefreshQueues(RefreshQueuesRequest.NewInstance()); int maxApps = ((CapacityScheduler)rm1.GetRMContext().GetScheduler()).GetConfiguration ().GetMaximumSystemApplications(); NUnit.Framework.Assert.AreEqual(maxApps, 5000); // Before failover happens, the maxApps is // still the default value on the standby rm : rm2 int maxAppsBeforeFailOver = ((CapacityScheduler)rm2.GetRMContext().GetScheduler() ).GetConfiguration().GetMaximumSystemApplications(); NUnit.Framework.Assert.AreEqual(maxAppsBeforeFailOver, 10000); // Do the failover rm1.adminService.TransitionToStandby(requestInfo); rm2.adminService.TransitionToActive(requestInfo); NUnit.Framework.Assert.IsTrue(rm1.GetRMContext().GetHAServiceState() == HAServiceProtocol.HAServiceState .Standby); NUnit.Framework.Assert.IsTrue(rm2.GetRMContext().GetHAServiceState() == HAServiceProtocol.HAServiceState .Active); int maxAppsAfter = ((CapacityScheduler)rm2.GetRMContext().GetScheduler()).GetConfiguration ().GetMaximumSystemApplications(); NUnit.Framework.Assert.AreEqual(maxAppsAfter, 5000); } finally { if (rm1 != null) { rm1.Stop(); } if (rm2 != null) { rm2.Stop(); } } }