Search in sources :

Example 11 with ResourceManager

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

the class TestMiniYarnClusterNodeUtilization method verifySimulatedUtilization.

/**
   * Verify both the RMNode and SchedulerNode have been updated with the test
   * fixture utilization data.
   */
private void verifySimulatedUtilization() throws InterruptedException {
    ResourceManager rm = cluster.getResourceManager(0);
    RMContext rmContext = rm.getRMContext();
    ResourceUtilization containersUtilization = nodeStatus.getContainersUtilization();
    ResourceUtilization nodeUtilization = nodeStatus.getNodeUtilization();
    // We check if the nodeUtilization is up to date
    for (int i = 0; i < 100; i++) {
        for (RMNode ni : rmContext.getRMNodes().values()) {
            if (ni.getNodeUtilization() != null) {
                if (ni.getNodeUtilization().equals(nodeUtilization)) {
                    break;
                }
            }
        }
        Thread.sleep(100);
    }
    // Verify the data is readable from the RM and scheduler nodes
    for (RMNode ni : rmContext.getRMNodes().values()) {
        ResourceUtilization cu = ni.getAggregatedContainersUtilization();
        assertEquals("Containers Utillization not propagated to RMNode", containersUtilization, cu);
        ResourceUtilization nu = ni.getNodeUtilization();
        assertEquals("Node Utillization not propagated to RMNode", nodeUtilization, nu);
        SchedulerNode scheduler = rmContext.getScheduler().getSchedulerNode(ni.getNodeID());
        cu = scheduler.getAggregatedContainersUtilization();
        assertEquals("Containers Utillization not propagated to SchedulerNode", containersUtilization, cu);
        nu = scheduler.getNodeUtilization();
        assertEquals("Node Utillization not propagated to SchedulerNode", nodeUtilization, nu);
    }
}
Also used : RMContext(org.apache.hadoop.yarn.server.resourcemanager.RMContext) RMNode(org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode) SchedulerNode(org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerNode) ResourceUtilization(org.apache.hadoop.yarn.api.records.ResourceUtilization) ResourceManager(org.apache.hadoop.yarn.server.resourcemanager.ResourceManager)

Example 12 with ResourceManager

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

the class TestAbstractYarnScheduler method getPrivateResourceTrackerService.

private ResourceTrackerService getPrivateResourceTrackerService(Dispatcher privateDispatcher, ResourceManager rm, SleepHandler sleepHandler) {
    Configuration conf = getConf();
    RMContext privateContext = new RMContextImpl(privateDispatcher, null, null, null, null, null, null, null, null, null);
    privateContext.setNodeLabelManager(Mockito.mock(RMNodeLabelsManager.class));
    privateDispatcher.register(SchedulerEventType.class, sleepHandler);
    privateDispatcher.register(SchedulerEventType.class, rm.getResourceScheduler());
    privateDispatcher.register(RMNodeEventType.class, new ResourceManager.NodeEventDispatcher(privateContext));
    ((Service) privateDispatcher).init(conf);
    ((Service) privateDispatcher).start();
    NMLivelinessMonitor nmLivelinessMonitor = new NMLivelinessMonitor(privateDispatcher);
    nmLivelinessMonitor.init(conf);
    nmLivelinessMonitor.start();
    NodesListManager nodesListManager = new NodesListManager(privateContext);
    nodesListManager.init(conf);
    RMContainerTokenSecretManager containerTokenSecretManager = new RMContainerTokenSecretManager(conf);
    containerTokenSecretManager.start();
    NMTokenSecretManagerInRM nmTokenSecretManager = new NMTokenSecretManagerInRM(conf);
    nmTokenSecretManager.start();
    ResourceTrackerService privateResourceTrackerService = new ResourceTrackerService(privateContext, nodesListManager, nmLivelinessMonitor, containerTokenSecretManager, nmTokenSecretManager);
    privateResourceTrackerService.init(conf);
    privateResourceTrackerService.start();
    rm.getResourceScheduler().setRMContext(privateContext);
    return privateResourceTrackerService;
}
Also used : RMContext(org.apache.hadoop.yarn.server.resourcemanager.RMContext) Configuration(org.apache.hadoop.conf.Configuration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) ResourceTrackerService(org.apache.hadoop.yarn.server.resourcemanager.ResourceTrackerService) Service(org.apache.hadoop.service.Service) ResourceTrackerService(org.apache.hadoop.yarn.server.resourcemanager.ResourceTrackerService) ResourceManager(org.apache.hadoop.yarn.server.resourcemanager.ResourceManager) NMLivelinessMonitor(org.apache.hadoop.yarn.server.resourcemanager.NMLivelinessMonitor) RMContainerTokenSecretManager(org.apache.hadoop.yarn.server.resourcemanager.security.RMContainerTokenSecretManager) NodesListManager(org.apache.hadoop.yarn.server.resourcemanager.NodesListManager) NMTokenSecretManagerInRM(org.apache.hadoop.yarn.server.resourcemanager.security.NMTokenSecretManagerInRM) RMContextImpl(org.apache.hadoop.yarn.server.resourcemanager.RMContextImpl) RMNodeLabelsManager(org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager)

