Search in sources :

Example 1 with MockRMApp

use of org.apache.hadoop.yarn.server.resourcemanager.rmapp.MockRMApp in project hadoop by apache.

the class TestFairScheduler method testFairShareAndWeightsInNestedUserQueueRule.

@Test
public void testFairShareAndWeightsInNestedUserQueueRule() throws Exception {
    conf.set(FairSchedulerConfiguration.ALLOCATION_FILE, ALLOC_FILE);
    PrintWriter out = new PrintWriter(new FileWriter(ALLOC_FILE));
    out.println("<?xml version=\"1.0\"?>");
    out.println("<allocations>");
    out.println("<queue name=\"parentq\" type=\"parent\">");
    out.println("<minResources>1024mb,0vcores</minResources>");
    out.println("</queue>");
    out.println("<queuePlacementPolicy>");
    out.println("<rule name=\"nestedUserQueue\">");
    out.println("     <rule name=\"specified\" create=\"false\" />");
    out.println("</rule>");
    out.println("<rule name=\"default\" />");
    out.println("</queuePlacementPolicy>");
    out.println("</allocations>");
    out.close();
    RMApp rmApp1 = new MockRMApp(0, 0, RMAppState.NEW);
    RMApp rmApp2 = new MockRMApp(1, 1, RMAppState.NEW);
    scheduler.init(conf);
    scheduler.start();
    scheduler.reinitialize(conf, resourceManager.getRMContext());
    int capacity = 16 * 1024;
    // create node with 16 G
    RMNode node1 = MockNodes.newNodeInfo(1, Resources.createResource(capacity), 1, "127.0.0.1");
    NodeAddedSchedulerEvent nodeEvent1 = new NodeAddedSchedulerEvent(node1);
    scheduler.handle(nodeEvent1);
    // user1,user2 submit their apps to parentq and create user queues
    createSchedulingRequest(10 * 1024, "root.parentq", "user1");
    createSchedulingRequest(10 * 1024, "root.parentq", "user2");
    // user3 submits app in default queue
    createSchedulingRequest(10 * 1024, "root.default", "user3");
    scheduler.update();
    scheduler.getQueueManager().getRootQueue().setSteadyFairShare(scheduler.getClusterResource());
    scheduler.getQueueManager().getRootQueue().recomputeSteadyShares();
    Collection<FSLeafQueue> leafQueues = scheduler.getQueueManager().getLeafQueues();
    for (FSLeafQueue leaf : leafQueues) {
        if (leaf.getName().equals("root.parentq.user1") || leaf.getName().equals("root.parentq.user2")) {
            // assert that the fair share is 1/4th node1's capacity
            assertEquals(capacity / 4, leaf.getFairShare().getMemorySize());
            // assert that the steady fair share is 1/4th node1's capacity
            assertEquals(capacity / 4, leaf.getSteadyFairShare().getMemorySize());
            // assert weights are equal for both the user queues
            assertEquals(1.0, leaf.getWeights().getWeight(ResourceType.MEMORY), 0);
        }
    }
}
Also used : MockRMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.MockRMApp) RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) MockRMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.MockRMApp) RMNode(org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode) NodeAddedSchedulerEvent(org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeAddedSchedulerEvent) FileWriter(java.io.FileWriter) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 2 with MockRMApp

use of org.apache.hadoop.yarn.server.resourcemanager.rmapp.MockRMApp in project hadoop by apache.

the class TestAppManager method testRMAppRetireSomeDifferentStates.

