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