synchronized void transitionToActive() throws Exception { if (rmContext.getHAServiceState() == HAServiceProtocol.HAServiceState.ACTIVE) { LOG.info("Already in active state"); return; } LOG.info("Transitioning to active state"); this.rmLoginUGI.doAs(new PrivilegedExceptionAction<Void>() { @Override public Void run() throws Exception { try { startActiveServices(); return null; } catch (Exception e) { reinitialize(true); throw e; } } }); rmContext.setHAServiceState(HAServiceProtocol.HAServiceState.ACTIVE); LOG.info("Transitioned to active state"); }
synchronized void transitionToActive() throws Exception { if (rmContext.getHAServiceState() == HAServiceProtocol.HAServiceState.ACTIVE) { LOG.info("Already in active state"); return; } LOG.info("Transitioning to active state"); this.rmLoginUGI.doAs(new PrivilegedExceptionAction<Void>() { @Override public Void run() throws Exception { try { startActiveServices(); return null; } catch (Exception e) { reinitialize(true); throw e; } } }); rmContext.setHAServiceState(HAServiceProtocol.HAServiceState.ACTIVE); LOG.info("Transitioned to active state"); }
synchronized void transitionToActive() throws Exception { if (rmContext.getHAServiceState() == HAServiceProtocol.HAServiceState.ACTIVE) { LOG.info("Already in active state"); return; } LOG.info("Transitioning to active state"); this.rmLoginUGI.doAs(new PrivilegedExceptionAction<Void>() { @Override public Void run() throws Exception { try { startActiveServices(); return null; } catch (Exception e) { reinitialize(true); throw e; } } }); rmContext.setHAServiceState(HAServiceProtocol.HAServiceState.ACTIVE); LOG.info("Transitioned to active state"); }
synchronized void transitionToStandby(boolean initialize) throws Exception { if (rmContext.getHAServiceState() == HAServiceProtocol.HAServiceState.STANDBY) { LOG.info("Already in standby state"); return; } LOG.info("Transitioning to standby state"); HAServiceState state = rmContext.getHAServiceState(); rmContext.setHAServiceState(HAServiceProtocol.HAServiceState.STANDBY); if (state == HAServiceProtocol.HAServiceState.ACTIVE) { stopActiveServices(); reinitialize(initialize); } LOG.info("Transitioned to standby state"); }
synchronized void transitionToStandby(boolean initialize) throws Exception { if (rmContext.getHAServiceState() == HAServiceProtocol.HAServiceState.STANDBY) { LOG.info("Already in standby state"); return; } LOG.info("Transitioning to standby state"); HAServiceState state = rmContext.getHAServiceState(); rmContext.setHAServiceState(HAServiceProtocol.HAServiceState.STANDBY); if (state == HAServiceProtocol.HAServiceState.ACTIVE) { stopActiveServices(); reinitialize(initialize); } LOG.info("Transitioned to standby state"); }
synchronized void transitionToStandby(boolean initialize) throws Exception { if (rmContext.getHAServiceState() == HAServiceProtocol.HAServiceState.STANDBY) { LOG.info("Already in standby state"); return; } LOG.info("Transitioning to standby state"); HAServiceState state = rmContext.getHAServiceState(); rmContext.setHAServiceState(HAServiceProtocol.HAServiceState.STANDBY); if (state == HAServiceProtocol.HAServiceState.ACTIVE) { stopActiveServices(); reinitialize(initialize); } LOG.info("Transitioned to standby state"); }
@Override protected void serviceStop() throws Exception { if (webApp != null) { webApp.stop(); } if (fetcher != null) { fetcher.stop(); } if (configurationProvider != null) { configurationProvider.close(); } super.serviceStop(); transitionToStandby(false); rmContext.setHAServiceState(HAServiceState.STOPPING); }
@Override protected void serviceStop() throws Exception { if (webApp != null) { webApp.stop(); } if (fetcher != null) { fetcher.stop(); } if (configurationProvider != null) { configurationProvider.close(); } super.serviceStop(); transitionToStandby(false); rmContext.setHAServiceState(HAServiceState.STOPPING); }
@Override protected void serviceStop() throws Exception { if (webApp != null) { webApp.stop(); } if (fetcher != null) { fetcher.stop(); } if (configurationProvider != null) { configurationProvider.close(); } super.serviceStop(); if (zkManager != null) { zkManager.close(); } transitionToStandby(false); rmContext.setHAServiceState(HAServiceState.STOPPING); }
@Test public void testModifyLabelsOnNodesWithDistributedConfigurationDisabled() throws IOException, YarnException { // create RM and set it's ACTIVE MockRM rm = new MockRM(); ((RMContextImpl) rm.getRMContext()) .setHAServiceState(HAServiceState.ACTIVE); RMNodeLabelsManager labelMgr = rm.rmContext.getNodeLabelManager(); // by default, distributed configuration for node label is disabled, this // should pass labelMgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of("x", "y")); rm.adminService.replaceLabelsOnNode(ReplaceLabelsOnNodeRequest .newInstance(ImmutableMap.of(NodeId.newInstance("host", 0), (Set<String>) ImmutableSet.of("x")))); rm.close(); }
@Test(expected = YarnException.class) public void testModifyLabelsOnNodesWithCentralizedConfigurationDisabled() throws IOException, YarnException { // create RM and set it's ACTIVE, and set distributed node label // configuration to true MockRM rm = new MockRM(); rm.adminService.isCentralizedNodeLabelConfiguration = false; ((RMContextImpl) rm.getRMContext()) .setHAServiceState(HAServiceState.ACTIVE); RMNodeLabelsManager labelMgr = rm.rmContext.getNodeLabelManager(); // by default, distributed configuration for node label is disabled, this // should pass labelMgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of("x", "y")); rm.adminService.replaceLabelsOnNode(ReplaceLabelsOnNodeRequest .newInstance(ImmutableMap.of(NodeId.newInstance("host", 0), (Set<String>) ImmutableSet.of("x")))); rm.close(); }
@Test public void testRemoveClusterNodeLabelsWithCentralizedConfigurationDisabled() throws IOException, YarnException { // create RM and set it's ACTIVE MockRM rm = new MockRM(); ((RMContextImpl) rm.getRMContext()) .setHAServiceState(HAServiceState.ACTIVE); RMNodeLabelsManager labelMgr = rm.rmContext.getNodeLabelManager(); rm.adminService.isCentralizedNodeLabelConfiguration = false; // by default, distributed configuration for node label is disabled, this // should pass labelMgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of("x", "y")); rm.adminService .removeFromClusterNodeLabels(RemoveFromClusterNodeLabelsRequest .newInstance((Set<String>) ImmutableSet.of("x"))); Set<String> clusterNodeLabels = labelMgr.getClusterNodeLabelNames(); assertEquals(1,clusterNodeLabels.size()); rm.close(); }
.setHAServiceState(HAServiceState.ACTIVE); setActiveAndInactiveNodes(rm);
.setHAServiceState(HAServiceState.ACTIVE); setActiveAndInactiveNodes(rm); RMNodeLabelsManager labelMgr = rm.rmContext.getNodeLabelManager();