@Test
public void testRMAppRetireSomeDifferentStates() throws Exception {
    long now = System.currentTimeMillis();
    // these parameters don't matter, override applications below
    RMContext rmContext = mockRMContext(10, now - 20000);
    Configuration conf = new YarnConfiguration();
    conf.setInt(YarnConfiguration.RM_STATE_STORE_MAX_COMPLETED_APPLICATIONS, 2);
    conf.setInt(YarnConfiguration.RM_MAX_COMPLETED_APPLICATIONS, 2);
    TestRMAppManager appMonitor = new TestRMAppManager(rmContext, conf);
    // clear out applications map
    rmContext.getRMApps().clear();
    Assert.assertEquals("map isn't empty", 0, rmContext.getRMApps().size());
    // 6 applications are in final state, 4 are not in final state.
    // / set with various finished states
    RMApp app = new MockRMApp(0, now - 20000, RMAppState.KILLED);
    rmContext.getRMApps().put(app.getApplicationId(), app);
    app = new MockRMApp(1, now - 200000, RMAppState.FAILED);
    rmContext.getRMApps().put(app.getApplicationId(), app);
    app = new MockRMApp(2, now - 30000, RMAppState.FINISHED);
    rmContext.getRMApps().put(app.getApplicationId(), app);
    app = new MockRMApp(3, now - 20000, RMAppState.RUNNING);
    rmContext.getRMApps().put(app.getApplicationId(), app);
    app = new MockRMApp(4, now - 20000, RMAppState.NEW);
    rmContext.getRMApps().put(app.getApplicationId(), app);
    // make sure it doesn't expire these since still running
    app = new MockRMApp(5, now - 10001, RMAppState.KILLED);
    rmContext.getRMApps().put(app.getApplicationId(), app);
    app = new MockRMApp(6, now - 30000, RMAppState.ACCEPTED);
    rmContext.getRMApps().put(app.getApplicationId(), app);
    app = new MockRMApp(7, now - 20000, RMAppState.SUBMITTED);
    rmContext.getRMApps().put(app.getApplicationId(), app);
    app = new MockRMApp(8, now - 10001, RMAppState.FAILED);
    rmContext.getRMApps().put(app.getApplicationId(), app);
    app = new MockRMApp(9, now - 20000, RMAppState.FAILED);
    rmContext.getRMApps().put(app.getApplicationId(), app);
    Assert.assertEquals("Number of apps incorrect before", 10, rmContext.getRMApps().size());
    // add them to completed apps list
    addToCompletedApps(appMonitor, rmContext);
    // shouldn't  have to many apps
    appMonitor.checkAppNumCompletedLimit();
    Assert.assertEquals("Number of apps incorrect after # completed check", 6, rmContext.getRMApps().size());
    Assert.assertEquals("Number of completed apps incorrect after check", 2, appMonitor.getCompletedAppsListSize());
    // 6 applications in final state, 4 of them are removed
    verify(rmContext.getStateStore(), times(4)).removeApplication(isA(RMApp.class));
}
Also used : RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) MockRMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.MockRMApp) MockRMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.MockRMApp) Configuration(org.apache.hadoop.conf.Configuration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Test(org.junit.Test)

Example 3 with MockRMApp

use of org.apache.hadoop.yarn.server.resourcemanager.rmapp.MockRMApp in project hadoop by apache.

the class TestFairScheduler method testAssignToBadDefaultQueue.

@Test
public void testAssignToBadDefaultQueue() throws Exception {
    conf.set(FairSchedulerConfiguration.ALLOCATION_FILE, ALLOC_FILE);
    PrintWriter out = new PrintWriter(new FileWriter(ALLOC_FILE));
    out.println("<?xml version=\"1.0\"?>");
    out.println("<allocations>");
    out.println("<queuePlacementPolicy>");
    out.println("<rule name=\"specified\" create=\"false\" />");
    out.println("<rule name=\"default\" create=\"false\" />");
    out.println("</queuePlacementPolicy>");
    out.println("</allocations>");
    out.close();
    scheduler.init(conf);
    scheduler.start();
    scheduler.reinitialize(conf, resourceManager.getRMContext());
    RMApp rmApp1 = new MockRMApp(0, 0, RMAppState.NEW);
    try {
        FSLeafQueue queue1 = scheduler.assignToQueue(rmApp1, "default", "asterix");
    } catch (IllegalStateException ise) {
        fail("Bad queue placement policy terminal rule should not throw " + "exception ");
    }
}
Also used : MockRMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.MockRMApp) RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) MockRMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.MockRMApp) FileWriter(java.io.FileWriter) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 4 with MockRMApp

