Search in sources :

Example 16 with DefaultResourceCalculator

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

the class TestInMemoryReservationAllocation method setUp.

@Before
public void setUp() {
    resCalc = new DefaultResourceCalculator();
    minAlloc = Resource.newInstance(1, 1);
}
Also used : DefaultResourceCalculator(org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator) Before(org.junit.Before)

Example 17 with DefaultResourceCalculator

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

the class TestNoOverCommitPolicy method setup.

@Before
public void setup() throws Exception {
    // 1 sec step
    step = 1000L;
    initTime = System.currentTimeMillis();
    minAlloc = Resource.newInstance(1024, 1);
    res = new DefaultResourceCalculator();
    maxAlloc = Resource.newInstance(1024 * 8, 8);
    mAgent = mock(ReservationAgent.class);
    String reservationQ = ReservationSystemTestUtil.getFullReservationQueueName();
    QueueMetrics rootQueueMetrics = mock(QueueMetrics.class);
    Resource clusterResource = ReservationSystemTestUtil.calculateClusterResource(totCont);
    ReservationSchedulerConfiguration conf = mock(ReservationSchedulerConfiguration.class);
    NoOverCommitPolicy policy = new NoOverCommitPolicy();
    policy.init(reservationQ, conf);
    RMContext context = ReservationSystemTestUtil.createMockRMContext();
    plan = new InMemoryPlan(rootQueueMetrics, policy, mAgent, clusterResource, step, res, minAlloc, maxAlloc, "dedicated", null, true, context);
}
Also used : QueueMetrics(org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueMetrics) RMContext(org.apache.hadoop.yarn.server.resourcemanager.RMContext) DefaultResourceCalculator(org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator) ReservationAgent(org.apache.hadoop.yarn.server.resourcemanager.reservation.planning.ReservationAgent) Resource(org.apache.hadoop.yarn.api.records.Resource) Before(org.junit.Before)

Example 18 with DefaultResourceCalculator

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

the class TestRLESparseResourceAllocation method testRangeOverlapping.

@Test
public void testRangeOverlapping() {
    ResourceCalculator resCalc = new DefaultResourceCalculator();
    RLESparseResourceAllocation r = new RLESparseResourceAllocation(resCalc);
    int[] alloc = { 10, 10, 10, 10, 10, 10 };
    int start = 100;
    Set<Entry<ReservationInterval, Resource>> inputs = generateAllocation(start, alloc, false).entrySet();
    for (Entry<ReservationInterval, Resource> ip : inputs) {
        r.addInterval(ip.getKey(), ip.getValue());
    }
    long s = r.getEarliestStartTime();
    long d = r.getLatestNonNullTime();
    // tries to trigger "out-of-range" bug
    r = r.getRangeOverlapping(s, d);
    r = r.getRangeOverlapping(s - 1, d - 1);
    r = r.getRangeOverlapping(s + 1, d + 1);
}
Also used : DefaultResourceCalculator(org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator) ResourceCalculator(org.apache.hadoop.yarn.util.resource.ResourceCalculator) Entry(java.util.Map.Entry) DefaultResourceCalculator(org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator) Resource(org.apache.hadoop.yarn.api.records.Resource) Test(org.junit.Test)

Example 19 with DefaultResourceCalculator

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

the class TestRLESparseResourceAllocation method testBlocks.

