Search in sources :

Example 21 with ApplicationReport

use of org.apache.hadoop.yarn.api.records.ApplicationReport in project hadoop by apache.

the class TestApplicationHistoryClientService method testApplications.

@Test
public void testApplications() throws IOException, YarnException {
    ApplicationId appId = null;
    appId = ApplicationId.newInstance(0, 1);
    ApplicationId appId1 = ApplicationId.newInstance(0, 2);
    GetApplicationsRequest request = GetApplicationsRequest.newInstance();
    GetApplicationsResponse response = clientService.getApplications(request);
    List<ApplicationReport> appReport = response.getApplicationList();
    Assert.assertNotNull(appReport);
    Assert.assertEquals(appId, appReport.get(1).getApplicationId());
    Assert.assertEquals(appId1, appReport.get(0).getApplicationId());
    // Create a historyManager, and set the max_apps can be loaded
    // as 1.
    Configuration conf = new YarnConfiguration();
    conf.setLong(YarnConfiguration.APPLICATION_HISTORY_MAX_APPS, 1);
    ApplicationHistoryManagerOnTimelineStore historyManager2 = new ApplicationHistoryManagerOnTimelineStore(dataManager, new ApplicationACLsManager(conf));
    historyManager2.init(conf);
    historyManager2.start();
    @SuppressWarnings("resource") ApplicationHistoryClientService clientService2 = new ApplicationHistoryClientService(historyManager2);
    response = clientService2.getApplications(request);
    appReport = response.getApplicationList();
    Assert.assertNotNull(appReport);
    Assert.assertTrue(appReport.size() == 1);
    // Expected to get the appReport for application with appId1
    Assert.assertEquals(appId1, appReport.get(0).getApplicationId());
}
Also used : ApplicationReport(org.apache.hadoop.yarn.api.records.ApplicationReport) ApplicationACLsManager(org.apache.hadoop.yarn.server.security.ApplicationACLsManager) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Configuration(org.apache.hadoop.conf.Configuration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) GetApplicationsResponse(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsResponse) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) GetApplicationsRequest(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest) Test(org.junit.Test)

Example 22 with ApplicationReport

use of org.apache.hadoop.yarn.api.records.ApplicationReport in project hadoop by apache.

the class TestApplicationHistoryClientService method testApplicationReport.

@Test
public void testApplicationReport() throws IOException, YarnException {
    ApplicationId appId = null;
    appId = ApplicationId.newInstance(0, 1);
    GetApplicationReportRequest request = GetApplicationReportRequest.newInstance(appId);
    GetApplicationReportResponse response = clientService.getApplicationReport(request);
    ApplicationReport appReport = response.getApplicationReport();
    Assert.assertNotNull(appReport);
    Assert.assertEquals(123, appReport.getApplicationResourceUsageReport().getMemorySeconds());
    Assert.assertEquals(345, appReport.getApplicationResourceUsageReport().getVcoreSeconds());
    Assert.assertEquals("application_0_0001", appReport.getApplicationId().toString());
    Assert.assertEquals("test app type", appReport.getApplicationType().toString());
    Assert.assertEquals("test queue", appReport.getQueue().toString());
}
Also used : ApplicationReport(org.apache.hadoop.yarn.api.records.ApplicationReport) GetApplicationReportRequest(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportRequest) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) GetApplicationReportResponse(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportResponse) Test(org.junit.Test)

Example 23 with ApplicationReport

use of org.apache.hadoop.yarn.api.records.ApplicationReport in project hadoop by apache.

the class TestApplicationHistoryManagerOnTimelineStore method testGetApplications.

@Test
public void testGetApplications() throws Exception {
    Collection<ApplicationReport> apps = historyManager.getApplications(Long.MAX_VALUE, 0L, Long.MAX_VALUE).values();
    Assert.assertNotNull(apps);
    Assert.assertEquals(SCALE + 2, apps.size());
    ApplicationId ignoredAppId = ApplicationId.newInstance(0, SCALE + 2);
    for (ApplicationReport app : apps) {
        Assert.assertNotEquals(ignoredAppId, app.getApplicationId());
    }
    // Get apps by given appStartedTime period
    apps = historyManager.getApplications(Long.MAX_VALUE, 2147483653L, Long.MAX_VALUE).values();
    Assert.assertNotNull(apps);
    Assert.assertEquals(2, apps.size());
}
Also used : ApplicationReport(org.apache.hadoop.yarn.api.records.ApplicationReport) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) Test(org.junit.Test)

Example 24 with ApplicationReport

use of org.apache.hadoop.yarn.api.records.ApplicationReport in project hadoop by apache.

the class TestApplicationHistoryManagerOnTimelineStore method testGetApplicationReportWithNotAttempt.

