Search in sources :

Example 1 with RMNMInfo

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

the class TestRMNMInfo method testRMNMInfoMissmatch.

@Test
public void testRMNMInfoMissmatch() throws Exception {
    RMContext rmc = mock(RMContext.class);
    ResourceScheduler rms = mock(ResourceScheduler.class);
    ConcurrentMap<NodeId, RMNode> map = new ConcurrentHashMap<NodeId, RMNode>();
    RMNode node = MockNodes.newNodeInfo(1, MockNodes.newResource(4 * 1024));
    map.put(node.getNodeID(), node);
    when(rmc.getRMNodes()).thenReturn(map);
    RMNMInfo rmInfo = new RMNMInfo(rmc, rms);
    String liveNMs = rmInfo.getLiveNodeManagers();
    ObjectMapper mapper = new ObjectMapper();
    JsonNode jn = mapper.readTree(liveNMs);
    Assert.assertEquals("Unexpected number of live nodes:", 1, jn.size());
    Iterator<JsonNode> it = jn.iterator();
    while (it.hasNext()) {
        JsonNode n = it.next();
        Assert.assertNotNull(n.get("HostName"));
        Assert.assertNotNull(n.get("Rack"));
        Assert.assertTrue("Node " + n.get("NodeId") + " should be RUNNING", n.get("State").asText().contains("RUNNING"));
        Assert.assertNotNull(n.get("NodeHTTPAddress"));
        Assert.assertNotNull(n.get("LastHealthUpdate"));
        Assert.assertNotNull(n.get("HealthReport"));
        Assert.assertNotNull(n.get("NodeManagerVersion"));
        Assert.assertNull(n.get("NumContainers"));
        Assert.assertNull(n.get("UsedMemoryMB"));
        Assert.assertNull(n.get("AvailableMemoryMB"));
    }
}
Also used : RMContext(org.apache.hadoop.yarn.server.resourcemanager.RMContext) RMNode(org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode) RMNMInfo(org.apache.hadoop.yarn.server.resourcemanager.RMNMInfo) NodeId(org.apache.hadoop.yarn.api.records.NodeId) ResourceScheduler(org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler) JsonNode(com.fasterxml.jackson.databind.JsonNode) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 2 with RMNMInfo

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

the class TestRMNMInfo method testRMNMInfo.

@Test
public void testRMNMInfo() throws Exception {
    if (!(new File(MiniMRYarnCluster.APPJAR)).exists()) {
        LOG.info("MRAppJar " + MiniMRYarnCluster.APPJAR + " not found. Not running test.");
        return;
    }
    RMContext rmc = mrCluster.getResourceManager().getRMContext();
    ResourceScheduler rms = mrCluster.getResourceManager().getResourceScheduler();
    RMNMInfo rmInfo = new RMNMInfo(rmc, rms);
    String liveNMs = rmInfo.getLiveNodeManagers();
    ObjectMapper mapper = new ObjectMapper();
    JsonNode jn = mapper.readTree(liveNMs);
    Assert.assertEquals("Unexpected number of live nodes:", NUMNODEMANAGERS, jn.size());
    Iterator<JsonNode> it = jn.iterator();
    while (it.hasNext()) {
        JsonNode n = it.next();
        Assert.assertNotNull(n.get("HostName"));
        Assert.assertNotNull(n.get("Rack"));
        Assert.assertTrue("Node " + n.get("NodeId") + " should be RUNNING", n.get("State").asText().contains("RUNNING"));
        Assert.assertNotNull(n.get("NodeHTTPAddress"));
        Assert.assertNotNull(n.get("LastHealthUpdate"));
        Assert.assertNotNull(n.get("HealthReport"));
        Assert.assertNotNull(n.get("NodeManagerVersion"));
        Assert.assertNotNull(n.get("NumContainers"));
        Assert.assertEquals(n.get("NodeId") + ": Unexpected number of used containers", 0, n.get("NumContainers").asInt());
        Assert.assertEquals(n.get("NodeId") + ": Unexpected amount of used memory", 0, n.get("UsedMemoryMB").asInt());
        Assert.assertNotNull(n.get("AvailableMemoryMB"));
    }
}
Also used : RMContext(org.apache.hadoop.yarn.server.resourcemanager.RMContext) RMNMInfo(org.apache.hadoop.yarn.server.resourcemanager.RMNMInfo) ResourceScheduler(org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler) JsonNode(com.fasterxml.jackson.databind.JsonNode) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 RMContext (org.apache.hadoop.yarn.server.resourcemanager.RMContext)2 RMNMInfo (org.apache.hadoop.yarn.server.resourcemanager.RMNMInfo)2 ResourceScheduler (org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler)2 Test (org.junit.Test)2 File (java.io.File)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 NodeId (org.apache.hadoop.yarn.api.records.NodeId)1 RMNode (org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode)1