Search in sources :

Example 11 with CSQueue

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

the class TestPriorityUtilizationQueueOrderingPolicy method verifyOrder.

private void verifyOrder(QueueOrderingPolicy orderingPolicy, String partition, String[] expectedOrder) {
    Iterator<CSQueue> iter = orderingPolicy.getAssignmentIterator(partition);
    int i = 0;
    while (iter.hasNext()) {
        CSQueue q = iter.next();
        Assert.assertEquals(expectedOrder[i], q.getQueueName());
        i++;
    }
    assert i == expectedOrder.length;
}
Also used : CSQueue(org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueue)

Example 12 with CSQueue

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

the class PreemptionManager method refreshQueues.

public void refreshQueues(CSQueue parent, CSQueue current) {
    try {
        writeLock.lock();
        PreemptableQueue parentEntity = null;
        if (parent != null) {
            parentEntity = entities.get(parent.getQueueName());
        }
        if (!entities.containsKey(current.getQueueName())) {
            entities.put(current.getQueueName(), new PreemptableQueue(parentEntity));
        }
        if (current.getChildQueues() != null) {
            for (CSQueue child : current.getChildQueues()) {
                refreshQueues(current, child);
            }
        }
    } finally {
        writeLock.unlock();
    }
}
Also used : CSQueue(org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueue)

Example 13 with CSQueue

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

the class CapacitySchedulerInfo method getQueues.

protected CapacitySchedulerQueueInfoList getQueues(CSQueue parent) {
    CapacitySchedulerQueueInfoList queuesInfo = new CapacitySchedulerQueueInfoList();
    // JAXB marashalling leads to situation where the "type" field injected
    // for JSON changes from string to array depending on order of printing
    // Issue gets fixed if all the leaf queues are marshalled before the
    // non-leaf queues. See YARN-4785 for more details.
    List<CSQueue> childQueues = new ArrayList<>();
    List<CSQueue> childLeafQueues = new ArrayList<>();
    List<CSQueue> childNonLeafQueues = new ArrayList<>();
    for (CSQueue queue : parent.getChildQueues()) {
        if (queue instanceof LeafQueue) {
            childLeafQueues.add(queue);
        } else {
            childNonLeafQueues.add(queue);
        }
    }
    childQueues.addAll(childLeafQueues);
    childQueues.addAll(childNonLeafQueues);
    for (CSQueue queue : childQueues) {
        CapacitySchedulerQueueInfo info;
        if (queue instanceof LeafQueue) {
            info = new CapacitySchedulerLeafQueueInfo((LeafQueue) queue);
        } else {
            info = new CapacitySchedulerQueueInfo(queue);
            info.queues = getQueues(queue);
        }
        queuesInfo.addToQueueInfoList(info);
    }
    return queuesInfo;
}
Also used : ArrayList(java.util.ArrayList) LeafQueue(org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.LeafQueue) CSQueue(org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueue)

Example 14 with CSQueue

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

the class TestProportionalCapacityPreemptionPolicy method mockParentQueue.

ParentQueue mockParentQueue(ParentQueue p, int subqueues, Deque<ParentQueue> pqs) {
    ParentQueue pq = mock(ParentQueue.class);
    List<CSQueue> cqs = new ArrayList<CSQueue>();
    when(pq.getChildQueues()).thenReturn(cqs);
    ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
    when(pq.getReadLock()).thenReturn(lock.readLock());
    // Ordering policy
    QueueOrderingPolicy policy = mock(QueueOrderingPolicy.class);
    when(policy.getConfigName()).thenReturn(CapacitySchedulerConfiguration.QUEUE_PRIORITY_UTILIZATION_ORDERING_POLICY);
    when(pq.getQueueOrderingPolicy()).thenReturn(policy);
    when(pq.getPriority()).thenReturn(Priority.newInstance(0));
    for (int i = 0; i < subqueues; ++i) {
        pqs.add(pq);
    }
    if (p != null) {
        p.getChildQueues().add(pq);
    }
    return pq;
}
Also used : ParentQueue(org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.ParentQueue) ArrayList(java.util.ArrayList) ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) QueueOrderingPolicy(org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.policy.QueueOrderingPolicy) CSQueue(org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueue)

Example 15 with CSQueue

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

the class TestProportionalCapacityPreemptionPolicy method mockNested.

