final AtomicReference<AllocationConfiguration> allocConf = new AtomicReference<AllocationConfiguration>(); AllocationFileLoaderService allocsLoader = new AllocationFileLoaderService(); allocsLoader.init(conf); allocsLoader.setReloadListener(new AllocationFileLoaderService.Listener() { @Override public void onReload(AllocationConfiguration allocs) { allocsLoader.reloadAllocations(); } catch (Exception ex) { throw new IOException("Failed to load queue allocations", ex); allocConf.set(new AllocationConfiguration(conf)); QueuePlacementPolicy queuePolicy = allocConf.get().getPlacementPolicy(); if (queuePolicy != null) { requestedQueue = queuePolicy.assignAppToQueue(requestedQueue, userName); if (StringUtils.isNotBlank(requestedQueue)) { LOG.debug("Setting queue name to " + requestedQueue + " for user "
@Override public void recomputeShares() { policy.computeShares(childQueues, getFairShare()); for (FSQueue childQueue : childQueues) { childQueue.getMetrics().setFairShare(childQueue.getFairShare()); childQueue.recomputeShares(); } }
private String handleMoveToPlanQueue(String targetQueueName) { FSQueue dest = queueMgr.getQueue(targetQueueName); if (dest != null && allocConf.isReservable(dest.getQueueName())) { // use the default child reservation queue of the plan targetQueueName = getDefaultQueueForPlanQueue(targetQueueName); } return targetQueueName; } }
public FSQueue(String name, FairScheduler scheduler, FSParentQueue parent) { this.name = name; this.scheduler = scheduler; this.metrics = FSQueueMetrics.forQueue(getName(), parent, true, scheduler.getConf()); metrics.setMinShare(getMinShare()); metrics.setMaxShare(getMaxShare()); this.parent = parent; }
public void recomputeSteadyShares() { policy.computeSteadyShares(childQueues, getSteadyFairShare()); for (FSQueue childQueue : childQueues) { childQueue.getMetrics().setSteadyFairShare(childQueue.getSteadyFairShare()); if (childQueue instanceof FSParentQueue) { ((FSParentQueue) childQueue).recomputeSteadyShares(); } } }
/** * Helper method to check if the queue should preempt containers * * @return true if check passes (can preempt) or false otherwise */ private boolean preemptContainerPreCheck() { return parent.getPolicy().checkIfUsageOverFairShare(getResourceUsage(), getFairShare()); }
@Override protected Resource getPlanQueueCapacity(String planQueueName) { return fairScheduler.getQueueManager().getParentQueue(planQueueName, false) .getSteadyFairShare(); }
private void removeApp(FSAppAttempt app) { app.getQueue().removeApp(app); maxAppsEnforcer.untrackRunnableApp(app); maxAppsEnforcer.updateRunnabilityOnAppRemoval(app, app.getQueue()); }
@Override public void onReload(AllocationConfiguration queueInfo) { // Commit the reload; also create any queue defined in the alloc file // if it does not already exist, so it can be displayed on the web UI. synchronized (FairScheduler.this) { allocConf = queueInfo; allocConf.getDefaultSchedulingPolicy().initialize(clusterResource); queueMgr.updateAllocationConfiguration(allocConf); maxRunningEnforcer.updateRunnabilityOnReload(); } } }
/** * Helper method that checks if {@code usage} is strictly less than * {@code share}. */ private boolean isUsageBelowShare(Resource usage, Resource share) { return getQueue().getPolicy().getResourceCalculator().compare( scheduler.getClusterResource(), usage, share, true) < 0; }
private boolean isReservable(Resource capacity) { // Reserve only when the app is starved and the requested container size // is larger than the configured threshold return isStarved() && scheduler.isAtLeastReservationThreshold( getQueue().getPolicy().getResourceCalculator(), capacity); }
protected void throwPolicyDoesnotApplyException(SchedulingPolicy policy) throws AllocationConfigurationException { throw new AllocationConfigurationException("SchedulingPolicy " + policy + " does not apply to queue " + getName()); }
@Override public void setPolicy(SchedulingPolicy policy) throws AllocationConfigurationException { if (!SchedulingPolicy.isApplicableTo(policy, SchedulingPolicy.DEPTH_LEAF)) { throwPolicyDoesnotApplyException(policy); } super.policy = policy; }
@Override public void setPolicy(SchedulingPolicy policy) throws AllocationConfigurationException { boolean allowed = SchedulingPolicy.isApplicableTo(policy, (parent == null) ? SchedulingPolicy.DEPTH_ROOT : SchedulingPolicy.DEPTH_INTERMEDIATE); if (!allowed) { throwPolicyDoesnotApplyException(policy); } super.policy = policy; }
public FSQueue(String name, FairScheduler scheduler, FSParentQueue parent) { this.name = name; this.scheduler = scheduler; this.metrics = FSQueueMetrics.forQueue(getName(), parent, true, scheduler.getConf()); metrics.setMinShare(getMinShare()); metrics.setMaxShare(getMaxShare()); this.parent = parent; }
@Override public void recomputeShares() { policy.computeShares(childQueues, getFairShare()); for (FSQueue childQueue : childQueues) { childQueue.getMetrics().setFairShare(childQueue.getFairShare()); childQueue.recomputeShares(); } }
private String handleMoveToPlanQueue(String targetQueueName) { FSQueue dest = queueMgr.getQueue(targetQueueName); if (dest != null && allocConf.isReservable(dest.getQueueName())) { // use the default child reservation queue of the plan targetQueueName = getDefaultQueueForPlanQueue(targetQueueName); } return targetQueueName; }
/** * Helper method to check if the queue should preempt containers * * @return true if check passes (can preempt) or false otherwise */ private boolean preemptContainerPreCheck() { return parent.getPolicy().checkIfUsageOverFairShare(getResourceUsage(), getFairShare()); }
@Override protected Resource getPlanQueueCapacity(String planQueueName) { return fairScheduler.getQueueManager().getParentQueue(planQueueName, false) .getSteadyFairShare(); }
private String handleMoveToPlanQueue(String targetQueueName) { FSQueue dest = queueMgr.getQueue(targetQueueName); if (dest != null && allocConf.isReservable(dest.getQueueName())) { // use the default child reservation queue of the plan targetQueueName = getDefaultQueueForPlanQueue(targetQueueName); } return targetQueueName; } }