Search in sources :

Example 46 with ReservationDefinition

use of org.apache.hadoop.yarn.api.records.ReservationDefinition in project hadoop by apache.

the class TestCapacityOverTimePolicy method testInstFail.

@Test(expected = PlanningQuotaException.class)
public void testInstFail() throws IOException, PlanningException {
    // generate allocation that exceed the instantaneous cap single-show
    int[] f = generateData(3600, (int) Math.ceil(0.71 * totCont));
    ReservationDefinition rDef = ReservationSystemTestUtil.createSimpleReservationDefinition(initTime, initTime + f.length + 1, f.length);
    assertTrue(plan.toString(), plan.addReservation(new InMemoryReservationAllocation(ReservationSystemTestUtil.getNewReservationId(), rDef, "u1", "dedicated", initTime, initTime + f.length, ReservationSystemTestUtil.generateAllocation(initTime, step, f), res, minAlloc), false));
    Assert.fail("should not have accepted this");
}
Also used : ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) Test(org.junit.Test)

Example 47 with ReservationDefinition

use of org.apache.hadoop.yarn.api.records.ReservationDefinition in project hadoop by apache.

the class TestCapacityOverTimePolicy method testMultiTenantFail.

@Test(expected = PlanningQuotaException.class)
public void testMultiTenantFail() throws IOException, PlanningException {
    // generate allocation from multiple tenants that exceed tot capacity
    int[] f = generateData(3600, (int) Math.ceil(0.25 * totCont));
    ReservationDefinition rDef = ReservationSystemTestUtil.createSimpleReservationDefinition(initTime, initTime + f.length + 1, f.length);
    for (int i = 0; i < 5; i++) {
        assertTrue(plan.toString(), plan.addReservation(new InMemoryReservationAllocation(ReservationSystemTestUtil.getNewReservationId(), rDef, "u" + i, "dedicated", initTime, initTime + f.length, ReservationSystemTestUtil.generateAllocation(initTime, step, f), res, minAlloc), false));
    }
}
Also used : ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) Test(org.junit.Test)

Example 48 with ReservationDefinition

use of org.apache.hadoop.yarn.api.records.ReservationDefinition in project hadoop by apache.

the class TestCapacityOverTimePolicy method testSimplePass2.

@Test
public void testSimplePass2() throws IOException, PlanningException {
    // generate allocation from single tenant that exceed avg momentarily but
    // fit within
    // max instantanesou
    int[] f = generateData(3600, (int) Math.ceil(0.69 * totCont));
    ReservationDefinition rDef = ReservationSystemTestUtil.createSimpleReservationDefinition(initTime, initTime + f.length + 1, f.length);
    assertTrue(plan.toString(), plan.addReservation(new InMemoryReservationAllocation(ReservationSystemTestUtil.getNewReservationId(), rDef, "u1", "dedicated", initTime, initTime + f.length, ReservationSystemTestUtil.generateAllocation(initTime, step, f), res, minAlloc), false));
}
Also used : ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) Test(org.junit.Test)

Example 49 with ReservationDefinition

use of org.apache.hadoop.yarn.api.records.ReservationDefinition in project hadoop by apache.

the class TestCapacityOverTimePolicy method testFailAvg.

@Test(expected = PlanningQuotaException.class)
public void testFailAvg() throws IOException, PlanningException {
    // generate an allocation which violates the 25% average single-shot
    Map<ReservationInterval, Resource> req = new TreeMap<ReservationInterval, Resource>();
    long win = timeWindow / 2 + 100;
    int cont = (int) Math.ceil(0.5 * totCont);
    req.put(new ReservationInterval(initTime, initTime + win), ReservationSystemUtil.toResource(ReservationRequest.newInstance(Resource.newInstance(1024, 1), cont)));
    ReservationDefinition rDef = ReservationSystemTestUtil.createSimpleReservationDefinition(initTime, initTime + win, win);
    assertTrue(plan.toString(), plan.addReservation(new InMemoryReservationAllocation(ReservationSystemTestUtil.getNewReservationId(), rDef, "u1", "dedicated", initTime, initTime + win, req, res, minAlloc), false));
}
Also used : ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) Resource(org.apache.hadoop.yarn.api.records.Resource) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Example 50 with ReservationDefinition

use of org.apache.hadoop.yarn.api.records.ReservationDefinition in project hadoop by apache.

the class TestCapacityOverTimePolicy method testFailAvgBySum.

@Test
public void testFailAvgBySum() throws IOException, PlanningException {
    // generate an allocation which violates the 25% average by sum
    Map<ReservationInterval, Resource> req = new TreeMap<ReservationInterval, Resource>();
    long win = 86400000 / 4 + 1;
    int cont = (int) Math.ceil(0.5 * totCont);
    req.put(new ReservationInterval(initTime, initTime + win), ReservationSystemUtil.toResource(ReservationRequest.newInstance(Resource.newInstance(1024, 1), cont)));
    ReservationDefinition rDef = ReservationSystemTestUtil.createSimpleReservationDefinition(initTime, initTime + win, win);
    assertTrue(plan.toString(), plan.addReservation(new InMemoryReservationAllocation(ReservationSystemTestUtil.getNewReservationId(), rDef, "u1", "dedicated", initTime, initTime + win, req, res, minAlloc), false));
    try {
        assertTrue(plan.toString(), plan.addReservation(new InMemoryReservationAllocation(ReservationSystemTestUtil.getNewReservationId(), null, "u1", "dedicated", initTime, initTime + win, req, res, minAlloc), false));
        Assert.fail("should not have accepted this");
    } catch (PlanningQuotaException e) {
    // expected
    }
}
Also used : PlanningQuotaException(org.apache.hadoop.yarn.server.resourcemanager.reservation.exceptions.PlanningQuotaException) ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) Resource(org.apache.hadoop.yarn.api.records.Resource) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Aggregations

ReservationDefinition (org.apache.hadoop.yarn.api.records.ReservationDefinition)70 Test (org.junit.Test)52 ReservationId (org.apache.hadoop.yarn.api.records.ReservationId)40 ReservationRequest (org.apache.hadoop.yarn.api.records.ReservationRequest)23 ReservationRequests (org.apache.hadoop.yarn.api.records.ReservationRequests)19 InMemoryReservationAllocation (org.apache.hadoop.yarn.server.resourcemanager.reservation.InMemoryReservationAllocation)19 Resource (org.apache.hadoop.yarn.api.records.Resource)17 ReservationAllocation (org.apache.hadoop.yarn.server.resourcemanager.reservation.ReservationAllocation)16 ReservationDefinitionPBImpl (org.apache.hadoop.yarn.api.records.impl.pb.ReservationDefinitionPBImpl)15 ReservationRequestsPBImpl (org.apache.hadoop.yarn.api.records.impl.pb.ReservationRequestsPBImpl)15 ReservationSubmissionRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest)14 ArrayList (java.util.ArrayList)12 PlanningException (org.apache.hadoop.yarn.server.resourcemanager.reservation.exceptions.PlanningException)12 ReservationUpdateRequest (org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateRequest)7 ReservationSubmissionResponse (org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionResponse)6 Plan (org.apache.hadoop.yarn.server.resourcemanager.reservation.Plan)5 Clock (org.apache.hadoop.yarn.util.Clock)5 ReservationUpdateResponse (org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateResponse)4 IOException (java.io.IOException)3 GetNewReservationRequest (org.apache.hadoop.yarn.api.protocolrecords.GetNewReservationRequest)3