Example 13 with ResourceManager

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

the class TestRMWebAppFairScheduler method testFairSchedulerWebAppPage.

@Test
public void testFairSchedulerWebAppPage() {
    List<RMAppState> appStates = Arrays.asList(RMAppState.NEW, RMAppState.NEW_SAVING, RMAppState.SUBMITTED);
    final RMContext rmContext = mockRMContext(appStates);
    Injector injector = WebAppTests.createMockInjector(RMContext.class, rmContext, new Module() {

        @Override
        public void configure(Binder binder) {
            try {
                ResourceManager mockRmWithFairScheduler = mockRm(rmContext);
                binder.bind(ResourceManager.class).toInstance(mockRmWithFairScheduler);
                binder.bind(ApplicationBaseProtocol.class).toInstance(mockRmWithFairScheduler.getClientRMService());
            } catch (IOException e) {
                throw new IllegalStateException(e);
            }
        }
    });
    FairSchedulerPage fsViewInstance = injector.getInstance(FairSchedulerPage.class);
    fsViewInstance.render();
    WebAppTests.flushOutput(injector);
}
Also used : RMContext(org.apache.hadoop.yarn.server.resourcemanager.RMContext) Binder(com.google.inject.Binder) RMAppState(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState) 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 14 with ResourceManager

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

the class TestRMWebAppFairScheduler method mockRm.

private static ResourceManager mockRm(RMContext rmContext) throws IOException {
    ResourceManager rm = mock(ResourceManager.class);
    ResourceScheduler rs = mockFairScheduler();
    ClientRMService clientRMService = mockClientRMService(rmContext);
    when(rm.getResourceScheduler()).thenReturn(rs);
    when(rm.getRMContext()).thenReturn(rmContext);
    when(rm.getClientRMService()).thenReturn(clientRMService);
    return rm;
}
Also used : 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 15 with ResourceManager

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

the class TestRMWebAppFairScheduler method testFairSchedulerWebAppPageInInconsistentState.

/**
   *  Testing inconsistent state between AbstractYarnScheduler#applications and
   *  RMContext#applications
   */
@Test
public void testFairSchedulerWebAppPageInInconsistentState() {
    List<RMAppState> appStates = Arrays.asList(RMAppState.NEW, RMAppState.NEW_SAVING, RMAppState.SUBMITTED, RMAppState.RUNNING, RMAppState.FINAL_SAVING, RMAppState.ACCEPTED, RMAppState.FINISHED);
    final RMContext rmContext = mockRMContext(appStates);
    Injector injector = WebAppTests.createMockInjector(RMContext.class, rmContext, new Module() {

        @Override
        public void configure(Binder binder) {
            try {
                ResourceManager mockRmWithFairScheduler = mockRmWithApps(rmContext);
                binder.bind(ResourceManager.class).toInstance(mockRmWithFairScheduler);
                binder.bind(ApplicationBaseProtocol.class).toInstance(mockRmWithFairScheduler.getClientRMService());
            } catch (IOException e) {
                throw new IllegalStateException(e);
            }
        }
    });
    FairSchedulerPage fsViewInstance = injector.getInstance(FairSchedulerPage.class);
    try {
        fsViewInstance.render();
    } catch (Exception e) {
        Assert.fail("Failed to render FairSchedulerPage: " + StringUtils.stringifyException(e));
    }
    WebAppTests.flushOutput(injector);
}
Also used : RMContext(org.apache.hadoop.yarn.server.resourcemanager.RMContext) Binder(com.google.inject.Binder) RMAppState(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState) Injector(com.google.inject.Injector) ResourceManager(org.apache.hadoop.yarn.server.resourcemanager.ResourceManager) IOException(java.io.IOException) Module(com.google.inject.Module) IOException(java.io.IOException) Test(org.junit.Test)

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