@Override public void becomeActive() throws ServiceFailedException { try { rmContext.getRMAdminService().transitionToActive(req); } catch (Exception e) { throw new ServiceFailedException("RM could not transition to Active", e); } }
@Override public void becomeActive() throws ServiceFailedException { try { rmContext.getRMAdminService().transitionToActive(req); } catch (Exception e) { throw new ServiceFailedException("RM could not transition to Active", e); } }
@Override public void isLeader() { LOG.info(rmId + "is elected leader, transitioning to active"); try { rm.getRMContext().getRMAdminService() .transitionToActive( new HAServiceProtocol.StateChangeRequestInfo( HAServiceProtocol.RequestSource.REQUEST_BY_ZKFC)); } catch (Exception e) { LOG.info(rmId + " failed to transition to active, giving up leadership", e); notLeader(); rejoinElection(); } }
@Override public void becomeActive() throws ServiceFailedException { cancelDisconnectTimer(); try { rm.getRMContext().getRMAdminService().transitionToActive(req); } catch (Exception e) { throw new ServiceFailedException("RM could not transition to Active", e); } }
/** * Helper method to test that neutral mode plays well with an active * transition. * * @param as the admin service * @param ees the embedded elector service * @throws IOException if there's an issue transitioning * @throws InterruptedException if interrupted * @throws TimeoutException if waitFor timeout reached */ private void testCallbackSynchronizationActive(AdminService as, ActiveStandbyElectorBasedElectorService ees) throws IOException, InterruptedException, TimeoutException { ees.becomeActive(); GenericTestUtils.waitFor( () -> transitionToActiveCounter.get() >= 1, 500, 10 * 1000); verify(as, times(1)).transitionToActive(any()); verify(as, never()).transitionToStandby(any()); }
verify(as, times(1)).transitionToActive(any()); verify(as, never()).transitionToStandby(any());
@Override protected synchronized void serviceStart() throws Exception { startResourceManager(index); if(index == 0 && resourceManagers[index].getRMContext().isHAEnabled()) { resourceManagers[index].getRMContext().getRMAdminService() .transitionToActive(new HAServiceProtocol.StateChangeRequestInfo( HAServiceProtocol.RequestSource.REQUEST_BY_USER_FORCED)); } Configuration conf = resourceManagers[index].getConfig(); LOG.info("Starting resourcemanager " + index); LOG.info("MiniYARN ResourceManager address: " + conf.get(YarnConfiguration.RM_ADDRESS)); LOG.info("MiniYARN ResourceManager web address: " + WebAppUtils .getRMWebAppURLWithoutScheme(conf)); super.serviceStart(); }
@Override protected synchronized void serviceStart() throws Exception { startResourceManager(index); if(index == 0 && resourceManagers[index].getRMContext().isHAEnabled()) { resourceManagers[index].getRMContext().getRMAdminService() .transitionToActive(new HAServiceProtocol.StateChangeRequestInfo( HAServiceProtocol.RequestSource.REQUEST_BY_USER_FORCED)); } LOG.info("MiniYARN ResourceManager address: " + getConfig().get(YarnConfiguration.RM_ADDRESS)); LOG.info("MiniYARN ResourceManager web address: " + WebAppUtils.getRMWebAppURLWithoutScheme(getConfig())); super.serviceStart(); }
@Test public void testFormatStateStoreCmdForZK() throws Exception { StateChangeRequestInfo req = new StateChangeRequestInfo( HAServiceProtocol.RequestSource.REQUEST_BY_USER); try (TestingServer curatorTestingServer = TestZKRMStateStore.setupCuratorServer(); CuratorFramework curatorFramework = TestZKRMStateStore. setupCuratorFramework(curatorTestingServer)) { Configuration conf = TestZKRMStateStore.createHARMConf("rm1,rm2", "rm1", 1234, false, curatorTestingServer); ResourceManager rm = new MockRM(conf); rm.start(); rm.getRMContext().getRMAdminService().transitionToActive(req); String zkStateRoot = ZKRMStateStore.ROOT_ZNODE_NAME; assertEquals("RM State store parent path should have a child node " + zkStateRoot, zkStateRoot, curatorFramework.getChildren().forPath( YarnConfiguration.DEFAULT_ZK_RM_STATE_STORE_PARENT_PATH).get(0)); rm.close(); try { ResourceManager.deleteRMStateStore(conf); } catch (Exception e) { fail("Exception should not be thrown during format rm state store" + " operation."); } assertTrue("After store format parent path should have no child nodes", curatorFramework.getChildren().forPath( YarnConfiguration.DEFAULT_ZK_RM_STATE_STORE_PARENT_PATH).isEmpty()); } }
protected void explicitFailover() throws IOException { rm1.adminService.transitionToStandby(requestInfo); rm2.adminService.transitionToActive(requestInfo); Assert.assertTrue(rm1.getRMContext().getHAServiceState() == HAServiceState.STANDBY); Assert.assertTrue(rm2.getRMContext().getHAServiceState() == HAServiceState.ACTIVE); }
protected void explicitFailover() throws IOException { rm1.adminService.transitionToStandby(requestInfo); rm2.adminService.transitionToActive(requestInfo); Assert.assertTrue(rm1.getRMContext().getHAServiceState() == HAServiceState.STANDBY); Assert.assertTrue(rm2.getRMContext().getHAServiceState() == HAServiceState.ACTIVE); }
HAServiceProtocol.RequestSource.REQUEST_BY_USER); rm.adminService.transitionToActive(requestInfo); rm.adminService.transitionToActive(requestInfo);
rm.adminService.transitionToActive(requestInfo); checkMonitorHealth(); checkActiveRMFunctionality(); rm.adminService.transitionToActive(requestInfo); checkMonitorHealth(); checkActiveRMFunctionality();
@Test public void testSecureRMBecomeActive() throws IOException, YarnException { StateChangeRequestInfo requestInfo = new StateChangeRequestInfo( HAServiceProtocol.RequestSource.REQUEST_BY_USER); updateConfigurationForRMHA(); configuration.setBoolean( CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION, true); configuration.set(YarnConfiguration.RM_HA_ID, "rm1"); // upload default configurations uploadDefaultConfiguration(); ResourceManager resourceManager = new ResourceManager(); try { resourceManager.init(configuration); resourceManager.start(); Assert.assertTrue(resourceManager.getRMContext().getHAServiceState() == HAServiceState.STANDBY); resourceManager.adminService.transitionToActive(requestInfo); } finally { resourceManager.close(); } }
@Test public void testSecureRMBecomeActive() throws IOException, YarnException { StateChangeRequestInfo requestInfo = new StateChangeRequestInfo( HAServiceProtocol.RequestSource.REQUEST_BY_USER); updateConfigurationForRMHA(); configuration.setBoolean( CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION, true); configuration.set(YarnConfiguration.RM_HA_ID, "rm1"); // upload default configurations uploadDefaultConfiguration(); ResourceManager resourceManager = new ResourceManager(); try { resourceManager.init(configuration); resourceManager.start(); Assert.assertTrue(resourceManager.getRMContext().getHAServiceState() == HAServiceState.STANDBY); resourceManager.adminService.transitionToActive(requestInfo); } finally { resourceManager.close(); } }
private void explicitFailover(MockRM rm) throws IOException { rm.getAdminService().transitionToStandby(requestInfo); Assert.assertTrue(rm.getRMContext() .getHAServiceState() == HAServiceProtocol.HAServiceState.STANDBY); rm.getAdminService().transitionToActive(requestInfo); Assert.assertTrue(rm.getRMContext() .getHAServiceState() == HAServiceProtocol.HAServiceState.ACTIVE); lastHearbeatTS = 0; stateStore = rm.getFederationStateStoreService().getStateStoreClient(); }
protected void startRMs(MockRM rm1, Configuration confForRM1, MockRM rm2, Configuration confForRM2) throws IOException { rm1.init(confForRM1); rm1.start(); Assert.assertTrue(rm1.getRMContext().getHAServiceState() == HAServiceState.STANDBY); rm2.init(confForRM2); rm2.start(); Assert.assertTrue(rm2.getRMContext().getHAServiceState() == HAServiceState.STANDBY); rm1.adminService.transitionToActive(requestInfo); Assert.assertTrue(rm1.getRMContext().getHAServiceState() == HAServiceState.ACTIVE); } }
protected void startRMs(MockRM rm1, Configuration confForRM1, MockRM rm2, Configuration confForRM2) throws IOException { rm1.init(confForRM1); rm1.start(); Assert.assertTrue(rm1.getRMContext().getHAServiceState() == HAServiceState.STANDBY); rm2.init(confForRM2); rm2.start(); Assert.assertTrue(rm2.getRMContext().getHAServiceState() == HAServiceState.STANDBY); rm1.adminService.transitionToActive(requestInfo); Assert.assertTrue(rm1.getRMContext().getHAServiceState() == HAServiceState.ACTIVE); } }
rm1.init(conf1); rm1.start(); rm1.getRMContext().getRMAdminService().transitionToActive(req); assertEquals("RM with ZKStore didn't start", Service.STATE.STARTED, rm1.getServiceState()); rm2.init(conf2); rm2.start(); rm2.getRMContext().getRMAdminService().transitionToActive(req); assertEquals("RM with ZKStore didn't start", Service.STATE.STARTED, rm2.getServiceState());
ResourceManager rm1 = new MockRM(conf1); rm1.start(); rm1.getRMContext().getRMAdminService().transitionToActive(req); assertEquals("RM with ZKStore didn't start", Service.STATE.STARTED, rm1.getServiceState()); ResourceManager rm2 = new MockRM(conf2); rm2.start(); rm2.getRMContext().getRMAdminService().transitionToActive(req); assertEquals("RM with ZKStore didn't start", Service.STATE.STARTED, rm2.getServiceState());