@Test
public void testGetApplicationReportWithNotAttempt() throws Exception {
    final ApplicationId appId = ApplicationId.newInstance(0, SCALE + 1);
    ApplicationReport app;
    if (callerUGI == null) {
        app = historyManager.getApplication(appId);
    } else {
        app = callerUGI.doAs(new PrivilegedExceptionAction<ApplicationReport>() {

            @Override
            public ApplicationReport run() throws Exception {
                return historyManager.getApplication(appId);
            }
        });
    }
    Assert.assertNotNull(app);
    Assert.assertEquals(appId, app.getApplicationId());
    Assert.assertEquals(ApplicationAttemptId.newInstance(appId, -1), app.getCurrentApplicationAttemptId());
}
Also used : ApplicationReport(org.apache.hadoop.yarn.api.records.ApplicationReport) PrivilegedExceptionAction(java.security.PrivilegedExceptionAction) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) Test(org.junit.Test)

Example 25 with ApplicationReport

use of org.apache.hadoop.yarn.api.records.ApplicationReport in project hadoop by apache.

the class TestClientRMService method testGetQueueInfo.

@Test
public void testGetQueueInfo() throws Exception {
    YarnScheduler yarnScheduler = mock(YarnScheduler.class);
    RMContext rmContext = mock(RMContext.class);
    mockRMContext(yarnScheduler, rmContext);
    ApplicationACLsManager mockAclsManager = mock(ApplicationACLsManager.class);
    QueueACLsManager mockQueueACLsManager = mock(QueueACLsManager.class);
    when(mockQueueACLsManager.checkAccess(any(UserGroupInformation.class), any(QueueACL.class), any(RMApp.class), any(String.class), any())).thenReturn(true);
    when(mockAclsManager.checkAccess(any(UserGroupInformation.class), any(ApplicationAccessType.class), anyString(), any(ApplicationId.class))).thenReturn(true);
    ClientRMService rmService = new ClientRMService(rmContext, yarnScheduler, null, mockAclsManager, mockQueueACLsManager, null);
    GetQueueInfoRequest request = recordFactory.newRecordInstance(GetQueueInfoRequest.class);
    request.setQueueName("testqueue");
    request.setIncludeApplications(true);
    GetQueueInfoResponse queueInfo = rmService.getQueueInfo(request);
    List<ApplicationReport> applications = queueInfo.getQueueInfo().getApplications();
    Assert.assertEquals(2, applications.size());
    request.setQueueName("nonexistentqueue");
    request.setIncludeApplications(true);
    // should not throw exception on nonexistent queue
    queueInfo = rmService.getQueueInfo(request);
    // Case where user does not have application access
    ApplicationACLsManager mockAclsManager1 = mock(ApplicationACLsManager.class);
    QueueACLsManager mockQueueACLsManager1 = mock(QueueACLsManager.class);
    when(mockQueueACLsManager1.checkAccess(any(UserGroupInformation.class), any(QueueACL.class), any(RMApp.class), any(String.class), any())).thenReturn(false);
    when(mockAclsManager1.checkAccess(any(UserGroupInformation.class), any(ApplicationAccessType.class), anyString(), any(ApplicationId.class))).thenReturn(false);
    ClientRMService rmService1 = new ClientRMService(rmContext, yarnScheduler, null, mockAclsManager1, mockQueueACLsManager1, null);
    request.setQueueName("testqueue");
    request.setIncludeApplications(true);
    GetQueueInfoResponse queueInfo1 = rmService1.getQueueInfo(request);
    List<ApplicationReport> applications1 = queueInfo1.getQueueInfo().getApplications();
    Assert.assertEquals(0, applications1.size());
}
Also used : RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) GetQueueInfoRequest(org.apache.hadoop.yarn.api.protocolrecords.GetQueueInfoRequest) GetQueueInfoResponse(org.apache.hadoop.yarn.api.protocolrecords.GetQueueInfoResponse) QueueACL(org.apache.hadoop.yarn.api.records.QueueACL) Matchers.anyString(org.mockito.Matchers.anyString) ApplicationReport(org.apache.hadoop.yarn.api.records.ApplicationReport) ApplicationACLsManager(org.apache.hadoop.yarn.server.security.ApplicationACLsManager) ApplicationAccessType(org.apache.hadoop.yarn.api.records.ApplicationAccessType) YarnScheduler(org.apache.hadoop.yarn.server.resourcemanager.scheduler.YarnScheduler) QueueACLsManager(org.apache.hadoop.yarn.server.resourcemanager.security.QueueACLsManager) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) Test(org.junit.Test)

Aggregations

ApplicationReport (org.apache.hadoop.yarn.api.records.ApplicationReport)140 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)65 Test (org.junit.Test)52 IOException (java.io.IOException)39 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)29 YarnApplicationState (org.apache.hadoop.yarn.api.records.YarnApplicationState)28 YarnClient (org.apache.hadoop.yarn.client.api.YarnClient)20 ApplicationNotFoundException (org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException)19 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)18 ApplicationSubmissionContext (org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext)16 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)16 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)14 ArrayList (java.util.ArrayList)13 Configuration (org.apache.hadoop.conf.Configuration)13 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)12 GetApplicationReportRequest (org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportRequest)11 GetApplicationsRequest (org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest)11 GetApplicationReportResponse (org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportResponse)10 ApplicationResourceUsageReport (org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport)10 ContainerLaunchContext (org.apache.hadoop.yarn.api.records.ContainerLaunchContext)10