ParentQueue mockNested(Resource[] abs, int[] maxCap, Resource[] used, Resource[] pending, Resource[] reserved, int[] apps, Resource[] gran, int[] queues) {
    ResourceCalculator rc = mCS.getResourceCalculator();
    Resource tot = leafAbsCapacities(abs, queues);
    Deque<ParentQueue> pqs = new LinkedList<ParentQueue>();
    ParentQueue root = mockParentQueue(null, queues[0], pqs);
    ResourceUsage resUsage = new ResourceUsage();
    resUsage.setUsed(used[0]);
    resUsage.setReserved(reserved[0]);
    when(root.getQueueName()).thenReturn(CapacitySchedulerConfiguration.ROOT);
    when(root.getAbsoluteUsedCapacity()).thenReturn(Resources.divide(rc, tot, used[0], tot));
    when(root.getAbsoluteCapacity()).thenReturn(Resources.divide(rc, tot, abs[0], tot));
    when(root.getAbsoluteMaximumCapacity()).thenReturn(maxCap[0] / (float) tot.getMemorySize());
    when(root.getQueueResourceUsage()).thenReturn(resUsage);
    QueueCapacities rootQc = new QueueCapacities(true);
    rootQc.setAbsoluteUsedCapacity(Resources.divide(rc, tot, used[0], tot));
    rootQc.setAbsoluteCapacity(Resources.divide(rc, tot, abs[0], tot));
    rootQc.setAbsoluteMaximumCapacity(maxCap[0] / (float) tot.getMemorySize());
    when(root.getQueueCapacities()).thenReturn(rootQc);
    when(root.getQueuePath()).thenReturn(CapacitySchedulerConfiguration.ROOT);
    boolean preemptionDisabled = mockPreemptionStatus("root");
    when(root.getPreemptionDisabled()).thenReturn(preemptionDisabled);
    for (int i = 1; i < queues.length; ++i) {
        final CSQueue q;
        final ParentQueue p = pqs.removeLast();
        final String queueName = "queue" + ((char) ('A' + i - 1));
        if (queues[i] > 0) {
            q = mockParentQueue(p, queues[i], pqs);
            ResourceUsage resUsagePerQueue = new ResourceUsage();
            resUsagePerQueue.setUsed(used[i]);
            resUsagePerQueue.setReserved(reserved[i]);
            when(q.getQueueResourceUsage()).thenReturn(resUsagePerQueue);
        } else {
            q = mockLeafQueue(p, tot, i, abs, used, pending, reserved, apps, gran);
        }
        when(q.getParent()).thenReturn(p);
        when(q.getQueueName()).thenReturn(queueName);
        when(q.getAbsoluteUsedCapacity()).thenReturn(Resources.divide(rc, tot, used[i], tot));
        when(q.getAbsoluteCapacity()).thenReturn(Resources.divide(rc, tot, abs[i], tot));
        when(q.getAbsoluteMaximumCapacity()).thenReturn(maxCap[i] / (float) tot.getMemorySize());
        // We need to make these fields to QueueCapacities
        QueueCapacities qc = new QueueCapacities(false);
        qc.setAbsoluteUsedCapacity(Resources.divide(rc, tot, used[i], tot));
        qc.setAbsoluteCapacity(Resources.divide(rc, tot, abs[i], tot));
        qc.setAbsoluteMaximumCapacity(maxCap[i] / (float) tot.getMemorySize());
        when(q.getQueueCapacities()).thenReturn(qc);
        String parentPathName = p.getQueuePath();
        parentPathName = (parentPathName == null) ? "root" : parentPathName;
        String queuePathName = (parentPathName + "." + queueName).replace("/", "root");
        when(q.getQueuePath()).thenReturn(queuePathName);
        preemptionDisabled = mockPreemptionStatus(queuePathName);
        when(q.getPreemptionDisabled()).thenReturn(preemptionDisabled);
    }
    assert 0 == pqs.size();
    return root;
}
Also used : ParentQueue(org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.ParentQueue) DefaultResourceCalculator(org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator) DominantResourceCalculator(org.apache.hadoop.yarn.util.resource.DominantResourceCalculator) ResourceCalculator(org.apache.hadoop.yarn.util.resource.ResourceCalculator) QueueCapacities(org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.QueueCapacities) ResourceUsage(org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceUsage) Resource(org.apache.hadoop.yarn.api.records.Resource) Matchers.anyString(org.mockito.Matchers.anyString) LinkedList(java.util.LinkedList) 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