Search in sources :

Example 1 with PlacementManager

use of org.apache.hadoop.yarn.server.resourcemanager.placement.PlacementManager in project hadoop by apache.

the class TestAppManager method testRMAppSubmitWithQueueChanged.

@Test
public void testRMAppSubmitWithQueueChanged() throws Exception {
    // Setup a PlacementManager returns a new queue
    PlacementManager placementMgr = mock(PlacementManager.class);
    doAnswer(new Answer<Void>() {

        @Override
        public Void answer(InvocationOnMock invocation) throws Throwable {
            ApplicationSubmissionContext ctx = (ApplicationSubmissionContext) invocation.getArguments()[0];
            ctx.setQueue("newQueue");
            return null;
        }
    }).when(placementMgr).placeApplication(any(ApplicationSubmissionContext.class), any(String.class));
    rmContext.setQueuePlacementManager(placementMgr);
    asContext.setQueue("oldQueue");
    appMonitor.submitApplication(asContext, "test");
    RMApp app = rmContext.getRMApps().get(appId);
    Assert.assertNotNull("app is null", app);
    Assert.assertEquals("newQueue", asContext.getQueue());
    // wait for event to be processed
    int timeoutSecs = 0;
    while ((getAppEventType() == RMAppEventType.KILL) && timeoutSecs++ < 20) {
        Thread.sleep(1000);
    }
    Assert.assertEquals("app event type sent is wrong", RMAppEventType.START, getAppEventType());
}
Also used : RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) MockRMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.MockRMApp) PlacementManager(org.apache.hadoop.yarn.server.resourcemanager.placement.PlacementManager) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ApplicationSubmissionContext(org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext) Test(org.junit.Test)

Aggregations

ApplicationSubmissionContext (org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext)1 PlacementManager (org.apache.hadoop.yarn.server.resourcemanager.placement.PlacementManager)1 MockRMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.MockRMApp)1 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)1 Test (org.junit.Test)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1