private void startRM() throws IOException, ClassNotFoundException { Configuration rmConf = new YarnConfiguration(); String schedulerClass = rmConf.get(YarnConfiguration.RM_SCHEDULER); // For CapacityScheduler we use a sub-classing instead of wrapping // to allow scheduler-specific invocations from monitors to work // this can be used for other schedulers as well if we care to // exercise/track behaviors that are not common to the scheduler api if(Class.forName(schedulerClass) == CapacityScheduler.class) { rmConf.set(YarnConfiguration.RM_SCHEDULER, SLSCapacityScheduler.class.getName()); } else { rmConf.set(YarnConfiguration.RM_SCHEDULER, ResourceSchedulerWrapper.class.getName()); rmConf.set(SLSConfiguration.RM_SCHEDULER, schedulerClass); } rmConf.set(SLSConfiguration.METRICS_OUTPUT_DIR, metricsOutputDir); rm = new ResourceManager(); rm.init(rmConf); rm.start(); }
@Before public void setUp() throws Exception { resourceManager = new ResourceManager(); Configuration conf = new Configuration(); conf.setClass(YarnConfiguration.RM_SCHEDULER, FifoScheduler.class, ResourceScheduler.class); resourceManager.init(conf); }
@Test public void testNMExpiryAndHeartbeatIntervalsValidation() throws Exception { Configuration conf = new YarnConfiguration(); conf.setLong(YarnConfiguration.RM_NM_EXPIRY_INTERVAL_MS, 1000); conf.setLong(YarnConfiguration.RM_NM_HEARTBEAT_INTERVAL_MS, 1001); resourceManager = new ResourceManager();; try { resourceManager.init(conf); } catch (YarnRuntimeException e) { // Exception is expected. if (!e.getMessage().startsWith("Nodemanager expiry interval should be no" + " less than heartbeat interval")) { throw e; } } }
@Test public void testResourceManagerMXBean() throws Exception { try (ResourceManager resourceManager = new ResourceManager()) { Configuration conf = new YarnConfiguration(); UserGroupInformation.setConfiguration(conf); resourceManager.init(conf); MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); ObjectName mxbeanName = new ObjectName( "Hadoop:service=ResourceManager,name=ResourceManager"); // Get attribute "SecurityEnabled" boolean securityEnabled = (boolean) mbs.getAttribute(mxbeanName, "SecurityEnabled"); Assert.assertEquals(resourceManager.isSecurityEnabled(), securityEnabled); } } }
@Test (timeout = 30000) public void testResourceManagerInitConfigValidation() throws Exception { Configuration conf = new YarnConfiguration(); conf.setInt(YarnConfiguration.RM_AM_MAX_ATTEMPTS, -1); resourceManager = new ResourceManager(); try { resourceManager.init(conf); fail("Exception is expected because the global max attempts" + " is negative."); } catch (YarnRuntimeException e) { // Exception is expected. if (!e.getMessage().startsWith( "Invalid global max attempts configuration")) throw e; } }
private synchronized void initResourceManager(int index, Configuration conf) { if (HAUtil.isHAEnabled(conf)) { conf.set(YarnConfiguration.RM_HA_ID, rmIds[index]); } resourceManagers[index].init(conf); resourceManagers[index].getRMContext().getDispatcher().register( RMAppAttemptEventType.class, new EventHandler<RMAppAttemptEvent>() { public void handle(RMAppAttemptEvent event) { if (event instanceof RMAppAttemptRegistrationEvent) { appMasters.put(event.getApplicationAttemptId(), event.getTimestamp()); } else if (event instanceof RMAppAttemptUnregistrationEvent) { appMasters.remove(event.getApplicationAttemptId()); } } }); }
@Test(timeout = 10000) public void testRMStarts() throws Exception { Configuration conf = new YarnConfiguration(); conf.setBoolean(YarnConfiguration.RM_SCHEDULER_ENABLE_MONITORS, true); conf.set(YarnConfiguration.RM_SCHEDULER_MONITOR_POLICIES, ProportionalCapacityPreemptionPolicy.class.getCanonicalName()); ResourceManager rm = new MockRM(); rm.init(conf); SchedulingEditPolicy mPolicy = mock(SchedulingEditPolicy.class); when(mPolicy.getMonitoringInterval()).thenReturn(1000L); SchedulingMonitor monitor = new SchedulingMonitor(rm.getRMContext(), mPolicy); monitor.serviceInit(conf); monitor.serviceStart(); verify(mPolicy, timeout(10000)).editSchedule(); monitor.close(); rm.close(); }
private synchronized void initResourceManager(int index, Configuration conf) { Configuration newConf = resourceManagers.length > 1 ? new YarnConfiguration(conf) : conf; if (HAUtil.isHAEnabled(newConf)) { newConf.set(YarnConfiguration.RM_HA_ID, rmIds[index]); } resourceManagers[index].init(newConf); resourceManagers[index].getRMContext().getDispatcher().register( RMAppAttemptEventType.class, new EventHandler<RMAppAttemptEvent>() { public void handle(RMAppAttemptEvent event) { if (event instanceof RMAppAttemptRegistrationEvent) { appMasters.put(event.getApplicationAttemptId(), event.getTimestamp()); } else if (event instanceof RMAppAttemptUnregistrationEvent) { appMasters.remove(event.getApplicationAttemptId()); } } }); }
@Test(timeout = 10000) public void testRMStarts() throws Exception { Configuration conf = new YarnConfiguration(); conf.setBoolean(YarnConfiguration.RM_SCHEDULER_ENABLE_MONITORS, true); conf.set(YarnConfiguration.RM_SCHEDULER_MONITOR_POLICIES, ProportionalCapacityPreemptionPolicy.class.getCanonicalName()); ResourceManager rm = new ResourceManager(); rm.init(conf); SchedulingEditPolicy mPolicy = mock(SchedulingEditPolicy.class); when(mPolicy.getMonitoringInterval()).thenReturn(1000L); SchedulingMonitor monitor = new SchedulingMonitor(rm.getRMContext(), mPolicy); monitor.serviceInit(conf); monitor.serviceStart(); verify(mPolicy, timeout(10000)).editSchedule(); monitor.close(); rm.close(); } }
@Test public void testServiceAclsRefreshWithLocalConfigurationProvider() { configuration.setBoolean( CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION, true); ResourceManager resourceManager = null; try { resourceManager = new ResourceManager(); resourceManager.init(configuration); resourceManager.start(); resourceManager.adminService.refreshServiceAcls(RefreshServiceAclsRequest .newInstance()); } catch (Exception ex) { fail("Using localConfigurationProvider. Should not get any exception."); } finally { if (resourceManager != null) { resourceManager.stop(); } } }
@Test public void testServiceAclsRefreshWithLocalConfigurationProvider() { configuration.setBoolean( CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION, true); ResourceManager resourceManager = null; try { resourceManager = new ResourceManager(); resourceManager.init(configuration); resourceManager.start(); resourceManager.adminService.refreshServiceAcls(RefreshServiceAclsRequest .newInstance()); } catch (Exception ex) { fail("Using localConfigurationProvider. Should not get any exception."); } finally { if (resourceManager != null) { resourceManager.stop(); } } }
@Before public void setUp() throws Exception { conf = new YarnConfiguration(); conf.setClass(YarnConfiguration.RM_SCHEDULER, FifoSchedulerWithMove.class, FifoSchedulerWithMove.class); conf.set(YarnConfiguration.YARN_ADMIN_ACL, " "); conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true); resourceManager = new ResourceManager(); resourceManager.init(conf); resourceManager.getRMContext().getContainerTokenSecretManager().rollMasterKey(); resourceManager.getRMContext().getNMTokenSecretManager().rollMasterKey(); resourceManager.start(); failMove = false; }
@Before public void setUp() throws IOException { scheduler = new FairScheduler(); Configuration conf = new YarnConfiguration(); conf.setClass(YarnConfiguration.RM_SCHEDULER, FairScheduler.class, ResourceScheduler.class); conf.set("yarn.scheduler.fair.event-log-enabled", "true"); // All tests assume only one assignment per node update conf.set(FairSchedulerConfiguration.ASSIGN_MULTIPLE, "false"); resourceManager = new ResourceManager(); resourceManager.init(conf); ((AsyncDispatcher)resourceManager.getRMContext().getDispatcher()).start(); scheduler.init(conf); scheduler.start(); scheduler.reinitialize(conf, resourceManager.getRMContext()); }
@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(); } }
@Before public void setUp() throws Exception { resourceManager = new ResourceManager() { @Override protected RMNodeLabelsManager createNodeLabelManager() { RMNodeLabelsManager mgr = new NullRMNodeLabelsManager(); mgr.init(getConfig()); return mgr; } }; CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration(); setupQueueConfiguration(csConf); YarnConfiguration conf = new YarnConfiguration(csConf); conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class, ResourceScheduler.class); resourceManager.init(conf); resourceManager.getRMContext().getContainerTokenSecretManager().rollMasterKey(); resourceManager.getRMContext().getNMTokenSecretManager().rollMasterKey(); ((AsyncDispatcher)resourceManager.getRMContext().getDispatcher()).start(); mockContext = mock(RMContext.class); when(mockContext.getConfigurationProvider()).thenReturn( new LocalConfigurationProvider()); }
@Before public void setUp() throws Exception { Configuration conf = new YarnConfiguration(); UserGroupInformation.setConfiguration(conf); resourceManager = new ResourceManager(); resourceManager.init(conf); resourceManager.getRMContext().getContainerTokenSecretManager().rollMasterKey(); resourceManager.getRMContext().getNMTokenSecretManager().rollMasterKey(); }
@Before public void setUp() throws Exception { Configuration conf = new YarnConfiguration(); UserGroupInformation.setConfiguration(conf); resourceManager = new ResourceManager(); resourceManager.init(conf); resourceManager.getRMContext().getContainerTokenSecretManager().rollMasterKey(); resourceManager.getRMContext().getNMTokenSecretManager().rollMasterKey(); }
public void setup() { resourceManager = new ResourceManager() { @Override protected RMNodeLabelsManager createNodeLabelManager() { RMNodeLabelsManager mgr = new NullRMNodeLabelsManager(); mgr.init(getConfig()); return mgr; } }; YarnConfiguration conf = new YarnConfiguration(); conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class, ResourceScheduler.class); resourceManager.init(conf); resourceManager.getRMContext().getContainerTokenSecretManager() .rollMasterKey(); resourceManager.getRMContext().getNMTokenSecretManager().rollMasterKey(); ((AsyncDispatcher) resourceManager.getRMContext().getDispatcher()).start(); }
@Before public void setUp() throws IOException { scheduler = new FairScheduler(); conf = createConfiguration(); resourceManager = new ResourceManager(); resourceManager.init(conf); // TODO: This test should really be using MockRM. For now starting stuff // that is needed at a bare minimum. ((AsyncDispatcher)resourceManager.getRMContext().getDispatcher()).start(); resourceManager.getRMContext().getStateStore().start(); // to initialize the master key resourceManager.getRMContext().getContainerTokenSecretManager().rollMasterKey(); scheduler.setRMContext(resourceManager.getRMContext()); }