/** * For the given child queue, set the max resources based on the * parent queue's default child resource settings. This method assumes that * the child queue is ad hoc and hence does not do any safety checks around * overwriting existing max resource settings. * * @param parent the parent queue * @param child the child queue * @param queueConf the {@link AllocationConfiguration} */ private void setChildResourceLimits(FSParentQueue parent, FSQueue child, AllocationConfiguration queueConf) { Map<FSQueueType, Set<String>> configuredQueues = queueConf.getConfiguredQueues(); // Ad hoc queues do not exist in the configured queues map if (!configuredQueues.get(FSQueueType.LEAF).contains(child.getName()) && !configuredQueues.get(FSQueueType.PARENT).contains(child.getName())) { // For ad hoc queues, set their max reource allocations based on // their parents' default child settings. ConfigurableResource maxChild = parent.getMaxChildQueueResource(); if (maxChild != null) { child.setMaxShare(maxChild); } } }
/** * After reloading the allocation config, the max resource settings for any * ad hoc queues will be missing. This method goes through the queue manager's * queue list and adds back the max resources settings for any ad hoc queues. * Note that the new max resource settings will be based on the new config. * The old settings are lost. */ private void applyChildDefaults() { Collection<FSQueue> queues = queueMgr.getQueues(); Set<String> configuredLeafQueues = allocConf.getConfiguredQueues().get(FSQueueType.LEAF); Set<String> configuredParentQueues = allocConf.getConfiguredQueues().get(FSQueueType.PARENT); for (FSQueue queue : queues) { // If the queue is ad hoc and not root, apply the child defaults if ((queue.getParent() != null) && !configuredLeafQueues.contains(queue.getName()) && !configuredParentQueues.contains(queue.getName())) { ConfigurableResource max = queue.getParent(). getMaxChildQueueResource(); if (max != null) { queue.setMaxShare(max); } } } }
/** * Initialize a {@link FSQueue} with queue-specific properties and its * metrics. * @param queue the FSQueue needed to be initialized */ public void initFSQueue(FSQueue queue){ // Set queue-specific properties. String name = queue.getName(); queue.setWeights(getQueueWeight(name)); queue.setMinShare(getMinResources(name)); queue.setMaxShare(getMaxResources(name)); queue.setMaxRunningApps(getQueueMaxApps(name)); queue.setMaxAMShare(getQueueMaxAMShare(name)); queue.setMaxChildQueueResource(getMaxChildResources(name)); queue.setMaxContainerAllocation(getQueueMaxContainerAllocation(name)); // Set queue metrics. queue.getMetrics().setMinShare(queue.getMinShare()); queue.getMetrics().setMaxShare(queue.getMaxShare()); queue.getMetrics().setMaxApps(queue.getMaxRunningApps()); queue.getMetrics().setSchedulingPolicy(getSchedulingPolicy(name).getName()); } }
@Test (expected = YarnException.class) public void testMoveWouldViolateMaxResourcesConstraints() throws Exception { scheduler.init(conf); scheduler.start(); scheduler.reinitialize(conf, resourceManager.getRMContext()); QueueManager queueMgr = scheduler.getQueueManager(); FSLeafQueue oldQueue = queueMgr.getLeafQueue("queue1", true); FSQueue queue2 = queueMgr.getLeafQueue("queue2", true); queue2.setMaxShare( new ConfigurableResource(Resource.newInstance(1024, 1))); ApplicationAttemptId appAttId = createSchedulingRequest(1024, 1, "queue1", "user1", 3); RMNode node = MockNodes.newNodeInfo(1, Resources.createResource(2048, 2)); NodeAddedSchedulerEvent nodeEvent = new NodeAddedSchedulerEvent(node); NodeUpdateSchedulerEvent updateEvent = new NodeUpdateSchedulerEvent(node); scheduler.handle(nodeEvent); scheduler.handle(updateEvent); scheduler.handle(updateEvent); assertEquals(Resource.newInstance(2048, 2), oldQueue.getResourceUsage()); scheduler.moveApplication(appAttId.getApplicationId(), "queue2"); }