@VisibleForTesting public static void setQueueAcls(YarnAuthorizationProvider authorizer, Map<String, CSQueue> queues) throws IOException { for (CSQueue queue : queues.values()) { AbstractCSQueue csQueue = (AbstractCSQueue) queue; authorizer.setPermission(csQueue.getPrivilegedEntity(), csQueue.getACLs(), UserGroupInformation.getCurrentUser()); } }
configuration.getAccessibleNodeLabels(getQueuePath()); this.defaultLabelExpression = configuration.getDefaultNodeLabelExpression( getQueuePath()); this.resourceTypes = new HashSet<String>(); for (AbsoluteResourceType type : AbsoluteResourceType.values()) { setupConfigurableCapacities(configuration); updateConfigurableResourceRequirement(getQueuePath(), clusterResource); getQueuePath()); QueueState previous = getState(); QueueState configuredState = configuration .getConfiguredState(getQueuePath()); QueueState parentState = (parent == null) ? null : parent.getState(); initializeQueueState(previous, configuredState, parentState); this.acls = configuration.getAcls(getQueuePath()); if (this.getAccessibleNodeLabels().contains( RMNodeLabelsManager.ANY)) { throw new IOException("Parent's accessible queue is not ANY(*), " + "but child's accessible queue is *"); } else{ Set<String> diff = Sets.difference(this.getAccessibleNodeLabels(), parent.getAccessibleNodeLabels()); if (!diff.isEmpty()) {
public void recoverDrainingState() { try { this.writeLock.lock(); if (getState() == QueueState.STOPPED) { updateQueueState(QueueState.DRAINING); } LOG.info("Recover draining state for queue " + this.getQueuePath()); if (getParent() != null && getParent().getState() == QueueState.STOPPED) { ((AbstractCSQueue) getParent()).recoverDrainingState(); } } finally { this.writeLock.unlock(); } }
@Override public Set<String> getNodeLabelsForQueue() { // if queue's label is *, queue can access any labels. Instead of // considering all labels in cluster, only those labels which are // use some resource of this queue can be considered. Set<String> nodeLabels = new HashSet<String>(); if (this.getAccessibleNodeLabels() != null && this.getAccessibleNodeLabels() .contains(RMNodeLabelsManager.ANY)) { nodeLabels.addAll(Sets.union(this.getQueueCapacities().getNodePartitionsSet(), this.getQueueResourceUsage().getNodePartitionsSet())); } else { nodeLabels.addAll(this.getAccessibleNodeLabels()); } // Add NO_LABEL also to this list as NO_LABEL also can be granted with // resource in many general cases. if (!nodeLabels.contains(RMNodeLabelsManager.NO_LABEL)) { nodeLabels.add(RMNodeLabelsManager.NO_LABEL); } return nodeLabels; }
csContext.getConfiguration().getAccessibleNodeLabels(getQueuePath()); this.defaultLabelExpression = csContext.getConfiguration() .getDefaultNodeLabelExpression(getQueuePath()); setupConfigurableCapacities(); getQueuePath()); this.state = csContext.getConfiguration().getState(getQueuePath()); this.acls = csContext.getConfiguration().getAcls(getQueuePath()); && !parent.getAccessibleNodeLabels().contains(RMNodeLabelsManager.ANY)) { if (this.getAccessibleNodeLabels().contains(RMNodeLabelsManager.ANY)) { throw new IOException("Parent's accessible queue is not ANY(*), " + "but child's accessible queue is *"); } else { Set<String> diff = Sets.difference(this.getAccessibleNodeLabels(), parent.getAccessibleNodeLabels()); if (!diff.isEmpty()) { .getReservationContinueLook(); this.preemptionDisabled = isQueueHierarchyPreemptionDisabled(this); this.clusterResource = clusterResource;
final Resource totalPartitionResource, String nodePartition, AbstractCSQueue childQueue) { QueueCapacities queueCapacities = childQueue.getQueueCapacities(); CSQueueMetrics queueMetrics = childQueue.getMetrics(); ResourceUsage queueResourceUsage = childQueue.getQueueResourceUsage(); Resource minimumAllocation = childQueue.getMinimumAllocation(); float absoluteUsedCapacity = 0.0f; float usedCapacity = 0.0f; .getEffectiveCapacity(nodePartition); childQueue.getParent(); QueueCapacities leafQueueTemplateCapacities = parentQueue .getLeafQueueTemplate()
Resource currentLimitResource = getCurrentLimitResource(nodePartition, clusterResource, currentResourceLimits, schedulingMode); if (hasChildQueues()) { usedExceptKillable = Resources.subtract(nowTotalUsed, getTotalKillableResource(nodePartition)); newTotalWithoutReservedResource, currentLimitResource)) { if (LOG.isDebugEnabled()) { LOG.debug("try to use reserved: " + getQueueName() + " usedResources: " + queueUsage.getUsed() + ", clusterResources: " + clusterResource LOG.debug("Failed to assign to queue: " + getQueueName() + " nodePatrition: " + nodePartition + ", usedResources: " + queueUsage.getUsed(nodePartition) LOG.debug("Check assign to queue: " + getQueueName() + " nodePartition: " + nodePartition + ", usedResources: " + queueUsage.getUsed(nodePartition)
try { writeLock.lock(); super.allocateResource(clusterResource, resource, nodePartition);
getCurrentLimitResource(label, clusterResource, currentResourceLimits); newTotalWithoutReservedResource, currentLimitResource)) { if (LOG.isDebugEnabled()) { LOG.debug("try to use reserved: " + getQueueName() + " usedResources: " + queueUsage.getUsed() + ", clusterResources: " + clusterResource LOG.debug(getQueueName() + "Check assign to queue, label=" + label + " usedResources: " + queueUsage.getUsed(label)
if (!super.canAssignToThisQueue(clusterResource, nodeLabels, resourceLimits, minimumAllocation, Resources.createResource(getMetrics() .getReservedMB(), getMetrics().getReservedVirtualCores()))) { assignedToChild.getResource(), Resources.none())) { super.allocateResource(clusterResource, assignedToChild.getResource(), nodeLabels);
protected QueueInfo getQueueInfo() { // Deliberately doesn't use lock here, because this method will be invoked // from schedulerApplicationAttempt, to avoid deadlock, sacrifice // consistency here. // TODO, improve this QueueInfo queueInfo = recordFactory.newRecordInstance(QueueInfo.class); queueInfo.setQueueName(queueName); queueInfo.setAccessibleNodeLabels(accessibleLabels); queueInfo.setCapacity(queueCapacities.getCapacity()); queueInfo.setMaximumCapacity(queueCapacities.getMaximumCapacity()); queueInfo.setQueueState(getState()); queueInfo.setDefaultNodeLabelExpression(defaultLabelExpression); queueInfo.setCurrentCapacity(getUsedCapacity()); queueInfo.setQueueStatistics(getQueueStatistics()); queueInfo.setPreemptionDisabled(preemptionDisabled); queueInfo.setIntraQueuePreemptionDisabled( getIntraQueuePreemptionDisabled()); queueInfo.setQueueConfigurations(getQueueConfigurations()); return queueInfo; }
private Map<String, Float> getUserWeightsFromHierarchy (CapacitySchedulerConfiguration configuration) throws IOException { Map<String, Float> unionInheritedWeights = new HashMap<String, Float>(); CSQueue parentQ = getParent(); if (parentQ != null) { // Inherit all of parent's user's weights unionInheritedWeights.putAll(parentQ.getUserWeights()); } // Insert this queue's user's weights, overriding parent's user's weights if // there is overlap. unionInheritedWeights.putAll( configuration.getAllUserWeightsForQueue(getQueuePath())); return unionInheritedWeights; }
protected void setupConfigurableCapacities( CapacitySchedulerConfiguration configuration) { CSQueueUtils.loadUpdateAndCheckCapacities( getQueuePath(), configuration, queueCapacities, parent == null ? null : parent.getQueueCapacities()); }
private void validateAbsoluteVsPercentageCapacityConfig( Resource minResource) { CapacityConfigType localType = CapacityConfigType.PERCENTAGE; if (!minResource.equals(Resources.none())) { localType = CapacityConfigType.ABSOLUTE_RESOURCE; } if (!queueName.equals("root") && !this.capacityConfigType.equals(localType)) { throw new IllegalArgumentException("Queue '" + getQueueName() + "' should use either percentage based capacity" + " configuration or absolute resource."); } }
@Override public void activeQueue() throws YarnException { try { this.writeLock.lock(); if (getState() == QueueState.RUNNING) { LOG.info("The specified queue:" + queueName + " is already in the RUNNING state."); } else if (getState() == QueueState.DRAINING) { throw new YarnException( "The queue:" + queueName + " is in the Stopping process. " + "Please wait for the queue getting fully STOPPED."); } else { CSQueue parent = getParent(); if (parent == null || parent.getState() == QueueState.RUNNING) { updateQueueState(QueueState.RUNNING); } else { throw new YarnException("The parent Queue:" + parent.getQueueName() + " is not running. Please activate the parent queue first"); } } } finally { this.writeLock.unlock(); } }
synchronized void allocateResource(Resource clusterResource, Resource resource, Set<String> nodeLabels) { // Update usedResources by labels if (nodeLabels == null || nodeLabels.isEmpty()) { queueUsage.incUsed(resource); } else { Set<String> anls = (accessibleLabels.contains(RMNodeLabelsManager.ANY)) ? labelManager.getClusterNodeLabels() : accessibleLabels; for (String label : Sets.intersection(anls, nodeLabels)) { queueUsage.incUsed(label, resource); } } ++numContainers; CSQueueUtils.updateQueueStatistics(resourceCalculator, this, getParent(), clusterResource, minimumAllocation); }
if (!super.canAssignToThisQueue(clusterResource, node.getLabels(), currentResourceLimits, required, application.getCurrentReservation())) { return NULL_ASSIGNMENT;
+ "' for queue '" + getQueueName()); if (LOG.isDebugEnabled()) { LOG.debug("capacityConfigType is updated as '" + capacityConfigType + "' for queue '" + getQueueName()); validateAbsoluteVsPercentageCapacityConfig(minResource); throw new IllegalArgumentException("Min resource configuration " + minResource + " is greater than its max value:" + maxResource + " in queue:" + getQueueName()); throw new IllegalArgumentException("Max resource configuration " + maxResource + " is greater than parents max value:" + parentMaxRes + " in queue:" + getQueueName()); + getQueueName() + " as minResource=" + minResource + " and maxResource=" + maxResource);
protected QueueInfo getQueueInfo() { QueueInfo queueInfo = recordFactory.newRecordInstance(QueueInfo.class); queueInfo.setQueueName(queueName); queueInfo.setAccessibleNodeLabels(accessibleLabels); queueInfo.setCapacity(queueCapacities.getCapacity()); queueInfo.setMaximumCapacity(queueCapacities.getMaximumCapacity()); queueInfo.setQueueState(state); queueInfo.setDefaultNodeLabelExpression(defaultLabelExpression); queueInfo.setCurrentCapacity(getUsedCapacity()); return queueInfo; }
if (!super.hasPendingResourceRequest(candidates.getPartition(), clusterResource, schedulingMode)) { if (LOG.isDebugEnabled()) { if (!super.canAssignToThisQueue(clusterResource, candidates.getPartition(), resourceLimits, Resources