Search in sources :

Example 31 with ResourceManager

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

the class TestRMWebApp method testView.

@Test
public void testView() {
    Injector injector = WebAppTests.createMockInjector(RMContext.class, mockRMContext(15, 1, 2, 8 * GiB), new Module() {

        @Override
        public void configure(Binder binder) {
            try {
                ResourceManager mockRm = mockRm(3, 1, 2, 8 * GiB);
                binder.bind(ResourceManager.class).toInstance(mockRm);
                binder.bind(ApplicationBaseProtocol.class).toInstance(mockRm.getClientRMService());
            } catch (IOException e) {
                throw new IllegalStateException(e);
            }
        }
    });
    RmView rmViewInstance = injector.getInstance(RmView.class);
    rmViewInstance.set(YarnWebParams.APP_STATE, YarnApplicationState.RUNNING.toString());
    rmViewInstance.render();
    WebAppTests.flushOutput(injector);
    rmViewInstance.set(YarnWebParams.APP_STATE, StringHelper.cjoin(YarnApplicationState.ACCEPTED.toString(), YarnApplicationState.RUNNING.toString()));
    rmViewInstance.render();
    WebAppTests.flushOutput(injector);
    Map<String, String> moreParams = rmViewInstance.context().requestContext().moreParams();
    String appsTableColumnsMeta = moreParams.get("ui.dataTables.apps.init");
    Assert.assertTrue(appsTableColumnsMeta.indexOf("natural") != -1);
}
Also used : Binder(com.google.inject.Binder) Injector(com.google.inject.Injector) ResourceManager(org.apache.hadoop.yarn.server.resourcemanager.ResourceManager) IOException(java.io.IOException) Module(com.google.inject.Module) Test(org.junit.Test)

Example 32 with ResourceManager

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

the class TestRMWebApp method mockRm.

public static ResourceManager mockRm(RMContext rmContext) throws IOException {
    ResourceManager rm = mock(ResourceManager.class);
    ResourceScheduler rs = mockCapacityScheduler();
    ApplicationACLsManager aclMgr = mockAppACLsManager();
    ClientRMService clientRMService = mockClientRMService(rmContext);
    when(rm.getResourceScheduler()).thenReturn(rs);
    when(rm.getRMContext()).thenReturn(rmContext);
    when(rm.getApplicationACLsManager()).thenReturn(aclMgr);
    when(rm.getClientRMService()).thenReturn(clientRMService);
    return rm;
}
Also used : ApplicationACLsManager(org.apache.hadoop.yarn.server.security.ApplicationACLsManager) ResourceScheduler(org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler) ResourceManager(org.apache.hadoop.yarn.server.resourcemanager.ResourceManager) ClientRMService(org.apache.hadoop.yarn.server.resourcemanager.ClientRMService)

Example 33 with ResourceManager

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

the class TestRMWebServices method testDumpingSchedulerLogs.

@Test
public void testDumpingSchedulerLogs() throws Exception {
    ResourceManager mockRM = mock(ResourceManager.class);
    Configuration conf = new YarnConfiguration();
    HttpServletRequest mockHsr = mock(HttpServletRequest.class);
    ApplicationACLsManager aclsManager = new ApplicationACLsManager(conf);
    when(mockRM.getApplicationACLsManager()).thenReturn(aclsManager);
    RMWebServices webSvc = new RMWebServices(mockRM, conf, mock(HttpServletResponse.class));
    // nothing should happen
    webSvc.dumpSchedulerLogs("1", mockHsr);
    waitforLogDump(50);
    checkSchedulerLogFileAndCleanup();
    conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true);
    conf.setStrings(YarnConfiguration.YARN_ADMIN_ACL, "admin");
    aclsManager = new ApplicationACLsManager(conf);
    when(mockRM.getApplicationACLsManager()).thenReturn(aclsManager);
    webSvc = new RMWebServices(mockRM, conf, mock(HttpServletResponse.class));
    boolean exceptionThrown = false;
    try {
        webSvc.dumpSchedulerLogs("1", mockHsr);
        fail("Dumping logs should fail");
    } catch (ForbiddenException ae) {
        exceptionThrown = true;
    }
    assertTrue("ForbiddenException expected", exceptionThrown);
    exceptionThrown = false;
    when(mockHsr.getUserPrincipal()).thenReturn(new Principal() {

        @Override
        public String getName() {
            return "testuser";
        }
    });
    try {
        webSvc.dumpSchedulerLogs("1", mockHsr);
        fail("Dumping logs should fail");
    } catch (ForbiddenException ae) {
        exceptionThrown = true;
    }
    assertTrue("ForbiddenException expected", exceptionThrown);
    when(mockHsr.getUserPrincipal()).thenReturn(new Principal() {

        @Override
        public String getName() {
            return "admin";
        }
    });
    webSvc.dumpSchedulerLogs("1", mockHsr);
    waitforLogDump(50);
    checkSchedulerLogFileAndCleanup();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ApplicationACLsManager(org.apache.hadoop.yarn.server.security.ApplicationACLsManager) ForbiddenException(org.apache.hadoop.yarn.webapp.ForbiddenException) Configuration(org.apache.hadoop.conf.Configuration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) HttpServletResponse(javax.servlet.http.HttpServletResponse) ResourceManager(org.apache.hadoop.yarn.server.resourcemanager.ResourceManager) Principal(java.security.Principal) Test(org.junit.Test)

Example 34 with ResourceManager

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

the class TestAMSimulator method setup.

@Before
public void setup() {
    conf = new YarnConfiguration();
    conf.set(YarnConfiguration.RM_SCHEDULER, "org.apache.hadoop.yarn.sls.scheduler.ResourceSchedulerWrapper");
    conf.set(SLSConfiguration.RM_SCHEDULER, "org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler");
    conf.setBoolean(SLSConfiguration.METRICS_SWITCH, false);
    rm = new ResourceManager();
    rm.init(conf);
    rm.start();
}
Also used : YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) ResourceManager(org.apache.hadoop.yarn.server.resourcemanager.ResourceManager) Before(org.junit.Before)

Example 35 with ResourceManager

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

the class TestNMSimulator method setup.

@Before
public void setup() {
    conf = new YarnConfiguration();
    conf.set(YarnConfiguration.RM_SCHEDULER, "org.apache.hadoop.yarn.sls.scheduler.ResourceSchedulerWrapper");
    conf.set(SLSConfiguration.RM_SCHEDULER, "org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler");
    conf.setBoolean(SLSConfiguration.METRICS_SWITCH, false);
    rm = new ResourceManager();
    rm.init(conf);
    rm.start();
}
Also used : YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) ResourceManager(org.apache.hadoop.yarn.server.resourcemanager.ResourceManager) Before(org.junit.Before)

Aggregations

ResourceManager (org.apache.hadoop.yarn.server.resourcemanager.ResourceManager)36 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)18 Test (org.junit.Test)17 Configuration (org.apache.hadoop.conf.Configuration)10 RMContext (org.apache.hadoop.yarn.server.resourcemanager.RMContext)10 IOException (java.io.IOException)7 ResourceScheduler (org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler)6 Binder (com.google.inject.Binder)5 Injector (com.google.inject.Injector)5 Module (com.google.inject.Module)5 RMNodeLabelsManager (org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager)5 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)4 AsyncDispatcher (org.apache.hadoop.yarn.event.AsyncDispatcher)4 ClientRMService (org.apache.hadoop.yarn.server.resourcemanager.ClientRMService)4 MockRM (org.apache.hadoop.yarn.server.resourcemanager.MockRM)4 Service (org.apache.hadoop.service.Service)3 Before (org.junit.Before)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2