Search in sources :

Example 16 with CSQueue

use of org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueue in project hadoop by apache.

the class SLSCapacityScheduler method initQueueMetrics.

private void initQueueMetrics(CSQueue queue) {
    if (queue instanceof LeafQueue) {
        SortedMap<String, Counter> counterMap = metrics.getCounters();
        String queueName = queue.getQueueName();
        String[] names = new String[] { QUEUE_COUNTER_PREFIX + queueName + ".pending.memory", QUEUE_COUNTER_PREFIX + queueName + ".pending.cores", QUEUE_COUNTER_PREFIX + queueName + ".allocated.memory", QUEUE_COUNTER_PREFIX + queueName + ".allocated.cores" };
        for (int i = names.length - 1; i >= 0; i--) {
            if (!counterMap.containsKey(names[i])) {
                metrics.counter(names[i]);
                counterMap = metrics.getCounters();
            }
        }
        queueLock.lock();
        try {
            if (!schedulerMetrics.isTracked(queueName)) {
                schedulerMetrics.trackQueue(queueName);
            }
        } finally {
            queueLock.unlock();
        }
        return;
    }
    for (CSQueue child : queue.getChildQueues()) {
        initQueueMetrics(child);
    }
}
Also used : Counter(com.codahale.metrics.Counter) LeafQueue(org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.LeafQueue) CSQueue(org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueue)

Example 17 with CSQueue

use of org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueue in project hadoop by apache.

the class ProportionalCapacityPreemptionPolicy method cloneQueues.

/**
   * This method walks a tree of CSQueue and clones the portion of the state
   * relevant for preemption in TempQueue(s). It also maintains a pointer to
   * the leaves. Finally it aggregates pending resources in each queue and rolls
   * it up to higher levels.
   *
   * @param curQueue current queue which I'm looking at now
   * @param partitionResource the total amount of resources in the cluster
   * @return the root of the cloned queue hierarchy
   */
private TempQueuePerPartition cloneQueues(CSQueue curQueue, Resource partitionResource, String partitionToLookAt) {
    TempQueuePerPartition ret;
    ReadLock readLock = curQueue.getReadLock();
    try {
        // Acquire a read lock from Parent/LeafQueue.
        readLock.lock();
        String queueName = curQueue.getQueueName();
        QueueCapacities qc = curQueue.getQueueCapacities();
        float absCap = qc.getAbsoluteCapacity(partitionToLookAt);
        float absMaxCap = qc.getAbsoluteMaximumCapacity(partitionToLookAt);
        boolean preemptionDisabled = curQueue.getPreemptionDisabled();
        Resource current = Resources.clone(curQueue.getQueueResourceUsage().getUsed(partitionToLookAt));
        Resource killable = Resources.none();
        Resource reserved = Resources.clone(curQueue.getQueueResourceUsage().getReserved(partitionToLookAt));
        if (null != preemptableQueues.get(queueName)) {
            killable = Resources.clone(preemptableQueues.get(queueName).getKillableResource(partitionToLookAt));
        }
        // could more than specified maxCapacity
        try {
            if (!scheduler.getRMContext().getNodeLabelManager().isExclusiveNodeLabel(partitionToLookAt)) {
                absMaxCap = 1.0f;
            }
        } catch (IOException e) {
        // This may cause by partition removed when running capacity monitor,
        // just ignore the error, this will be corrected when doing next check.
        }
        ret = new TempQueuePerPartition(queueName, current, preemptionDisabled, partitionToLookAt, killable, absCap, absMaxCap, partitionResource, reserved, curQueue);
        if (curQueue instanceof ParentQueue) {
            String configuredOrderingPolicy = ((ParentQueue) curQueue).getQueueOrderingPolicy().getConfigName();
            // Recursively add children
            for (CSQueue c : curQueue.getChildQueues()) {
                TempQueuePerPartition subq = cloneQueues(c, partitionResource, partitionToLookAt);
                // If we respect priority
                if (StringUtils.equals(CapacitySchedulerConfiguration.QUEUE_PRIORITY_UTILIZATION_ORDERING_POLICY, configuredOrderingPolicy)) {
                    subq.relativePriority = c.getPriority().getPriority();
                }
                ret.addChild(subq);
                subq.parent = ret;
            }
        }
    } finally {
        readLock.unlock();
    }
    addTempQueuePartition(ret);
    return ret;
}
Also used : ReadLock(java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock) ParentQueue(org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.ParentQueue) QueueCapacities(org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.QueueCapacities) Resource(org.apache.hadoop.yarn.api.records.Resource) IOException(java.io.IOException) CSQueue(org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueue)

Example 18 with CSQueue

use of org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueue in project hadoop by apache.

the class ProportionalCapacityPreemptionPolicy method editSchedule.

@Override
public synchronized void editSchedule() {
    long startTs = clock.getTime();
    CSQueue root = scheduler.getRootQueue();
    Resource clusterResources = Resources.clone(scheduler.getClusterResource());
    containerBasedPreemptOrKill(root, clusterResources);
    if (LOG.isDebugEnabled()) {
        LOG.debug("Total time used=" + (clock.getTime() - startTs) + " ms.");
    }
}
Also used : Resource(org.apache.hadoop.yarn.api.records.Resource) CSQueue(org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueue)

Example 19 with CSQueue

use of org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueue in project hadoop by apache.

the class CapacitySchedulerPlanFollower method getChildReservationQueues.

@Override
protected List<? extends Queue> getChildReservationQueues(Queue queue) {
    PlanQueue planQueue = (PlanQueue) queue;
    List<CSQueue> childQueues = planQueue.getChildQueues();
    return childQueues;
}
Also used : PlanQueue(org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.PlanQueue) CSQueue(org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueue)

Example 20 with CSQueue

use of org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueue in project hadoop by apache.

the class CapacitySchedulerPlanFollower method getReservationQueueResourceIfExists.

@Override
protected Resource getReservationQueueResourceIfExists(Plan plan, ReservationId reservationId) {
    CSQueue resQueue = cs.getQueue(reservationId.toString());
    Resource reservationResource = null;
    if (resQueue != null) {
        reservationResource = Resources.multiply(cs.getClusterResource(), resQueue.getAbsoluteCapacity());
    }
    return reservationResource;
}
Also used : Resource(org.apache.hadoop.yarn.api.records.Resource) CSQueue(org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueue)

Aggregations

CSQueue (org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueue)20 Resource (org.apache.hadoop.yarn.api.records.Resource)5 ArrayList (java.util.ArrayList)4 ParentQueue (org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.ParentQueue)4 LeafQueue (org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.LeafQueue)3 QueueCapacities (org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.QueueCapacities)3 ReentrantReadWriteLock (java.util.concurrent.locks.ReentrantReadWriteLock)2 CapacityScheduler (org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler)2 QueueOrderingPolicy (org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.policy.QueueOrderingPolicy)2 ResourceCalculator (org.apache.hadoop.yarn.util.resource.ResourceCalculator)2 Matchers.anyString (org.mockito.Matchers.anyString)2 Counter (com.codahale.metrics.Counter)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 TreeSet (java.util.TreeSet)1 ReadLock (java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1