@Test
public void testBlocks() {
    ResourceCalculator resCalc = new DefaultResourceCalculator();
    RLESparseResourceAllocation rleSparseVector = new RLESparseResourceAllocation(resCalc);
    int[] alloc = { 10, 10, 10, 10, 10, 10 };
    int start = 100;
    Set<Entry<ReservationInterval, Resource>> inputs = generateAllocation(start, alloc, false).entrySet();
    for (Entry<ReservationInterval, Resource> ip : inputs) {
        rleSparseVector.addInterval(ip.getKey(), ip.getValue());
    }
    LOG.info(rleSparseVector.toString());
    Assert.assertFalse(rleSparseVector.isEmpty());
    Assert.assertEquals(Resource.newInstance(0, 0), rleSparseVector.getCapacityAtTime(99));
    Assert.assertEquals(Resource.newInstance(0, 0), rleSparseVector.getCapacityAtTime(start + alloc.length + 1));
    for (int i = 0; i < alloc.length; i++) {
        Assert.assertEquals(Resource.newInstance(1024 * (alloc[i]), (alloc[i])), rleSparseVector.getCapacityAtTime(start + i));
    }
    Assert.assertEquals(Resource.newInstance(0, 0), rleSparseVector.getCapacityAtTime(start + alloc.length + 2));
    for (Entry<ReservationInterval, Resource> ip : inputs) {
        rleSparseVector.removeInterval(ip.getKey(), ip.getValue());
    }
    LOG.info(rleSparseVector.toString());
    for (int i = 0; i < alloc.length; i++) {
        Assert.assertEquals(Resource.newInstance(0, 0), rleSparseVector.getCapacityAtTime(start + i));
    }
    Assert.assertTrue(rleSparseVector.isEmpty());
}
Also used : DefaultResourceCalculator(org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator) ResourceCalculator(org.apache.hadoop.yarn.util.resource.ResourceCalculator) Entry(java.util.Map.Entry) DefaultResourceCalculator(org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator) Resource(org.apache.hadoop.yarn.api.records.Resource) Test(org.junit.Test)

Example 20 with DefaultResourceCalculator

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

the class TestRLESparseResourceAllocation method testMergeMax.

@Test
public void testMergeMax() throws PlanningException {
    TreeMap<Long, Resource> a = new TreeMap<>();
    TreeMap<Long, Resource> b = new TreeMap<>();
    setupArrays(a, b);
    RLESparseResourceAllocation rleA = new RLESparseResourceAllocation(a, new DefaultResourceCalculator());
    RLESparseResourceAllocation rleB = new RLESparseResourceAllocation(b, new DefaultResourceCalculator());
    RLESparseResourceAllocation out = RLESparseResourceAllocation.merge(new DefaultResourceCalculator(), Resource.newInstance(100 * 128 * 1024, 100 * 32), rleA, rleB, RLEOperator.max, 0, 60);
    System.out.println(out);
    long[] time = { 10, 20, 30, 40, 50, 60 };
    int[] alloc = { 5, 10, 15, 20, 10 };
    validate(out, time, alloc);
}
Also used : DefaultResourceCalculator(org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator) Resource(org.apache.hadoop.yarn.api.records.Resource) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Aggregations

DefaultResourceCalculator (org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator)27 Resource (org.apache.hadoop.yarn.api.records.Resource)22 Test (org.junit.Test)18 ResourceCalculator (org.apache.hadoop.yarn.util.resource.ResourceCalculator)11 RMContext (org.apache.hadoop.yarn.server.resourcemanager.RMContext)7 TreeMap (java.util.TreeMap)6 Before (org.junit.Before)6 Entry (java.util.Map.Entry)5 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)4 QueueMetrics (org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueMetrics)4 ReservationId (org.apache.hadoop.yarn.api.records.ReservationId)3 Clock (org.apache.hadoop.yarn.util.Clock)3 Random (java.util.Random)2 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)2 ReservationDefinition (org.apache.hadoop.yarn.api.records.ReservationDefinition)2 RMNodeLabelsManager (org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager)2 InMemoryReservationAllocation (org.apache.hadoop.yarn.server.resourcemanager.reservation.InMemoryReservationAllocation)2 ReservationAllocation (org.apache.hadoop.yarn.server.resourcemanager.reservation.ReservationAllocation)2 ReservationAgent (org.apache.hadoop.yarn.server.resourcemanager.reservation.planning.ReservationAgent)2 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)2