@Override protected void addReservationQueue( String planQueueName, Queue queue, String currResId) { PlanQueue planQueue = (PlanQueue)queue; try { ReservationQueue resQueue = new ReservationQueue(cs, currResId, planQueue); cs.addQueue(resQueue); } catch (SchedulerDynamicEditException e) { LOG.warn( "Exception while trying to activate reservation: {} for plan: {}", currResId, planQueueName, e); } catch (IOException e) { LOG.warn( "Exception while trying to activate reservation: {} for plan: {}", currResId, planQueueName, e); } }
/** * 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()); } }
@Override protected void setupConfigurableCapacities() { CSQueueUtils.updateAndCheckCapacitiesByLabel(getQueuePath(), queueCapacities, parent == null ? null : parent.getQueueCapacities()); } }
private void updateQuotas(int userLimit, float userLimitFactor, int maxAppsForReservation, int maxAppsPerUserForReservation) { setUserLimit(userLimit); setUserLimitFactor(userLimitFactor); setMaxApplications(maxAppsForReservation); maxApplicationsPerUser = maxAppsPerUserForReservation; }
@Override public synchronized void removeQueue(String queueName) throws SchedulerDynamicEditException { LOG.info("Removing queue: " + queueName); CSQueue q = this.getQueue(queueName); if (!(q instanceof ReservationQueue)) { throw new SchedulerDynamicEditException("The queue that we are asked " + "to remove (" + queueName + ") is not a ReservationQueue"); } ReservationQueue disposableLeafQueue = (ReservationQueue) q; // at this point we should have no more apps if (disposableLeafQueue.getNumApplications() > 0) { throw new SchedulerDynamicEditException("The queue " + queueName + " is not empty " + disposableLeafQueue.getApplications().size() + " active apps " + disposableLeafQueue.pendingApplications.size() + " pending apps"); } ((PlanQueue) disposableLeafQueue.getParent()).removeChildQueue(q); this.queues.remove(queueName); LOG.info("Removal of ReservationQueue " + queueName + " has succeeded"); }
ReservationQueue resQueue = new ReservationQueue(csContext, defReservationId, (PlanQueue) queue); try { resQueue.setEntitlement(new QueueEntitlement(1.0f, 1.0f)); } catch (SchedulerDynamicEditException e) { throw new IllegalStateException(e);
autoCreatedLeafQueue.setCapacity(1.0F); validateAutoCreatedLeafQueue(1); autoCreatedLeafQueue.setEntitlement(new QueueEntitlement(0.9f, 1f)); validateAutoCreatedLeafQueue(0.9); autoCreatedLeafQueue.setEntitlement(new QueueEntitlement(1f, 1f)); validateAutoCreatedLeafQueue(1); autoCreatedLeafQueue.setEntitlement(new QueueEntitlement(0f, 1f)); validateAutoCreatedLeafQueue(0); autoCreatedLeafQueue.setEntitlement(new QueueEntitlement(1.1f, 1f)); fail(); } catch (SchedulerDynamicEditException iae) { autoCreatedLeafQueue.setEntitlement(new QueueEntitlement(-0.1f, 1f)); fail(); } catch (SchedulerDynamicEditException iae) {
@Override public void reinitialize(CSQueue newlyParsedQueue, Resource clusterResource) throws IOException { try { writeLock.lock(); // Sanity check if (!(newlyParsedQueue instanceof ReservationQueue) || !newlyParsedQueue .getQueuePath().equals(getQueuePath())) { throw new IOException( "Trying to reinitialize " + getQueuePath() + " from " + newlyParsedQueue.getQueuePath()); } super.reinitialize(newlyParsedQueue, clusterResource); CSQueueUtils.updateQueueStatistics(resourceCalculator, clusterResource, this, labelManager, null); updateQuotas(parent.getUserLimitForReservation(), parent.getUserLimitFactor(), parent.getMaxApplicationsForReservations(), parent.getMaxApplicationsPerUserForReservation()); } finally { writeLock.unlock(); } }
return; newQueue.setEntitlement(entitlement); } else { throw new SchedulerDynamicEditException(
private void validateReservationQueue(double capacity) { assertTrue(" actual capacity: " + reservationQueue.getCapacity(), reservationQueue.getCapacity() - capacity < CSQueueUtils.EPSILON); assertEquals(reservationQueue.maxApplications, DEF_MAX_APPS); assertEquals(reservationQueue.maxApplicationsPerUser, DEF_MAX_APPS); }
public ReservationQueue(CapacitySchedulerContext cs, String queueName, PlanQueue parent) throws IOException { super(cs, queueName, parent, null); // the following parameters are common to all reservation in the plan updateQuotas(parent.getUserLimitForReservation(), parent.getUserLimitFactor(), parent.getMaxApplicationsForReservations(), parent.getMaxApplicationsPerUserForReservation()); this.parent = parent; }
new ReservationQueue(cs, "a1", (PlanQueue) cs.getQueue("a")); a1.setEntitlement(new QueueEntitlement(A1_CAPACITY / 100, 1f)); cs.addQueue(a1); fail(); new ReservationQueue(cs, "a1", (PlanQueue) cs.getQueue("a")); cs.addQueue(a1); .setEntitlement( new QueueEntitlement(0f, 1f)); a1.setEntitlement(new QueueEntitlement(A1_CAPACITY / 100, 1f)); new ReservationQueue(cs, "a2", (PlanQueue) cs.getQueue("a"));
private void updateQuotas(int userLimit, float userLimitFactor, int maxAppsForReservation, int maxAppsPerUserForReservation) { setUserLimit(userLimit); setUserLimitFactor(userLimitFactor); setMaxApplications(maxAppsForReservation); maxApplicationsPerUser = maxAppsPerUserForReservation; }
reservationQueue.setCapacity(1.0F); validateReservationQueue(1); reservationQueue.setEntitlement(new QueueEntitlement(0.9f, 1f)); validateReservationQueue(0.9); reservationQueue.setEntitlement(new QueueEntitlement(1f, 1f)); validateReservationQueue(1); reservationQueue.setEntitlement(new QueueEntitlement(0f, 1f)); validateReservationQueue(0); reservationQueue.setEntitlement(new QueueEntitlement(1.1f, 1f)); fail(); } catch (SchedulerDynamicEditException iae) { reservationQueue.setEntitlement(new QueueEntitlement(-0.1f, 1f)); fail(); } catch (SchedulerDynamicEditException iae) {
@Override public synchronized void reinitialize(CSQueue newlyParsedQueue, Resource clusterResource) throws IOException { // Sanity check if (!(newlyParsedQueue instanceof ReservationQueue) || !newlyParsedQueue.getQueuePath().equals(getQueuePath())) { throw new IOException("Trying to reinitialize " + getQueuePath() + " from " + newlyParsedQueue.getQueuePath()); } super.reinitialize(newlyParsedQueue, clusterResource); CSQueueUtils.updateQueueStatistics( parent.schedulerContext.getResourceCalculator(), newlyParsedQueue, parent, parent.schedulerContext.getClusterResource(), parent.schedulerContext.getMinimumResourceCapability()); updateQuotas(parent.getUserLimitForReservation(), parent.getUserLimitFactor(), parent.getMaxApplicationsForReservations(), parent.getMaxApplicationsPerUserForReservation()); }
@Override public synchronized void removeQueue(String queueName) throws SchedulerDynamicEditException { LOG.info("Removing queue: " + queueName); CSQueue q = this.getQueue(queueName); if (!(q instanceof ReservationQueue)) { throw new SchedulerDynamicEditException("The queue that we are asked " + "to remove (" + queueName + ") is not a ReservationQueue"); } ReservationQueue disposableLeafQueue = (ReservationQueue) q; // at this point we should have no more apps if (disposableLeafQueue.getNumApplications() > 0) { throw new SchedulerDynamicEditException("The queue " + queueName + " is not empty " + disposableLeafQueue.getApplications().size() + " active apps " + disposableLeafQueue.pendingApplications.size() + " pending apps"); } ((PlanQueue) disposableLeafQueue.getParent()).removeChildQueue(q); this.queues.remove(queueName); LOG.info("Removal of ReservationQueue " + queueName + " has succeeded"); }
return; newQueue.setEntitlement(entitlement); } else { throw new SchedulerDynamicEditException(
private void validateAutoCreatedLeafQueue(double capacity) { assertTrue(" actual capacity: " + autoCreatedLeafQueue.getCapacity(), autoCreatedLeafQueue.getCapacity() - capacity < CSQueueUtils.EPSILON); assertEquals(autoCreatedLeafQueue.maxApplications, DEF_MAX_APPS); assertEquals(autoCreatedLeafQueue.maxApplicationsPerUser, DEF_MAX_APPS); }
public ReservationQueue(CapacitySchedulerContext cs, String queueName, PlanQueue parent) throws IOException { super(cs, queueName, parent, null); // the following parameters are common to all reservation in the plan updateQuotas(parent.getUserLimitForReservation(), parent.getUserLimitFactor(), parent.getMaxApplicationsForReservations(), parent.getMaxApplicationsPerUserForReservation()); this.parent = parent; }
new ReservationQueue(cs, "a1", (PlanQueue) cs.getQueue("a")); a1.setEntitlement(new QueueEntitlement(A1_CAPACITY / 100, 1f)); cs.addQueue(a1); fail(); new ReservationQueue(cs, "a1", (PlanQueue) cs.getQueue("a")); cs.addQueue(a1); a1.setEntitlement(new QueueEntitlement(A1_CAPACITY / 100, 1f)); new ReservationQueue(cs, "a2", (PlanQueue) cs.getQueue("a"));