Search in sources :

Example 11 with ApplicationAttemptReport

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

the class TestApplicationHistoryClientService method testApplicationAttempts.

@Test
public void testApplicationAttempts() throws IOException, YarnException {
    ApplicationId appId = ApplicationId.newInstance(0, 1);
    ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 1);
    ApplicationAttemptId appAttemptId1 = ApplicationAttemptId.newInstance(appId, 2);
    GetApplicationAttemptsRequest request = GetApplicationAttemptsRequest.newInstance(appId);
    GetApplicationAttemptsResponse response = clientService.getApplicationAttempts(request);
    List<ApplicationAttemptReport> attemptReports = response.getApplicationAttemptList();
    Assert.assertNotNull(attemptReports);
    Assert.assertEquals(appAttemptId, attemptReports.get(0).getApplicationAttemptId());
    Assert.assertEquals(appAttemptId1, attemptReports.get(1).getApplicationAttemptId());
}
Also used : ApplicationAttemptReport(org.apache.hadoop.yarn.api.records.ApplicationAttemptReport) GetApplicationAttemptsRequest(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptsRequest) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) GetApplicationAttemptsResponse(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptsResponse) Test(org.junit.Test)

Example 12 with ApplicationAttemptReport

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

the class TestApplicationHistoryManagerOnTimelineStore method testGetApplicationAttemptReport.

@Test
public void testGetApplicationAttemptReport() throws Exception {
    final ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(ApplicationId.newInstance(0, 1), 1);
    ApplicationAttemptReport appAttempt;
    if (callerUGI == null) {
        appAttempt = historyManager.getApplicationAttempt(appAttemptId);
    } else {
        try {
            appAttempt = callerUGI.doAs(new PrivilegedExceptionAction<ApplicationAttemptReport>() {

                @Override
                public ApplicationAttemptReport run() throws Exception {
                    return historyManager.getApplicationAttempt(appAttemptId);
                }
            });
            if (callerUGI != null && callerUGI.getShortUserName().equals("user3")) {
                // The exception is expected
                Assert.fail();
            }
        } catch (AuthorizationException e) {
            if (callerUGI != null && callerUGI.getShortUserName().equals("user3")) {
                // The exception is expected
                return;
            }
            throw e;
        }
    }
    Assert.assertNotNull(appAttempt);
    Assert.assertEquals(appAttemptId, appAttempt.getApplicationAttemptId());
    Assert.assertEquals(ContainerId.newContainerId(appAttemptId, 1), appAttempt.getAMContainerId());
    Assert.assertEquals("test host", appAttempt.getHost());
    Assert.assertEquals(100, appAttempt.getRpcPort());
    Assert.assertEquals("test tracking url", appAttempt.getTrackingUrl());
    Assert.assertEquals("test original tracking url", appAttempt.getOriginalTrackingUrl());
    Assert.assertEquals("test diagnostics info", appAttempt.getDiagnostics());
    Assert.assertEquals(YarnApplicationAttemptState.FINISHED, appAttempt.getYarnApplicationAttemptState());
}
Also used : ApplicationAttemptReport(org.apache.hadoop.yarn.api.records.ApplicationAttemptReport) AuthorizationException(org.apache.hadoop.security.authorize.AuthorizationException) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId) PrivilegedExceptionAction(java.security.PrivilegedExceptionAction) Test(org.junit.Test)

Example 13 with ApplicationAttemptReport

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

the class GetApplicationAttemptsResponsePBImpl method initLocalApplicationAttemptsList.

// Once this is called. containerList will never be null - until a getProto
// is called.
private void initLocalApplicationAttemptsList() {
    if (this.applicationAttemptList != null) {
        return;
    }
    GetApplicationAttemptsResponseProtoOrBuilder p = viaProto ? proto : builder;
    List<ApplicationAttemptReportProto> list = p.getApplicationAttemptsList();
    applicationAttemptList = new ArrayList<ApplicationAttemptReport>();
    for (ApplicationAttemptReportProto a : list) {
        applicationAttemptList.add(convertFromProtoFormat(a));
    }
}
Also used : ApplicationAttemptReport(org.apache.hadoop.yarn.api.records.ApplicationAttemptReport) GetApplicationAttemptsResponseProtoOrBuilder(org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationAttemptsResponseProtoOrBuilder) ApplicationAttemptReportProto(org.apache.hadoop.yarn.proto.YarnProtos.ApplicationAttemptReportProto)

Example 14 with ApplicationAttemptReport

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

the class TestYarnClient method testGetApplicationAttempts.

@Test(timeout = 10000)
public void testGetApplicationAttempts() throws YarnException, IOException {
    Configuration conf = new Configuration();
    final YarnClient client = new MockYarnClient();
    client.init(conf);
    client.start();
    ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
    List<ApplicationAttemptReport> reports = client.getApplicationAttempts(applicationId);
    Assert.assertNotNull(reports);
    Assert.assertEquals(reports.get(0).getApplicationAttemptId(), ApplicationAttemptId.newInstance(applicationId, 1));
    Assert.assertEquals(reports.get(1).getApplicationAttemptId(), ApplicationAttemptId.newInstance(applicationId, 2));
    client.stop();
}
Also used : ApplicationAttemptReport(org.apache.hadoop.yarn.api.records.ApplicationAttemptReport) CapacitySchedulerConfiguration(org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration) Configuration(org.apache.hadoop.conf.Configuration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) YarnClient(org.apache.hadoop.yarn.client.api.YarnClient) Test(org.junit.Test)

Example 15 with ApplicationAttemptReport

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

the class TestYarnCLI method testAppAttemptReportWhileContainerIsNotAssigned.

@Test
public void testAppAttemptReportWhileContainerIsNotAssigned() throws Exception {
    ApplicationCLI cli = createAndGetAppCLI();
    ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
    ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance(applicationId, 1);
    ApplicationAttemptReport attemptReport = ApplicationAttemptReport.newInstance(attemptId, "host", 124, "url", "oUrl", "diagnostics", YarnApplicationAttemptState.SCHEDULED, null, 1000l, 2000l);
    when(client.getApplicationAttemptReport(any(ApplicationAttemptId.class))).thenReturn(attemptReport);
    int result = cli.run(new String[] { "applicationattempt", "-status", attemptId.toString() });
    assertEquals(0, result);
    result = cli.run(new String[] { "applicationattempt", "-list", applicationId.toString() });
    assertEquals(0, result);
}
Also used : ApplicationAttemptReport(org.apache.hadoop.yarn.api.records.ApplicationAttemptReport) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) Test(org.junit.Test)

Aggregations

ApplicationAttemptReport (org.apache.hadoop.yarn.api.records.ApplicationAttemptReport)35 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)18 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)17 Test (org.junit.Test)15 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)8 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)7 Configuration (org.apache.hadoop.conf.Configuration)6 ApplicationReport (org.apache.hadoop.yarn.api.records.ApplicationReport)6 AuthorizationException (org.apache.hadoop.security.authorize.AuthorizationException)5 ContainerReport (org.apache.hadoop.yarn.api.records.ContainerReport)5 YarnClient (org.apache.hadoop.yarn.client.api.YarnClient)5 ApplicationAttemptNotFoundException (org.apache.hadoop.yarn.exceptions.ApplicationAttemptNotFoundException)5 ApplicationNotFoundException (org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException)5 PrintWriter (java.io.PrintWriter)4 ArrayList (java.util.ArrayList)4 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)4 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)4 ContainerNotFoundException (org.apache.hadoop.yarn.exceptions.ContainerNotFoundException)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 GetApplicationAttemptReportRequest (org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportRequest)3