use of org.apache.hadoop.yarn.server.resourcemanager.rmapp.MockRMApp in project hadoop by apache.

the class TestFairScheduler method testAssignToQueue.

@Test
public void testAssignToQueue() throws Exception {
    conf.set(FairSchedulerConfiguration.USER_AS_DEFAULT_QUEUE, "true");
    scheduler.init(conf);
    scheduler.start();
    scheduler.reinitialize(conf, resourceManager.getRMContext());
    RMApp rmApp1 = new MockRMApp(0, 0, RMAppState.NEW);
    RMApp rmApp2 = new MockRMApp(1, 1, RMAppState.NEW);
    FSLeafQueue queue1 = scheduler.assignToQueue(rmApp1, "default", "asterix");
    FSLeafQueue queue2 = scheduler.assignToQueue(rmApp2, "notdefault", "obelix");
    // assert FSLeafQueue's name is the correct name is the one set in the RMApp
    assertEquals(rmApp1.getQueue(), queue1.getName());
    assertEquals("root.asterix", rmApp1.getQueue());
    assertEquals(rmApp2.getQueue(), queue2.getName());
    assertEquals("root.notdefault", rmApp2.getQueue());
}
Also used : MockRMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.MockRMApp) RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) MockRMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.MockRMApp) Test(org.junit.Test)

Example 5 with MockRMApp

use of org.apache.hadoop.yarn.server.resourcemanager.rmapp.MockRMApp in project hadoop by apache.

the class TestFairScheduler method testAssignToNonLeafQueueReturnsNull.

@Test
public void testAssignToNonLeafQueueReturnsNull() throws Exception {
    conf.set(FairSchedulerConfiguration.USER_AS_DEFAULT_QUEUE, "true");
    scheduler.init(conf);
    scheduler.start();
    scheduler.reinitialize(conf, resourceManager.getRMContext());
    scheduler.getQueueManager().getLeafQueue("root.child1.granchild", true);
    scheduler.getQueueManager().getLeafQueue("root.child2", true);
    RMApp rmApp1 = new MockRMApp(0, 0, RMAppState.NEW);
    RMApp rmApp2 = new MockRMApp(1, 1, RMAppState.NEW);
    // Trying to assign to non leaf queue would return null
    assertNull(scheduler.assignToQueue(rmApp1, "root.child1", "tintin"));
    assertNotNull(scheduler.assignToQueue(rmApp2, "root.child2", "snowy"));
}
Also used : MockRMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.MockRMApp) RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) MockRMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.MockRMApp) Test(org.junit.Test)

Aggregations

MockRMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.MockRMApp)9 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)8 Test (org.junit.Test)7 FileWriter (java.io.FileWriter)3 PrintWriter (java.io.PrintWriter)3 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)2 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)2 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Configuration (org.apache.hadoop.conf.Configuration)1 DataInputBuffer (org.apache.hadoop.io.DataInputBuffer)1 InvalidToken (org.apache.hadoop.security.token.SecretManager.InvalidToken)1 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)1 NodeId (org.apache.hadoop.yarn.api.records.NodeId)1 Resource (org.apache.hadoop.yarn.api.records.Resource)1 Token (org.apache.hadoop.yarn.api.records.Token)1 YarnRPC (org.apache.hadoop.yarn.ipc.YarnRPC)1 ContainerTokenIdentifier (org.apache.hadoop.yarn.security.ContainerTokenIdentifier)1 NMTokenIdentifier (org.apache.hadoop.yarn.security.NMTokenIdentifier)1