Search in sources :

Example 56 with ReservationDefinition

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

the class TestInMemoryReservationAllocation method testSteps.

@Test
public void testSteps() {
    ReservationId reservationID = ReservationId.newInstance(rand.nextLong(), rand.nextLong());
    int[] alloc = { 10, 10, 10, 10, 10, 10 };
    int start = 100;
    ReservationDefinition rDef = ReservationSystemTestUtil.createSimpleReservationDefinition(start, start + alloc.length + 1, alloc.length);
    Map<ReservationInterval, Resource> allocations = generateAllocation(start, alloc, true, false);
    ReservationAllocation rAllocation = new InMemoryReservationAllocation(reservationID, rDef, user, planName, start, start + alloc.length + 1, allocations, resCalc, minAlloc);
    doAssertions(rAllocation, reservationID, rDef, allocations, start, alloc);
    Assert.assertFalse(rAllocation.containsGangs());
    for (int i = 0; i < alloc.length; i++) {
        Assert.assertEquals(Resource.newInstance(1024 * (alloc[i] + i), (alloc[i] + i)), rAllocation.getResourcesAtTime(start + i));
    }
}
Also used : ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) Resource(org.apache.hadoop.yarn.api.records.Resource) Test(org.junit.Test)

Example 57 with ReservationDefinition

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

the class TestNoOverCommitPolicy method testMultiTenantFail.

