protected float sumOfChildAbsCapacities() { try { writeLock.lock(); float ret = 0; for (CSQueue l : childQueues) { ret += l.getAbsoluteCapacity(); } return ret; } finally { writeLock.unlock(); } }
private float computeQueueUsedCapacity(CSQueue queue, int expectedMemory, Resource clusterResource) { return (expectedMemory / (clusterResource.getMemory() * queue.getAbsoluteCapacity())); }
private float computeQueueUsedCapacity(CSQueue queue, int expectedMemory, Resource clusterResource) { return (expectedMemory / (clusterResource.getMemorySize() * queue.getAbsoluteCapacity())); }
private float computeQueueUsedCapacity(CSQueue queue, int expectedMemory, Resource clusterResource) { return (expectedMemory / (clusterResource.getMemory() * queue.getAbsoluteCapacity())); }
private float computeQueueUsedCapacity(CSQueue queue, int expectedMemory, Resource clusterResource) { return (expectedMemory / (clusterResource.getMemorySize() * queue.getAbsoluteCapacity())); }
@Override protected Resource getReservationQueueResourceIfExists(Plan plan, ReservationId reservationId) { CSQueue resQueue = cs.getQueue(reservationId.toString()); Resource reservationResource = null; if (resQueue != null) { reservationResource = Resources.multiply(cs.getClusterResource(), resQueue.getAbsoluteCapacity()); } return reservationResource; }
@Override protected Resource getReservationQueueResourceIfExists(Plan plan, ReservationId reservationId) { CSQueue resQueue = cs.getQueue(reservationId.toString()); Resource reservationResource = null; if (resQueue != null) { reservationResource = Resources.multiply(cs.getClusterResource(), resQueue.getAbsoluteCapacity()); } return reservationResource; }
@Override protected Resource getReservationQueueResourceIfExists(Plan plan, ReservationId reservationId) { CSQueue resQueue = cs.getQueue(reservationId.toString()); Resource reservationResource = null; if (resQueue != null) { reservationResource = Resources.multiply(cs.getClusterResource(), resQueue.getAbsoluteCapacity()); } return reservationResource; }
@Override protected Resource getPlanQueueCapacity(String planQueueName) { Resource minAllocation = getMinAllocation(); ResourceCalculator rescCalc = getResourceCalculator(); CSQueue planQueue = capScheduler.getQueue(planQueueName); return rescCalc.multiplyAndNormalizeDown(capScheduler.getClusterResource(), planQueue.getAbsoluteCapacity(), minAllocation); }
@Override protected Resource getPlanQueueCapacity(String planQueueName) { Resource minAllocation = getMinAllocation(); ResourceCalculator rescCalc = getResourceCalculator(); CSQueue planQueue = capScheduler.getQueue(planQueueName); return rescCalc.multiplyAndNormalizeDown(capScheduler.getClusterResource(), planQueue.getAbsoluteCapacity(), minAllocation); }
@Override protected Resource getPlanQueueCapacity(String planQueueName) { Resource minAllocation = getMinAllocation(); ResourceCalculator rescCalc = getResourceCalculator(); CSQueue planQueue = capScheduler.getQueue(planQueueName); return rescCalc.multiplyAndNormalizeDown(capScheduler.getClusterResource(), planQueue.getAbsoluteCapacity(), minAllocation); }
/** * This methods to change capacity for a queue and adjusts its * absoluteCapacity * * @param entitlement the new entitlement for the queue (capacity, * maxCapacity, etc..) * @throws SchedulerDynamicEditException */ public synchronized void setEntitlement(QueueEntitlement entitlement) throws SchedulerDynamicEditException { float capacity = entitlement.getCapacity(); if (capacity < 0 || capacity > 1.0f) { throw new SchedulerDynamicEditException( "Capacity demand is not in the [0,1] range: " + capacity); } setCapacity(capacity); setAbsoluteCapacity(getParent().getAbsoluteCapacity() * getCapacity()); // note: we currently set maxCapacity to capacity // this might be revised later setMaxCapacity(entitlement.getMaxCapacity()); if (LOG.isDebugEnabled()) { LOG.debug("successfully changed to " + capacity + " for queue " + this.getQueueName()); } }
/** * This methods to change capacity for a queue and adjusts its * absoluteCapacity * * @param entitlement the new entitlement for the queue (capacity, * maxCapacity, etc..) * @throws SchedulerDynamicEditException */ public synchronized void setEntitlement(QueueEntitlement entitlement) throws SchedulerDynamicEditException { float capacity = entitlement.getCapacity(); if (capacity < 0 || capacity > 1.0f) { throw new SchedulerDynamicEditException( "Capacity demand is not in the [0,1] range: " + capacity); } setCapacity(capacity); setAbsoluteCapacity(getParent().getAbsoluteCapacity() * getCapacity()); // note: we currently set maxCapacity to capacity // this might be revised later setMaxCapacity(entitlement.getMaxCapacity()); if (LOG.isDebugEnabled()) { LOG.debug("successfully changed to " + capacity + " for queue " + this.getQueueName()); } }
void printString(CSQueue nq, String indent) { if (nq instanceof ParentQueue) { System.out.println(indent + nq.getQueueName() + " cur:" + nq.getAbsoluteUsedCapacity() + " guar:" + nq.getAbsoluteCapacity() ); for (CSQueue q : ((ParentQueue)nq).getChildQueues()) { printString(q, indent + " "); } } else { System.out.println(indent + nq.getQueueName() + " pen:" + ((LeafQueue) nq) .getTotalPendingResourcesConsideringUserLimit(isA(Resource.class)) + " cur:" + nq.getAbsoluteUsedCapacity() + " guar:" + nq.getAbsoluteCapacity() ); for (FiCaSchedulerApp a : ((LeafQueue)nq).getApplications()) { System.out.println(indent + " " + a.getApplicationId()); } } }
void setEntitlement(AutoCreatedLeafQueue queue, QueueEntitlement entitlement) { queue.setCapacity(entitlement.getCapacity()); queue.setAbsoluteCapacity( queue.getParent().getAbsoluteCapacity() * entitlement.getCapacity()); // note: we currently set maxCapacity to capacity // this might be revised later queue.setMaxCapacity(entitlement.getMaxCapacity()); }
void checkQueueCapacity(CSQueue q, float expectedCapacity, float expectedAbsCapacity, float expectedMaxCapacity, float expectedAbsMaxCapacity) { final float epsilon = 1e-5f; assertEquals("capacity", expectedCapacity, q.getCapacity(), epsilon); assertEquals("absolute capacity", expectedAbsCapacity, q.getAbsoluteCapacity(), epsilon); assertEquals("maximum capacity", expectedMaxCapacity, q.getMaximumCapacity(), epsilon); assertEquals("absolute maximum capacity", expectedAbsMaxCapacity, q.getAbsoluteMaximumCapacity(), epsilon); }
private void checkQueueCapacity(CSQueue q, float expectedCapacity, float expectedAbsCapacity, float expectedMaxCapacity, float expectedAbsMaxCapacity) { final float epsilon = 1e-5f; assertEquals("capacity", expectedCapacity, q.getCapacity(), epsilon); assertEquals("absolute capacity", expectedAbsCapacity, q.getAbsoluteCapacity(), epsilon); assertEquals("maximum capacity", expectedMaxCapacity, q.getMaximumCapacity(), epsilon); assertEquals("absolute maximum capacity", expectedAbsMaxCapacity, q.getAbsoluteMaximumCapacity(), epsilon); }
@Test public void testQueueParsing() throws Exception { CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration(); setupQueueConfiguration(csConf); YarnConfiguration conf = new YarnConfiguration(csConf); CapacityScheduler capacityScheduler = new CapacityScheduler(); capacityScheduler.setConf(conf); capacityScheduler.setRMContext(TestUtils.getMockRMContext()); capacityScheduler.init(conf); capacityScheduler.start(); capacityScheduler.reinitialize(conf, TestUtils.getMockRMContext()); CSQueue a = capacityScheduler.getQueue("a"); Assert.assertEquals(0.10, a.getAbsoluteCapacity(), DELTA); Assert.assertEquals(0.15, a.getAbsoluteMaximumCapacity(), DELTA); CSQueue b1 = capacityScheduler.getQueue("b1"); Assert.assertEquals(0.2 * 0.5, b1.getAbsoluteCapacity(), DELTA); Assert.assertEquals("Parent B has no MAX_CAP", 0.85, b1.getAbsoluteMaximumCapacity(), DELTA); CSQueue c12 = capacityScheduler.getQueue("c12"); Assert.assertEquals(0.7 * 0.5 * 0.45, c12.getAbsoluteCapacity(), DELTA); Assert.assertEquals(0.7 * 0.55 * 0.7, c12.getAbsoluteMaximumCapacity(), DELTA); ServiceOperations.stopQuietly(capacityScheduler); }
@Test public void testQueueParsingShouldTrimSpaces() throws Exception { CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration(); setupQueueConfigurationWithSpacesShouldBeTrimmed(csConf); YarnConfiguration conf = new YarnConfiguration(csConf); CapacityScheduler capacityScheduler = new CapacityScheduler(); capacityScheduler.setConf(conf); capacityScheduler.setRMContext(TestUtils.getMockRMContext()); capacityScheduler.init(conf); capacityScheduler.start(); capacityScheduler.reinitialize(conf, TestUtils.getMockRMContext()); CSQueue a = capacityScheduler.getQueue("a"); Assert.assertNotNull(a); Assert.assertEquals(0.10, a.getAbsoluteCapacity(), DELTA); Assert.assertEquals(0.15, a.getAbsoluteMaximumCapacity(), DELTA); CSQueue c = capacityScheduler.getQueue("c"); Assert.assertNotNull(c); Assert.assertEquals(0.70, c.getAbsoluteCapacity(), DELTA); Assert.assertEquals(0.70, c.getAbsoluteMaximumCapacity(), DELTA); }
@Test public void testQueueParsingShouldTrimSpaces() throws Exception { CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration(); setupQueueConfigurationWithSpacesShouldBeTrimmed(csConf); YarnConfiguration conf = new YarnConfiguration(csConf); CapacityScheduler capacityScheduler = new CapacityScheduler(); capacityScheduler.setConf(conf); capacityScheduler.setRMContext(TestUtils.getMockRMContext()); capacityScheduler.init(conf); capacityScheduler.start(); capacityScheduler.reinitialize(conf, TestUtils.getMockRMContext()); CSQueue a = capacityScheduler.getQueue("a"); Assert.assertNotNull(a); Assert.assertEquals(0.10, a.getAbsoluteCapacity(), DELTA); Assert.assertEquals(0.15, a.getAbsoluteMaximumCapacity(), DELTA); CSQueue c = capacityScheduler.getQueue("c"); Assert.assertNotNull(c); Assert.assertEquals(0.70, c.getAbsoluteCapacity(), DELTA); Assert.assertEquals(0.70, c.getAbsoluteMaximumCapacity(), DELTA); }