Search in sources :

Example 1 with NodesListManagerEvent

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

the class TestNodesListManager method testCachedResolverWithEvent.

@Test
public void testCachedResolverWithEvent() throws Exception {
    Logger rootLogger = LogManager.getRootLogger();
    rootLogger.setLevel(Level.DEBUG);
    YarnConfiguration conf = new YarnConfiguration();
    conf.setInt(YarnConfiguration.RM_NODE_IP_CACHE_EXPIRY_INTERVAL_SECS, 30);
    MockRM rm = new MockRM(conf);
    rm.init(conf);
    NodesListManager nodesListManager = rm.getNodesListManager();
    nodesListManager.init(conf);
    nodesListManager.start();
    NodesListManager.CachedResolver resolver = (NodesListManager.CachedResolver) nodesListManager.getResolver();
    resolver.addToCache("testCachedResolverHost1", "1.1.1.1");
    resolver.addToCache("testCachedResolverHost2", "1.1.1.2");
    Assert.assertEquals("1.1.1.1", resolver.resolve("testCachedResolverHost1"));
    Assert.assertEquals("1.1.1.2", resolver.resolve("testCachedResolverHost2"));
    RMNode rmnode1 = MockNodes.newNodeInfo(1, Resource.newInstance(28000, 8), 1, "testCachedResolverHost1", 1234);
    RMNode rmnode2 = MockNodes.newNodeInfo(1, Resource.newInstance(28000, 8), 1, "testCachedResolverHost2", 1234);
    nodesListManager.handle(new NodesListManagerEvent(NodesListManagerEventType.NODE_USABLE, rmnode1));
    Assert.assertNotEquals("1.1.1.1", resolver.resolve("testCachedResolverHost1"));
    Assert.assertEquals("1.1.1.2", resolver.resolve("testCachedResolverHost2"));
    nodesListManager.handle(new NodesListManagerEvent(NodesListManagerEventType.NODE_USABLE, rmnode2));
    Assert.assertNotEquals("1.1.1.1", resolver.resolve("testCachedResolverHost1"));
    Assert.assertNotEquals("1.1.1.2", resolver.resolve("testCachedResolverHost2"));
}
Also used : NodesListManagerEvent(org.apache.hadoop.yarn.server.resourcemanager.NodesListManagerEvent) RMNode(org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) MockRM(org.apache.hadoop.yarn.server.resourcemanager.MockRM) Logger(org.apache.log4j.Logger) NodesListManager(org.apache.hadoop.yarn.server.resourcemanager.NodesListManager) Test(org.junit.Test)

Example 2 with NodesListManagerEvent

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

the class RMNodeImpl method reportNodeUnusable.

/**
   * Report node is UNUSABLE and update metrics.
   * @param rmNode
   * @param finalState
   */
public static void reportNodeUnusable(RMNodeImpl rmNode, NodeState finalState) {
    // Inform the scheduler
    rmNode.nodeUpdateQueue.clear();
    // If the current state is NodeState.UNHEALTHY
    // Then node is already been removed from the
    // Scheduler
    NodeState initialState = rmNode.getState();
    if (!initialState.equals(NodeState.UNHEALTHY)) {
        rmNode.context.getDispatcher().getEventHandler().handle(new NodeRemovedSchedulerEvent(rmNode));
    }
    rmNode.context.getDispatcher().getEventHandler().handle(new NodesListManagerEvent(NodesListManagerEventType.NODE_UNUSABLE, rmNode));
    //Update the metrics
    rmNode.updateMetricsForDeactivatedNode(initialState, finalState);
}
Also used : NodesListManagerEvent(org.apache.hadoop.yarn.server.resourcemanager.NodesListManagerEvent) NodeState(org.apache.hadoop.yarn.api.records.NodeState) NodeRemovedSchedulerEvent(org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeRemovedSchedulerEvent)

Example 3 with NodesListManagerEvent

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

NodesListManagerEvent (org.apache.hadoop.yarn.server.resourcemanager.NodesListManagerEvent)3 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)2 MockRM (org.apache.hadoop.yarn.server.resourcemanager.MockRM)2 NodesListManager (org.apache.hadoop.yarn.server.resourcemanager.NodesListManager)2 RMNode (org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode)2 Logger (org.apache.log4j.Logger)2 Test (org.junit.Test)2 NodeState (org.apache.hadoop.yarn.api.records.NodeState)1 Resource (org.apache.hadoop.yarn.api.records.Resource)1 Dispatcher (org.apache.hadoop.yarn.event.Dispatcher)1 DrainDispatcher (org.apache.hadoop.yarn.event.DrainDispatcher)1 MockAM (org.apache.hadoop.yarn.server.resourcemanager.MockAM)1 MockNM (org.apache.hadoop.yarn.server.resourcemanager.MockNM)1 RMAppAttempt (org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt)1 NodeRemovedSchedulerEvent (org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeRemovedSchedulerEvent)1