TempQueuePerPartition tq1 = preemptionContext.getQueueByPartition(q1, RMNodeLabelsManager.NO_LABEL); TempQueuePerPartition tq2 = preemptionContext.getQueueByPartition(q2, RMNodeLabelsManager.NO_LABEL);
@Override public Map<String, Resource> getResourceDemandFromAppsPerQueue( String queueName, String partition) { Map<String, Resource> resToObtainByPartition = new HashMap<>(); TempQueuePerPartition tq = context .getQueueByPartition(queueName, partition); Collection<TempAppPerPartition> appsOrderedByPriority = tq.getApps(); Resource actualPreemptNeeded = resToObtainByPartition.get(partition); // Updating pending resource per-partition level. if (actualPreemptNeeded == null) { actualPreemptNeeded = Resources.createResource(0, 0); resToObtainByPartition.put(partition, actualPreemptNeeded); } for (TempAppPerPartition a1 : appsOrderedByPriority) { Resources.addTo(actualPreemptNeeded, a1.getActuallyToBePreempted()); } if (LOG.isDebugEnabled()) { LOG.debug("Selected to preempt " + actualPreemptNeeded + " resource from partition:" + partition); } return resToObtainByPartition; }
@Override public Collection<FiCaSchedulerApp> getPreemptableApps(String queueName, String partition) { TempQueuePerPartition tq = context.getQueueByPartition(queueName, partition); List<FiCaSchedulerApp> apps = new ArrayList<FiCaSchedulerApp>(); for (TempAppPerPartition tmpApp : tq.getApps()) { // If a lower priority app was not selected to get preempted, mark such // apps out from preemption candidate selection. if (Resources.equals(tmpApp.getActuallyToBePreempted(), Resources.none())) { continue; } apps.add(tmpApp.app); } return apps; }
if (preemptionContext.getQueueByPartition(queueName, RMNodeLabelsManager.NO_LABEL).preemptionDisabled) { if (LOG.isDebugEnabled()) { LeafQueue leafQueue = preemptionContext.getQueueByPartition(queueName, RMNodeLabelsManager.NO_LABEL).leafQueue;
public void computeIdealAllocation(Resource clusterResource, Resource totalPreemptionAllowed) { for (String partition : context.getAllPartitions()) { TempQueuePerPartition tRoot = context.getQueueByPartition( CapacitySchedulerConfiguration.ROOT, partition); updatePreemptableExtras(tRoot); // compute the ideal distribution of resources among queues // updates cloned queues state accordingly tRoot.initializeRootIdealWithGuarangeed(); recursivelyComputeIdealAssignment(tRoot, totalPreemptionAllowed); } // based on ideal allocation select containers to be preempted from each // calculate resource-to-obtain by partition for each leaf queues calculateResToObtainByPartitionForLeafQueues(context.getLeafQueueNames(), clusterResource); } }
/** * Do we allow the demanding queue preempt resource from other queues? * A satisfied queue is not allowed to preempt resource from other queues. * @param demandingQueue * @return allowed/not */ private boolean isQueueSatisfied(String demandingQueue, String partition) { TempQueuePerPartition tq = preemptionContext.getQueueByPartition( demandingQueue, partition); if (null == tq) { return false; } Resource guaranteed = tq.getGuaranteed(); Resource usedDeductReservd = Resources.subtract(tq.getUsed(), tq.getReserved()); Resource markedToPreemptFromOtherQueue = toPreemptedFromOtherQueues.get( demandingQueue, partition); if (null == markedToPreemptFromOtherQueue) { markedToPreemptFromOtherQueue = Resources.none(); } // return Used - reserved + to-preempt-from-other-queue >= guaranteed boolean flag = Resources.greaterThanOrEqual(rc, clusterResource, Resources.add(usedDeductReservd, markedToPreemptFromOtherQueue), guaranteed); return flag; }
TempQueuePerPartition tq = context.getQueueByPartition(queue, partition);
LeafQueue leafQueue = preemptionContext.getQueueByPartition(queueName, RMNodeLabelsManager.NO_LABEL).leafQueue;
if (context.getQueueByPartition(queueName, RMNodeLabelsManager.NO_LABEL).preemptionDisabled) { if (LOG.isDebugEnabled()) {
TempQueuePerPartition tq = context.getQueueByPartition(app.getQueueName(), partition); TempUserPerPartition tmpUser = tq.getUsersPerPartition().get(app.getUser());
TempQueuePerPartition tq = context.getQueueByPartition(queueName, partition); LeafQueue leafQueue = tq.leafQueue;