Search in sources :

Example 76 with RMContext

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

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

Example 78 with RMContext

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

the class TestHadoopArchiveLogs method testFilterAppsByAggregatedStatus.

@Test(timeout = 30000)
public void testFilterAppsByAggregatedStatus() throws Exception {
    try (MiniYARNCluster yarnCluster = new MiniYARNCluster(TestHadoopArchiveLogs.class.getSimpleName(), 1, 1, 1, 1)) {
        Configuration conf = new Configuration();
        conf.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED, true);
        yarnCluster.init(conf);
        yarnCluster.start();
        conf = yarnCluster.getConfig();
        RMContext rmContext = yarnCluster.getResourceManager().getRMContext();
        RMAppImpl appImpl1 = (RMAppImpl) createRMApp(1, conf, rmContext, LogAggregationStatus.DISABLED);
        RMAppImpl appImpl2 = (RMAppImpl) createRMApp(2, conf, rmContext, LogAggregationStatus.FAILED);
        RMAppImpl appImpl3 = (RMAppImpl) createRMApp(3, conf, rmContext, LogAggregationStatus.NOT_START);
        RMAppImpl appImpl4 = (RMAppImpl) createRMApp(4, conf, rmContext, LogAggregationStatus.SUCCEEDED);
        RMAppImpl appImpl5 = (RMAppImpl) createRMApp(5, conf, rmContext, LogAggregationStatus.RUNNING);
        RMAppImpl appImpl6 = (RMAppImpl) createRMApp(6, conf, rmContext, LogAggregationStatus.RUNNING_WITH_FAILURE);
        RMAppImpl appImpl7 = (RMAppImpl) createRMApp(7, conf, rmContext, LogAggregationStatus.TIME_OUT);
        RMAppImpl appImpl8 = (RMAppImpl) createRMApp(8, conf, rmContext, LogAggregationStatus.SUCCEEDED);
        rmContext.getRMApps().put(appImpl1.getApplicationId(), appImpl1);
        rmContext.getRMApps().put(appImpl2.getApplicationId(), appImpl2);
        rmContext.getRMApps().put(appImpl3.getApplicationId(), appImpl3);
        rmContext.getRMApps().put(appImpl4.getApplicationId(), appImpl4);
        rmContext.getRMApps().put(appImpl5.getApplicationId(), appImpl5);
        rmContext.getRMApps().put(appImpl6.getApplicationId(), appImpl6);
        rmContext.getRMApps().put(appImpl7.getApplicationId(), appImpl7);
        // appImpl8 is not in the RM
        HadoopArchiveLogs hal = new HadoopArchiveLogs(conf);
        Assert.assertEquals(0, hal.eligibleApplications.size());
        hal.eligibleApplications.add(new HadoopArchiveLogs.AppInfo(appImpl1.getApplicationId().toString(), USER));
        hal.eligibleApplications.add(new HadoopArchiveLogs.AppInfo(appImpl2.getApplicationId().toString(), USER));
        hal.eligibleApplications.add(new HadoopArchiveLogs.AppInfo(appImpl3.getApplicationId().toString(), USER));
        HadoopArchiveLogs.AppInfo app4 = new HadoopArchiveLogs.AppInfo(appImpl4.getApplicationId().toString(), USER);
        hal.eligibleApplications.add(app4);
        hal.eligibleApplications.add(new HadoopArchiveLogs.AppInfo(appImpl5.getApplicationId().toString(), USER));
        hal.eligibleApplications.add(new HadoopArchiveLogs.AppInfo(appImpl6.getApplicationId().toString(), USER));
        HadoopArchiveLogs.AppInfo app7 = new HadoopArchiveLogs.AppInfo(appImpl7.getApplicationId().toString(), USER);
        hal.eligibleApplications.add(app7);
        HadoopArchiveLogs.AppInfo app8 = new HadoopArchiveLogs.AppInfo(appImpl8.getApplicationId().toString(), USER);
        hal.eligibleApplications.add(app8);
        Assert.assertEquals(8, hal.eligibleApplications.size());
        hal.filterAppsByAggregatedStatus();
        Assert.assertEquals(3, hal.eligibleApplications.size());
        Assert.assertTrue(hal.eligibleApplications.contains(app4));
        Assert.assertTrue(hal.eligibleApplications.contains(app7));
        Assert.assertTrue(hal.eligibleApplications.contains(app8));
    }
}
Also used : RMAppImpl(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppImpl) RMContext(org.apache.hadoop.yarn.server.resourcemanager.RMContext) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Configuration(org.apache.hadoop.conf.Configuration) MiniYARNCluster(org.apache.hadoop.yarn.server.MiniYARNCluster) Test(org.junit.Test)

Aggregations

RMContext (org.apache.hadoop.yarn.server.resourcemanager.RMContext)78 Test (org.junit.Test)45 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)33 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)24 Resource (org.apache.hadoop.yarn.api.records.Resource)24 Configuration (org.apache.hadoop.conf.Configuration)20 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)20 Priority (org.apache.hadoop.yarn.api.records.Priority)14 Before (org.junit.Before)14 IOException (java.io.IOException)12 ResourceManager (org.apache.hadoop.yarn.server.resourcemanager.ResourceManager)11 Dispatcher (org.apache.hadoop.yarn.event.Dispatcher)10 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)10 RMNode (org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode)10 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)9 RMApplicationHistoryWriter (org.apache.hadoop.yarn.server.resourcemanager.ahs.RMApplicationHistoryWriter)9 SystemMetricsPublisher (org.apache.hadoop.yarn.server.resourcemanager.metrics.SystemMetricsPublisher)9 CapacitySchedulerConfiguration (org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration)8 FiCaSchedulerApp (org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp)8 NodeAddedSchedulerEvent (org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeAddedSchedulerEvent)8