private List<CSQueue> mockCSQueues(String[] queueNames, int[] priorities, float[] utilizations, float[] absCapacities, String partition) { // sanity check assert queueNames != null && priorities != null && utilizations != null && queueNames.length > 0 && queueNames.length == priorities.length && priorities.length == utilizations.length; List<CSQueue> list = new ArrayList<>(); for (int i = 0; i < queueNames.length; i++) { CSQueue q = mock(CSQueue.class); when(q.getQueueName()).thenReturn(queueNames[i]); QueueCapacities qc = new QueueCapacities(false); qc.setAbsoluteCapacity(partition, absCapacities[i]); qc.setUsedCapacity(partition, utilizations[i]); when(q.getQueueCapacities()).thenReturn(qc); when(q.getPriority()).thenReturn(Priority.newInstance(priorities[i])); QueueResourceQuotas qr = new QueueResourceQuotas(); when(q.getQueueResourceQuotas()).thenReturn(qr); list.add(q); } return list; }
for (CSQueue queue : childQueues) { childCapacities += queue.getCapacity(); Resources.addTo(minResDefaultLabel, queue.getQueueResourceQuotas() .getConfiguredMinResource()); && !queue.getQueueResourceQuotas().getConfiguredMinResource() .equals(Resources.none())) { throw new IllegalArgumentException("Parent queue '" + getQueueName() Resources.addTo(minRes, queue.getQueueResourceQuotas() .getConfiguredMinResource(nodeLabel));
public CapacitySchedulerInfo(CSQueue parent, CapacityScheduler cs) { this.queueName = parent.getQueueName(); this.usedCapacity = parent.getUsedCapacity() * 100; this.capacity = parent.getCapacity() * 100; float max = parent.getMaximumCapacity(); if (max < EPSILON || max > 1f) max = 1f; this.maxCapacity = max * 100; capacities = new QueueCapacitiesInfo(parent.getQueueCapacities(), parent.getQueueResourceQuotas(), false); queues = getQueues(parent); health = new CapacitySchedulerHealthInfo(cs); }
for (CSQueue childQueue : getChildQueues()) { Resources.addTo(configuredMinResources, childQueue.getQueueResourceQuotas().getConfiguredMinResource(label)); Resource minResource = childQueue.getQueueResourceQuotas() .getConfiguredMinResource(label); childQueue.getQueueResourceQuotas().setEffectiveMinResource(label, getMinResourceNormalized(childQueue.getQueueName(), effectiveMinRatioPerResource, minResource)); .getConfiguredMaxResource(label); if (parent != null && parentMaxRes.equals(Resources.none())) { parentMaxRes = parent.getQueueResourceQuotas() .getEffectiveMaxResource(label); Resource childMaxResource = childQueue.getQueueResourceQuotas() .getConfiguredMaxResource(label); Resource effMaxResource = Resources.min(resourceCalculator, : childMaxResource, parentMaxRes); childQueue.getQueueResourceQuotas().setEffectiveMaxResource(label, Resources.clone(effMaxResource)); childQueue); } else { childQueue.getQueueResourceQuotas().setEffectiveMinResource(label, Resources.multiply(resourceByLabel,
private int compare(CSQueue q1, CSQueue q2, float q1Used, float q2Used, String partition) { int p1 = 0; int p2 = 0; if (respectPriority) { p1 = q1.getPriority().getPriority(); p2 = q2.getPriority().getPriority(); } int rc = PriorityUtilizationQueueOrderingPolicy.compare(q1Used, q2Used, p1, p2); // For queue with same used ratio / priority, queue with higher configured // capacity goes first if (0 == rc) { Resource minEffRes1 = q1.getQueueResourceQuotas().getConfiguredMinResource(partition); Resource minEffRes2 = q2.getQueueResourceQuotas().getConfiguredMinResource(partition); if (!minEffRes1.equals(Resources.none()) && !minEffRes2.equals( Resources.none())) { return minEffRes2.compareTo(minEffRes1); } float abs1 = q1.getQueueCapacities().getAbsoluteCapacity(partition); float abs2 = q2.getQueueCapacities().getAbsoluteCapacity(partition); return Float.compare(abs2, abs1); } return rc; }
Resource parentMaxRes = parent.getQueueResourceQuotas() .getConfiguredMaxResource(label); if (Resources.greaterThan(resourceCalculator, clusterResource,
QueueResourceQuotas qResQuotas = q.getQueueResourceQuotas(); populateQueueCapacities(qCapacities, qResQuotas); q.getQueueResourceQuotas().getEffectiveMinResource()); maxEffectiveCapacity = new ResourceInfo( q.getQueueResourceQuotas().getEffectiveMaxResource());
when(queue.getQueueResourceQuotas()).thenReturn(qr);
Resource.newInstance(maxCap[i], 0)); qr.setEffectiveMinResource(RMNodeLabelsManager.NO_LABEL, abs[i]); when(q.getQueueResourceQuotas()).thenReturn(qr); when(q.getEffectiveCapacity(RMNodeLabelsManager.NO_LABEL)) .thenReturn(abs[i]);
.getQueueResourceQuotas(); Resource effMinRes = queueResourceQuotas .getEffectiveMinResource(partitionToLookAt);
childQueue.getQueueResourceQuotas().getEffectiveMinResource(label), getQueueResourceQuotas().getEffectiveMinResource(label))); childQueue.getQueueResourceQuotas().getEffectiveMaxResource(label), getQueueResourceQuotas().getEffectiveMaxResource(label)));
Resources.none(), user3LeafQueue.getQueueResourceQuotas() .getEffectiveMinResource()); Assert.assertEquals("Effective Max resource for USER3 is not correct", MAX_RES, user3LeafQueue .getQueueResourceQuotas() .getEffectiveMaxResource()); CSQueue user2LeafQueue = newCS.getQueue(USER2); Assert.assertEquals("Effective Min resource for USER2 is not correct", MIN_RES, user1LeafQueue.getQueueResourceQuotas() .getEffectiveMinResource()); Assert.assertEquals("Effective Max resource for USER2 is not correct", MAX_RES, user1LeafQueue.getQueueResourceQuotas().getEffectiveMaxResource()); MIN_RES, user2LeafQueue.getQueueResourceQuotas() .getEffectiveMinResource()); Assert.assertEquals("Effective Max resource for USER1 is not correct", MAX_RES, user2LeafQueue.getQueueResourceQuotas() .getEffectiveMaxResource()); MIN_RES_UPDATED, user1LeafQueue.getQueueResourceQuotas().getEffectiveMinResource ()); Assert.assertEquals("Effective Max resource for USER2 is not correct", MAX_RES_UPDATED, user2LeafQueue.getQueueResourceQuotas() .getEffectiveMaxResource());