Search in sources :

Example 6 with NodesListManager

use of org.apache.hadoop.yarn.server.resourcemanager.NodesListManager 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 7 with NodesListManager

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

the class TestNodesListManager method testNodeUsableEvent.

@Test(timeout = 300000)
public void testNodeUsableEvent() throws Exception {
    Logger rootLogger = LogManager.getRootLogger();
    rootLogger.setLevel(Level.DEBUG);
    final Dispatcher dispatcher = getDispatcher();
    YarnConfiguration conf = new YarnConfiguration();
    MockRM rm = new MockRM(conf) {

        @Override
        protected Dispatcher createDispatcher() {
            return dispatcher;
        }
    };
    rm.start();
    MockNM nm1 = rm.registerNode("h1:1234", 28000);
    NodesListManager nodesListManager = rm.getNodesListManager();
    Resource clusterResource = Resource.newInstance(28000, 8);
    RMNode rmnode = MockNodes.newNodeInfo(1, clusterResource);
    // Create killing APP
    RMApp killrmApp = rm.submitApp(200);
    rm.killApp(killrmApp.getApplicationId());
    rm.waitForState(killrmApp.getApplicationId(), RMAppState.KILLED);
    // Create finish APP
    RMApp finshrmApp = rm.submitApp(2000);
    nm1.nodeHeartbeat(true);
    RMAppAttempt attempt = finshrmApp.getCurrentAppAttempt();
    MockAM am = rm.sendAMLaunched(attempt.getAppAttemptId());
    am.registerAppAttempt();
    am.unregisterAppAttempt();
    nm1.nodeHeartbeat(attempt.getAppAttemptId(), 1, ContainerState.COMPLETE);
    rm.waitForState(am.getApplicationAttemptId(), RMAppAttemptState.FINISHED);
    // Create submitted App
    RMApp subrmApp = rm.submitApp(200);
    // Fire Event for NODE_USABLE
    nodesListManager.handle(new NodesListManagerEvent(NodesListManagerEventType.NODE_USABLE, rmnode));
    if (applist.size() > 0) {
        Assert.assertTrue("Event based on running app expected " + subrmApp.getApplicationId(), applist.contains(subrmApp.getApplicationId()));
        Assert.assertFalse("Event based on finish app not expected " + finshrmApp.getApplicationId(), applist.contains(finshrmApp.getApplicationId()));
        Assert.assertFalse("Event based on killed app not expected " + killrmApp.getApplicationId(), applist.contains(killrmApp.getApplicationId()));
    } else {
        Assert.fail("Events received should have beeen more than 1");
    }
    applist.clear();
    // Fire Event for NODE_UNUSABLE
    nodesListManager.handle(new NodesListManagerEvent(NodesListManagerEventType.NODE_UNUSABLE, rmnode));
    if (applist.size() > 0) {
        Assert.assertTrue("Event based on running app expected " + subrmApp.getApplicationId(), applist.contains(subrmApp.getApplicationId()));
        Assert.assertFalse("Event based on finish app not expected " + finshrmApp.getApplicationId(), applist.contains(finshrmApp.getApplicationId()));
        Assert.assertFalse("Event based on killed app not expected " + killrmApp.getApplicationId(), applist.contains(killrmApp.getApplicationId()));
    } else {
        Assert.fail("Events received should have beeen more than 1");
    }
}
Also used : NodesListManagerEvent(org.apache.hadoop.yarn.server.resourcemanager.NodesListManagerEvent) RMNode(org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode) RMAppAttempt(org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) MockNM(org.apache.hadoop.yarn.server.resourcemanager.MockNM) Resource(org.apache.hadoop.yarn.api.records.Resource) MockAM(org.apache.hadoop.yarn.server.resourcemanager.MockAM) MockRM(org.apache.hadoop.yarn.server.resourcemanager.MockRM) Logger(org.apache.log4j.Logger) Dispatcher(org.apache.hadoop.yarn.event.Dispatcher) DrainDispatcher(org.apache.hadoop.yarn.event.DrainDispatcher) NodesListManager(org.apache.hadoop.yarn.server.resourcemanager.NodesListManager) Test(org.junit.Test)

Aggregations

NodesListManager (org.apache.hadoop.yarn.server.resourcemanager.NodesListManager)7 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)6 Configuration (org.apache.hadoop.conf.Configuration)4 NMLivelinessMonitor (org.apache.hadoop.yarn.server.resourcemanager.NMLivelinessMonitor)4 RMContextImpl (org.apache.hadoop.yarn.server.resourcemanager.RMContextImpl)4 ResourceTrackerService (org.apache.hadoop.yarn.server.resourcemanager.ResourceTrackerService)4 NMTokenSecretManagerInRM (org.apache.hadoop.yarn.server.resourcemanager.security.NMTokenSecretManagerInRM)4 RMContainerTokenSecretManager (org.apache.hadoop.yarn.server.resourcemanager.security.RMContainerTokenSecretManager)4 Dispatcher (org.apache.hadoop.yarn.event.Dispatcher)3 InlineDispatcher (org.apache.hadoop.yarn.event.InlineDispatcher)3 MockRM (org.apache.hadoop.yarn.server.resourcemanager.MockRM)3 RMContext (org.apache.hadoop.yarn.server.resourcemanager.RMContext)3 Logger (org.apache.log4j.Logger)3 Before (org.junit.Before)3 Test (org.junit.Test)3 NodesListManagerEvent (org.apache.hadoop.yarn.server.resourcemanager.NodesListManagerEvent)2 ResourceManager (org.apache.hadoop.yarn.server.resourcemanager.ResourceManager)2 NodeEventDispatcher (org.apache.hadoop.yarn.server.resourcemanager.ResourceManager.NodeEventDispatcher)2 RMNode (org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode)2 Service (org.apache.hadoop.service.Service)1