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"));
}
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);
}
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");
}
}
Aggregations