Search in sources :

Example 1 with DominantResourceCalculator

use of org.apache.hadoop.yarn.util.resource.DominantResourceCalculator in project hadoop by apache.

the class TestProportionalCapacityPreemptionPolicy method buildPolicy.

ProportionalCapacityPreemptionPolicy buildPolicy(int[][] qData, String[][] resData, boolean useDominantResourceCalculator) {
    if (useDominantResourceCalculator) {
        when(mCS.getResourceCalculator()).thenReturn(new DominantResourceCalculator());
    }
    ProportionalCapacityPreemptionPolicy policy = new ProportionalCapacityPreemptionPolicy(rmContext, mCS, mClock);
    clusterResources = leafAbsCapacities(parseResourceDetails(resData[0]), qData[2]);
    ParentQueue mRoot = buildMockRootQueue(rand, resData, qData);
    when(mCS.getRootQueue()).thenReturn(mRoot);
    setResourceAndNodeDetails();
    return policy;
}
Also used : ParentQueue(org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.ParentQueue) DominantResourceCalculator(org.apache.hadoop.yarn.util.resource.DominantResourceCalculator)

Example 2 with DominantResourceCalculator

use of org.apache.hadoop.yarn.util.resource.DominantResourceCalculator in project hadoop by apache.

the class TestSchedulerUtils method testNormalizeRequestWithDominantResourceCalculator.

@Test(timeout = 30000)
public void testNormalizeRequestWithDominantResourceCalculator() {
    ResourceCalculator resourceCalculator = new DominantResourceCalculator();
    Resource minResource = Resources.createResource(1024, 1);
    Resource maxResource = Resources.createResource(10240, 10);
    Resource clusterResource = Resources.createResource(10 * 1024, 10);
    ResourceRequest ask = new ResourceRequestPBImpl();
    // case negative memory/vcores
    ask.setCapability(Resources.createResource(-1024, -1));
    SchedulerUtils.normalizeRequest(ask, resourceCalculator, minResource, maxResource);
    assertEquals(minResource, ask.getCapability());
    // case zero memory/vcores
    ask.setCapability(Resources.createResource(0, 0));
    SchedulerUtils.normalizeRequest(ask, resourceCalculator, minResource, maxResource);
    assertEquals(minResource, ask.getCapability());
    assertEquals(1, ask.getCapability().getVirtualCores());
    assertEquals(1024, ask.getCapability().getMemorySize());
    // case non-zero memory & zero cores
    ask.setCapability(Resources.createResource(1536, 0));
    SchedulerUtils.normalizeRequest(ask, resourceCalculator, minResource, maxResource);
    assertEquals(Resources.createResource(2048, 1), ask.getCapability());
    assertEquals(1, ask.getCapability().getVirtualCores());
    assertEquals(2048, ask.getCapability().getMemorySize());
}
Also used : DefaultResourceCalculator(org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator) DominantResourceCalculator(org.apache.hadoop.yarn.util.resource.DominantResourceCalculator) ResourceCalculator(org.apache.hadoop.yarn.util.resource.ResourceCalculator) DominantResourceCalculator(org.apache.hadoop.yarn.util.resource.DominantResourceCalculator) Resource(org.apache.hadoop.yarn.api.records.Resource) ResourceRequestPBImpl(org.apache.hadoop.yarn.api.records.impl.pb.ResourceRequestPBImpl) ResourceRequest(org.apache.hadoop.yarn.api.records.ResourceRequest) Test(org.junit.Test)

Example 3 with DominantResourceCalculator

use of org.apache.hadoop.yarn.util.resource.DominantResourceCalculator in project hadoop by apache.

the class ProportionalCapacityPreemptionPolicyMockFramework method buildEnv.

public void buildEnv(String labelsConfig, String nodesConfig, String queuesConfig, String appsConfig, boolean useDominantResourceCalculator) throws IOException {
    if (useDominantResourceCalculator) {
        when(cs.getResourceCalculator()).thenReturn(new DominantResourceCalculator());
    }
    mockNodeLabelsManager(labelsConfig);
    mockSchedulerNodes(nodesConfig);
    for (NodeId nodeId : nodeIdToSchedulerNodes.keySet()) {
        when(cs.getSchedulerNode(nodeId)).thenReturn(nodeIdToSchedulerNodes.get(nodeId));
    }
    List<FiCaSchedulerNode> allNodes = new ArrayList<>(nodeIdToSchedulerNodes.values());
    when(cs.getAllNodes()).thenReturn(allNodes);
    ParentQueue root = mockQueueHierarchy(queuesConfig);
    when(cs.getRootQueue()).thenReturn(root);
    when(cs.getClusterResource()).thenReturn(clusterResource);
    mockApplications(appsConfig);
    policy = new ProportionalCapacityPreemptionPolicy(rmContext, cs, mClock);
}
Also used : ParentQueue(org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.ParentQueue) FiCaSchedulerNode(org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode) DominantResourceCalculator(org.apache.hadoop.yarn.util.resource.DominantResourceCalculator) NodeId(org.apache.hadoop.yarn.api.records.NodeId) ArrayList(java.util.ArrayList)

Aggregations

DominantResourceCalculator (org.apache.hadoop.yarn.util.resource.DominantResourceCalculator)3 ParentQueue (org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.ParentQueue)2 ArrayList (java.util.ArrayList)1 NodeId (org.apache.hadoop.yarn.api.records.NodeId)1 Resource (org.apache.hadoop.yarn.api.records.Resource)1 ResourceRequest (org.apache.hadoop.yarn.api.records.ResourceRequest)1 ResourceRequestPBImpl (org.apache.hadoop.yarn.api.records.impl.pb.ResourceRequestPBImpl)1 FiCaSchedulerNode (org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode)1 DefaultResourceCalculator (org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator)1 ResourceCalculator (org.apache.hadoop.yarn.util.resource.ResourceCalculator)1 Test (org.junit.Test)1