/** * This method recursively computes the ideal assignment of resources to each * level of the hierarchy. This ensures that leafs that are over-capacity but * with parents within capacity will not be preemptionCandidates. Preemptions * are allowed within each subtree according to local over/under capacity. * * @param root the root of the cloned queue hierachy * @param totalPreemptionAllowed maximum amount of preemption allowed */ protected void recursivelyComputeIdealAssignment( TempQueuePerPartition root, Resource totalPreemptionAllowed) { if (root.getChildren() != null && root.getChildren().size() > 0) { // compute ideal distribution at this level computeIdealResourceDistribution(rc, root.getChildren(), totalPreemptionAllowed, root.idealAssigned); // compute recursively for lower levels and build list of leafs for (TempQueuePerPartition t : root.getChildren()) { recursivelyComputeIdealAssignment(t, totalPreemptionAllowed); } } }
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); } }