@Test(expected = ResourceOverCommitException.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 58 with ReservationDefinition

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

the class TestNoOverCommitPolicy method testSingleUserEasyFitPass.

@Test
public void testSingleUserEasyFitPass() throws IOException, PlanningException {
    // generate allocation that easily fit within resource constraints
    int[] f = generateData(3600, (int) Math.ceil(0.2 * 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 59 with ReservationDefinition

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

the class TestSchedulerPlanFollowerBase method testPlanFollower.

protected void testPlanFollower(boolean isMove) throws PlanningException, InterruptedException, AccessControlException {
    // Initialize plan based on move flag
    plan = new InMemoryPlan(scheduler.getRootQueueMetrics(), policy, mAgent, scheduler.getClusterResource(), 1L, res, scheduler.getMinimumResourceCapability(), maxAlloc, "dedicated", null, isMove, context);
    // add a few reservations to the plan
    long ts = System.currentTimeMillis();
    ReservationId r1 = ReservationId.newInstance(ts, 1);
    int[] f1 = { 10, 10, 10, 10, 10 };
    ReservationDefinition rDef = ReservationSystemTestUtil.createSimpleReservationDefinition(0, 0 + f1.length + 1, f1.length);
    assertTrue(plan.toString(), plan.addReservation(new InMemoryReservationAllocation(r1, rDef, "u3", "dedicated", 0, 0 + f1.length, ReservationSystemTestUtil.generateAllocation(0L, 1L, f1), res, minAlloc), false));
    ReservationId r2 = ReservationId.newInstance(ts, 2);
    assertTrue(plan.toString(), plan.addReservation(new InMemoryReservationAllocation(r2, rDef, "u3", "dedicated", 3, 3 + f1.length, ReservationSystemTestUtil.generateAllocation(3L, 1L, f1), res, minAlloc), false));
    ReservationId r3 = ReservationId.newInstance(ts, 3);
    int[] f2 = { 0, 10, 20, 10, 0 };
    assertTrue(plan.toString(), plan.addReservation(new InMemoryReservationAllocation(r3, rDef, "u4", "dedicated", 10, 10 + f2.length, ReservationSystemTestUtil.generateAllocation(10L, 1L, f2), res, minAlloc), false));
    AbstractSchedulerPlanFollower planFollower = createPlanFollower();
    when(mClock.getTime()).thenReturn(0L);
    planFollower.run();
    Queue q = getReservationQueue(r1.toString());
    assertReservationQueueExists(r1);
    // submit an app to r1
    String user_0 = "test-user";
    ApplicationId appId = ApplicationId.newInstance(0, 1);
    ApplicationAttemptId appAttemptId_0 = ApplicationAttemptId.newInstance(appId, 0);
    AppAddedSchedulerEvent addAppEvent = new AppAddedSchedulerEvent(appId, q.getQueueName(), user_0);
    scheduler.handle(addAppEvent);
    AppAttemptAddedSchedulerEvent appAttemptAddedEvent = new AppAttemptAddedSchedulerEvent(appAttemptId_0, false);
    scheduler.handle(appAttemptAddedEvent);
    // initial default reservation queue should have no apps
    Queue defQ = getDefaultQueue();
    Assert.assertEquals(0, getNumberOfApplications(defQ));
    assertReservationQueueExists(r1, 0.1, 0.1);
    Assert.assertEquals(1, getNumberOfApplications(q));
    assertReservationQueueDoesNotExist(r2);
    assertReservationQueueDoesNotExist(r3);
    when(mClock.getTime()).thenReturn(3L);
    planFollower.run();
    Assert.assertEquals(0, getNumberOfApplications(defQ));
    assertReservationQueueExists(r1, 0.1, 0.1);
    Assert.assertEquals(1, getNumberOfApplications(q));
    assertReservationQueueExists(r2, 0.1, 0.1);
    assertReservationQueueDoesNotExist(r3);
    when(mClock.getTime()).thenReturn(10L);
    planFollower.run();
    q = getReservationQueue(r1.toString());
    if (isMove) {
        // app should have been moved to default reservation queue
        Assert.assertEquals(1, getNumberOfApplications(defQ));
        assertNull(q);
    } else {
        // app should be killed
        Assert.assertEquals(0, getNumberOfApplications(defQ));
        assertNotNull(q);
        AppAttemptRemovedSchedulerEvent appAttemptRemovedEvent = new AppAttemptRemovedSchedulerEvent(appAttemptId_0, RMAppAttemptState.KILLED, false);
        scheduler.handle(appAttemptRemovedEvent);
    }
    assertReservationQueueDoesNotExist(r2);
    assertReservationQueueExists(r3, 0, 1.0);
    when(mClock.getTime()).thenReturn(11L);
    planFollower.run();
    if (isMove) {
        // app should have been moved to default reservation queue
        Assert.assertEquals(1, getNumberOfApplications(defQ));
    } else {
        // app should be killed
        Assert.assertEquals(0, getNumberOfApplications(defQ));
    }
    assertReservationQueueDoesNotExist(r1);
    assertReservationQueueDoesNotExist(r2);
    assertReservationQueueExists(r3, 0.1, 0.1);
    when(mClock.getTime()).thenReturn(12L);
    planFollower.run();
    assertReservationQueueDoesNotExist(r1);
    assertReservationQueueDoesNotExist(r2);
    assertReservationQueueExists(r3, 0.2, 0.2);
    when(mClock.getTime()).thenReturn(16L);
    planFollower.run();
    assertReservationQueueDoesNotExist(r1);
    assertReservationQueueDoesNotExist(r2);
    assertReservationQueueDoesNotExist(r3);
    verifyCapacity(defQ);
}
Also used : AppAddedSchedulerEvent(org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppAddedSchedulerEvent) ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId) ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) AppAttemptRemovedSchedulerEvent(org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppAttemptRemovedSchedulerEvent) AppAttemptAddedSchedulerEvent(org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppAttemptAddedSchedulerEvent) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) Queue(org.apache.hadoop.yarn.server.resourcemanager.scheduler.Queue)

Example 60 with ReservationDefinition

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

the class TestAlignedPlanner method testImpossibleDuration.

@Test
public void testImpossibleDuration() throws PlanningException {
    // Create reservation
    ReservationDefinition rr1 = createReservationDefinition(// Job arrival time
    10 * step, // Job deadline
    15 * step, new ReservationRequest[] { ReservationRequest.newInstance(// Capability
    Resource.newInstance(1024, 1), // Num containers
    20, // Concurrency
    20, // Duration
    10 * step) }, ReservationRequestInterpreter.R_ALL, "u1");
    // Add reservation
    try {
        ReservationId reservationID = ReservationSystemTestUtil.getNewReservationId();
        agent.createReservation(reservationID, "u1", plan, rr1);
        fail();
    } catch (PlanningException e) {
    // Expected failure
    }
    // CHECK: allocation was not accepted
    assertTrue("Agent-based allocation should have failed", plan.getAllReservations().size() == 0);
}
Also used : ReservationId(org.apache.hadoop.yarn.api.records.ReservationId) ReservationDefinition(org.apache.hadoop.yarn.api.records.ReservationDefinition) PlanningException(org.apache.hadoop.yarn.server.resourcemanager.reservation.exceptions.PlanningException) 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