@Override void updateInternal() { readLock.lock(); try { policy.computeShares(runnableApps, getFairShare()); } finally { readLock.unlock(); } }
+ " does not extend SchedulingPolicy"); return getInstance(clazz);
private SchedulingPolicy extractSchedulingPolicy(Element element) throws AllocationConfigurationException { String text = getTrimmedTextData(element); if (text.equalsIgnoreCase(FifoPolicy.NAME)) { throw new AllocationConfigurationException("Bad fair scheduler " + "config file: defaultQueueSchedulingPolicy or " + "defaultQueueSchedulingMode can't be FIFO."); } return SchedulingPolicy.parse(text); }
public void testParseSchedulingPolicy() throws AllocationConfigurationException { // Class name SchedulingPolicy sm = SchedulingPolicy .parse(FairSharePolicy.class.getName()); assertTrue("Invalid scheduler name", sm.getName().equals(FairSharePolicy.NAME)); // Canonical name sm = SchedulingPolicy.parse(FairSharePolicy.class .getCanonicalName()); assertTrue("Invalid scheduler name", sm.getName().equals(FairSharePolicy.NAME)); // Class sm = SchedulingPolicy.getInstance(FairSharePolicy.class); assertTrue("Invalid scheduler name", sm.getName().equals(FairSharePolicy.NAME)); // Shortname - drf sm = SchedulingPolicy.parse("drf"); assertTrue("Invalid scheduler name", sm.getName().equals(DominantResourceFairnessPolicy.NAME)); // Shortname - fair sm = SchedulingPolicy.parse("fair"); assertTrue("Invalid scheduler name", sm.getName().equals(FairSharePolicy.NAME)); // Shortname - fifo sm = SchedulingPolicy.parse("fifo"); assertTrue("Invalid scheduler name", sm.getName().equals(FifoPolicy.NAME)); }
@Override protected void dumpStateInternal(StringBuilder sb) { sb.append("{Name: " + getName() + ", Weight: " + weights + ", Policy: " + policy.getName() + ", FairShare: " + getFairShare() + ", SteadyFairShare: " + getSteadyFairShare() + ", MaxShare: " + getMaxShare() + ", MinShare: " + minShare + ", ResourceUsage: " + getResourceUsage() + ", Demand: " + getDemand() + ", MaxAMShare: " + maxAMShare + ", Runnable: " + getNumRunnableApps() + "}"); for(FSQueue child : getChildQueues()) { sb.append(", "); child.dumpStateInternal(sb); } } }
SchedulingPolicy policy = SchedulingPolicy.parse("fifo"); assertTrue(ERR, SchedulingPolicy.isApplicableTo(policy, SchedulingPolicy.DEPTH_LEAF)); assertFalse(ERR, SchedulingPolicy.isApplicableTo( SchedulingPolicy.parse("fifo"), SchedulingPolicy.DEPTH_INTERMEDIATE)); assertFalse(ERR, SchedulingPolicy.isApplicableTo( SchedulingPolicy.parse("fifo"), SchedulingPolicy.DEPTH_ROOT)); policy = SchedulingPolicy.parse("fair"); assertTrue(ERR, SchedulingPolicy.isApplicableTo(policy, SchedulingPolicy.DEPTH_LEAF)); assertTrue(ERR, SchedulingPolicy.isApplicableTo(policy, SchedulingPolicy.DEPTH_INTERMEDIATE)); assertTrue(ERR, SchedulingPolicy.isApplicableTo(policy, SchedulingPolicy.DEPTH_ROOT)); assertTrue(ERR, SchedulingPolicy.isApplicableTo(policy, SchedulingPolicy.DEPTH_PARENT)); assertTrue(ERR, SchedulingPolicy.isApplicableTo(policy, SchedulingPolicy.DEPTH_ANY)); policy = SchedulingPolicy.parse("drf"); assertTrue(ERR, SchedulingPolicy.isApplicableTo(policy, SchedulingPolicy.DEPTH_LEAF)); assertTrue(ERR, SchedulingPolicy.isApplicableTo(policy, SchedulingPolicy.DEPTH_INTERMEDIATE)); assertTrue(ERR, SchedulingPolicy.isApplicableTo(policy, SchedulingPolicy.DEPTH_ROOT)); assertTrue(ERR, SchedulingPolicy.isApplicableTo(policy, SchedulingPolicy.DEPTH_PARENT));
@Override public RMContainer preemptContainer() { RMContainer toBePreempted = null; // Find the childQueue which is most over fair share FSQueue candidateQueue = null; Comparator<Schedulable> comparator = policy.getComparator(); for (FSQueue queue : childQueues) { if (candidateQueue == null || comparator.compare(queue, candidateQueue) > 0) { candidateQueue = queue; } } // Let the selected queue choose which of its container to preempt if (candidateQueue != null) { toBePreempted = candidateQueue.preemptContainer(); } return toBePreempted; }
public void setPolicy(SchedulingPolicy policy) { policy.initialize(scheduler.getContext()); this.policy = policy; }
@Override public void setPolicy(SchedulingPolicy policy) throws AllocationConfigurationException { if (!SchedulingPolicy.isApplicableTo(policy, SchedulingPolicy.DEPTH_LEAF)) { throwPolicyDoesnotApplyException(policy); } super.policy = policy; }
void recomputeSteadyShares() { readLock.lock(); try { policy.computeSteadyShares(childQueues, getSteadyFairShare()); for (FSQueue childQueue : childQueues) { childQueue.getMetrics() .setSteadyFairShare(childQueue.getSteadyFairShare()); if (childQueue instanceof FSParentQueue) { ((FSParentQueue) childQueue).recomputeSteadyShares(); } } } finally { readLock.unlock(); } }
clusterAvailableResources, queueMaxAvailableResources); Resource headroom = policy.getHeadroom(queueFairShare, queueUsage, maxAvailableResource); if (LOG.isDebugEnabled()) {
/** * Checks if the specified {@link SchedulingPolicy} can be used for a queue at * the specified depth in the hierarchy * * @param policy {@link SchedulingPolicy} we are checking the * depth-applicability for * @param depth queue's depth in the hierarchy * @return true if policy is applicable to passed depth, false otherwise */ public static boolean isApplicableTo(SchedulingPolicy policy, byte depth) { return ((policy.getApplicableDepth() & depth) == depth) ? true : false; }
.parse(FairSharePolicy.class.getName()); assertTrue("Invalid scheduler name", sm.getName().equals(FairSharePolicy.NAME)); sm = SchedulingPolicy.parse(FairSharePolicy.class .getCanonicalName()); assertTrue("Invalid scheduler name", sm.getName().equals(FairSharePolicy.NAME)); sm = SchedulingPolicy.getInstance(FairSharePolicy.class); assertTrue("Invalid scheduler name", sm.getName().equals(FairSharePolicy.NAME)); sm = SchedulingPolicy.parse("drf"); assertTrue("Invalid scheduler name", sm.getName().equals(DominantResourceFairnessPolicy.NAME)); sm = SchedulingPolicy.parse("fair"); assertTrue("Invalid scheduler name", sm.getName().equals(FairSharePolicy.NAME)); sm = SchedulingPolicy.parse("fifo"); assertTrue("Invalid scheduler name", sm.getName().equals(FifoPolicy.NAME));
@Override protected void dumpStateInternal(StringBuilder sb) { sb.append("{Name: " + getName() + ", Weight: " + weights + ", Policy: " + policy.getName() + ", FairShare: " + getFairShare() + ", SteadyFairShare: " + getSteadyFairShare() + ", MaxShare: " + getMaxShare() + ", MinShare: " + minShare + ", ResourceUsage: " + getResourceUsage() + ", Demand: " + getDemand() + ", Runnable: " + getNumRunnableApps() + ", NumPendingApps: " + getNumPendingApps() + ", NonRunnable: " + getNumNonRunnableApps() + ", MaxAMShare: " + maxAMShare + ", MaxAMResource: " + computeMaxAMResource() + ", AMResourceUsage: " + getAmResourceUsage() + ", LastTimeAtMinShare: " + lastTimeAtMinShare + "}"); }
@Override public RMContainer preemptContainer() { RMContainer toBePreempted = null; // Find the childQueue which is most over fair share FSQueue candidateQueue = null; Comparator<Schedulable> comparator = policy.getComparator(); for (FSQueue queue : childQueues) { if (candidateQueue == null || comparator.compare(queue, candidateQueue) > 0) { candidateQueue = queue; } } // Let the selected queue choose which of its container to preempt if (candidateQueue != null) { toBePreempted = candidateQueue.preemptContainer(); } return toBePreempted; }
@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(); } } }
@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 void recomputeSteadyShares() { policy.computeSteadyShares(childQueues, getSteadyFairShare()); for (FSQueue childQueue : childQueues) { childQueue.getMetrics().setSteadyFairShare(childQueue.getSteadyFairShare()); if (childQueue instanceof FSParentQueue) { ((FSParentQueue) childQueue).recomputeSteadyShares(); } } }
clusterAvailableResources, queueMaxAvailableResources); Resource headroom = policy.getHeadroom(queueFairShare, queueUsage, maxAvailableResource); if (LOG.isDebugEnabled()) {
/** * Checks if the specified {@link SchedulingPolicy} can be used for a queue at * the specified depth in the hierarchy * * @param policy {@link SchedulingPolicy} we are checking the * depth-applicability for * @param depth queue's depth in the hierarchy * @return true if policy is applicable to passed depth, false otherwise */ public static boolean isApplicableTo(SchedulingPolicy policy, byte depth) { return ((policy.getApplicableDepth() & depth) == depth) ? true : false; }