ReservationQueue extends LeafQueue { 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()); setMaxApplications((int) (maxSystemApps * getAbsoluteCapacity())); setMaxCapacity(entitlement.getMaxCapacity()); if (LOG.isDebugEnabled()) { LOG.debug("successfully changed to " + capacity + " for queue " + this.getQueueName()); } } ReservationQueue(CapacitySchedulerContext cs, String queueName,
      PlanQueue parent); @Override synchronized void reinitialize(CSQueue newlyParsedQueue,
      Resource clusterResource); synchronized void setEntitlement(QueueEntitlement entitlement);  }
@Test public void testAddSubtractCapacity() throws Exception { reservationQueue.setCapacity(1.0F); assertTrue(" actual capacity: " + reservationQueue.getCapacity(), reservationQueue.getCapacity() - 1 < CSQueueUtils.EPSILON); reservationQueue.setEntitlement(new QueueEntitlement(0.9f, 1f)); assertTrue(" actual capacity: " + reservationQueue.getCapacity(), reservationQueue.getCapacity() - 0.9 < CSQueueUtils.EPSILON); reservationQueue.setEntitlement(new QueueEntitlement(1f, 1f)); assertTrue(" actual capacity: " + reservationQueue.getCapacity(), reservationQueue.getCapacity() - 1 < CSQueueUtils.EPSILON); reservationQueue.setEntitlement(new QueueEntitlement(0f, 1f)); assertTrue(" actual capacity: " + reservationQueue.getCapacity(), reservationQueue.getCapacity() < CSQueueUtils.EPSILON); try { reservationQueue.setEntitlement(new QueueEntitlement(1.1f, 1f)); fail(); } catch (SchedulerDynamicEditException iae) { assertTrue(" actual capacity: " + reservationQueue.getCapacity(), reservationQueue.getCapacity() - 1 < CSQueueUtils.EPSILON); } try { reservationQueue.setEntitlement(new QueueEntitlement(-0.1f, 1f)); fail(); } catch (SchedulerDynamicEditException iae) { assertTrue(" actual capacity: " + reservationQueue.getCapacity(), reservationQueue.getCapacity() - 1 < CSQueueUtils.EPSILON); } }