protected void createPolicyMonitors() { if (scheduler instanceof PreemptableResourceScheduler && conf.getBoolean(YarnConfiguration.RM_SCHEDULER_ENABLE_MONITORS, YarnConfiguration.DEFAULT_RM_SCHEDULER_ENABLE_MONITORS)) { LOG.info("Loading policy monitors"); List<SchedulingEditPolicy> policies = conf.getInstances( YarnConfiguration.RM_SCHEDULER_MONITOR_POLICIES, SchedulingEditPolicy.class); if (policies.size() > 0) { for (SchedulingEditPolicy policy : policies) { LOG.info("LOADING SchedulingEditPolicy:" + policy.getPolicyName()); // periodically check whether we need to take action to guarantee // constraints SchedulingMonitor mon = new SchedulingMonitor(rmContext, policy); addService(mon); } } else { LOG.warn("Policy monitors configured (" + YarnConfiguration.RM_SCHEDULER_ENABLE_MONITORS + ") but none specified (" + YarnConfiguration.RM_SCHEDULER_MONITOR_POLICIES + ")"); } } } }
@VisibleForTesting protected boolean areActiveServicesRunning() { return activeServices != null && activeServices.isInState(STATE.STARTED); }
/** * Helper method to start {@link #activeServices}. * @throws Exception */ void startActiveServices() throws Exception { if (activeServices != null) { clusterTimeStamp = System.currentTimeMillis(); activeServices.start(); } }
addService(rmSecretManagerService); addService(containerAllocationExpirer); rmContext.setContainerAllocationExpirer(containerAllocationExpirer); addService(amLivelinessMonitor); rmContext.setAMLivelinessMonitor(amLivelinessMonitor); addService(amFinishingMonitor); rmContext.setAMFinishingMonitor(amFinishingMonitor); addService(rmAppLifetimeMonitor); rmContext.setRMAppLifetimeMonitor(rmAppLifetimeMonitor); addService(nlm); rmContext.setNodeLabelManager(nlm); addService(nam); rmContext.setNodeAttributesManager(nam); addService(placementConstraintManager); rmContext.setPlacementConstraintManager(placementConstraintManager); createMultiNodeSortingManager(); multiNodeSortingManager.setRMContext(rmContext); addService(multiNodeSortingManager); rmContext.setMultiNodeSortingManager(multiNodeSortingManager); createRMDelegatedNodeLabelsUpdater();
addService(rmSecretManagerService); addService(containerAllocationExpirer); rmContext.setContainerAllocationExpirer(containerAllocationExpirer); addService(amLivelinessMonitor); rmContext.setAMLivelinessMonitor(amLivelinessMonitor); addService(amFinishingMonitor); rmContext.setAMFinishingMonitor(amFinishingMonitor); addService(nlm); rmContext.setNodeLabelManager(nlm); addService(nodesListManager); rmContext.setNodesListManager(nodesListManager); addIfService(scheduler); rmContext.setScheduler(scheduler); addIfService(schedulerDispatcher); rmDispatcher.register(SchedulerEventType.class, schedulerDispatcher); addService(nmLivelinessMonitor); addService(resourceTracker); rmContext.setResourceTrackerService(resourceTracker); if (reservationSystem != null) {
addService(rmSecretManagerService); addService(containerAllocationExpirer); rmContext.setContainerAllocationExpirer(containerAllocationExpirer); addService(amLivelinessMonitor); rmContext.setAMLivelinessMonitor(amLivelinessMonitor); addService(amFinishingMonitor); rmContext.setAMFinishingMonitor(amFinishingMonitor); addService(nlm); rmContext.setNodeLabelManager(nlm); addService(nodesListManager); rmContext.setNodesListManager(nodesListManager); addIfService(scheduler); rmContext.setScheduler(scheduler); addIfService(schedulerDispatcher); rmDispatcher.register(SchedulerEventType.class, schedulerDispatcher); addService(nmLivelinessMonitor); addService(resourceTracker); rmContext.setResourceTrackerService(resourceTracker); if (reservationSystem != null) {
protected void createPolicyMonitors() { if (scheduler instanceof PreemptableResourceScheduler && conf.getBoolean(YarnConfiguration.RM_SCHEDULER_ENABLE_MONITORS, YarnConfiguration.DEFAULT_RM_SCHEDULER_ENABLE_MONITORS)) { LOG.info("Loading policy monitors"); List<SchedulingEditPolicy> policies = conf.getInstances( YarnConfiguration.RM_SCHEDULER_MONITOR_POLICIES, SchedulingEditPolicy.class); if (policies.size() > 0) { for (SchedulingEditPolicy policy : policies) { LOG.info("LOADING SchedulingEditPolicy:" + policy.getPolicyName()); // periodically check whether we need to take action to guarantee // constraints SchedulingMonitor mon = new SchedulingMonitor(rmContext, policy); addService(mon); } } else { LOG.warn("Policy monitors configured (" + YarnConfiguration.RM_SCHEDULER_ENABLE_MONITORS + ") but none specified (" + YarnConfiguration.RM_SCHEDULER_MONITOR_POLICIES + ")"); } } } }
@Test public void testPolicyInitializeAfterSchedulerInitialized() { @SuppressWarnings("resource") MockRM rm = new MockRM(conf); rm.init(conf); // ProportionalCapacityPreemptionPolicy should be initialized after // CapacityScheduler initialized. We will // 1) find SchedulingMonitor from RMActiveService's service list, // 2) check if ResourceCalculator in policy is null or not. // If it's not null, we can come to a conclusion that policy initialized // after scheduler got initialized for (Service service : rm.getRMActiveService().getServices()) { if (service instanceof SchedulingMonitor) { ProportionalCapacityPreemptionPolicy policy = (ProportionalCapacityPreemptionPolicy) ((SchedulingMonitor) service) .getSchedulingEditPolicy(); assertNotNull(policy.getResourceCalculator()); return; } } fail("Failed to find SchedulingMonitor service, please check what happened"); }
private void createAndRegisterOpportunisticDispatcher( ApplicationMasterService service) { if (!isOpportunisticSchedulingEnabled(conf)) { return; } EventDispatcher oppContainerAllocEventDispatcher = new EventDispatcher( (OpportunisticContainerAllocatorAMService) service, OpportunisticContainerAllocatorAMService.class.getName()); // Add an event dispatcher for the // OpportunisticContainerAllocatorAMService to handle node // additions, updates and removals. Since the SchedulerEvent is currently // a super set of theses, we register interest for it. addService(oppContainerAllocEventDispatcher); rmDispatcher .register(SchedulerEventType.class, oppContainerAllocEventDispatcher); }
SchedulingEditPolicy getSchedulingEditPolicy(MockRM rm) { ResourceManager.RMActiveServices activeServices = rm.getRMActiveService(); SchedulingMonitor mon = null; for (Service service : activeServices.getServices()) { if (service instanceof SchedulingMonitor) { mon = (SchedulingMonitor) service; break; } } if (mon != null) { return mon.getSchedulingEditPolicy(); } return null; }
@VisibleForTesting protected boolean areActiveServicesRunning() { return activeServices != null && activeServices.isInState(STATE.STARTED); }
@VisibleForTesting protected boolean areActiveServicesRunning() { return activeServices != null && activeServices.isInState(STATE.STARTED); }
/** * Helper method to create and init {@link #activeServices}. This creates an * instance of {@link RMActiveServices} and initializes it. * @throws Exception */ protected void createAndInitActiveServices() throws Exception { activeServices = new RMActiveServices(this); activeServices.init(conf); }
/** * Helper method to stop {@link #activeServices}. * @throws Exception */ void stopActiveServices() throws Exception { if (activeServices != null) { activeServices.stop(); activeServices = null; } }
/** * Helper method to create and init {@link #activeServices}. This creates an * instance of {@link RMActiveServices} and initializes it. * * @param fromActive Indicates if the call is from the active state transition * or the RM initialization. */ protected void createAndInitActiveServices(boolean fromActive) { activeServices = new RMActiveServices(this); activeServices.fromActive = fromActive; activeServices.init(conf); }
/** * Helper method to start {@link #activeServices}. * @throws Exception */ void startActiveServices() throws Exception { if (activeServices != null) { clusterTimeStamp = System.currentTimeMillis(); activeServices.start(); } }
/** * Helper method to start {@link #activeServices}. * @throws Exception */ void startActiveServices() throws Exception { if (activeServices != null) { clusterTimeStamp = System.currentTimeMillis(); activeServices.start(); } }
/** * Helper method to stop {@link #activeServices}. * @throws Exception */ void stopActiveServices() { if (activeServices != null) { activeServices.stop(); activeServices = null; } }
/** * Helper method to create and init {@link #activeServices}. This creates an * instance of {@link RMActiveServices} and initializes it. * @throws Exception */ protected void createAndInitActiveServices() throws Exception { activeServices = new RMActiveServices(this); activeServices.init(conf); }
/** * Helper method to stop {@link #activeServices}. * @throws Exception */ void stopActiveServices() throws Exception { if (activeServices != null) { activeServices.stop(); activeServices = null; } }