use of org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptsResponse in project hadoop by apache.
the class TestClientRMService method testGetApplicationAttempts.
@Test
public void testGetApplicationAttempts() throws YarnException, IOException {
ClientRMService rmService = createRMService();
RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
GetApplicationAttemptsRequest request = recordFactory.newRecordInstance(GetApplicationAttemptsRequest.class);
ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance(ApplicationId.newInstance(123456, 1), 1);
request.setApplicationId(ApplicationId.newInstance(123456, 1));
try {
GetApplicationAttemptsResponse response = rmService.getApplicationAttempts(request);
Assert.assertEquals(1, response.getApplicationAttemptList().size());
Assert.assertEquals(attemptId, response.getApplicationAttemptList().get(0).getApplicationAttemptId());
} catch (ApplicationNotFoundException ex) {
Assert.fail(ex.getMessage());
}
}
use of org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptsResponse in project hadoop by apache.
the class ClientRMService method getApplicationAttempts.
@Override
public GetApplicationAttemptsResponse getApplicationAttempts(GetApplicationAttemptsRequest request) throws YarnException, IOException {
ApplicationId appId = request.getApplicationId();
UserGroupInformation callerUGI;
try {
callerUGI = UserGroupInformation.getCurrentUser();
} catch (IOException ie) {
LOG.info("Error getting UGI ", ie);
throw RPCUtil.getRemoteException(ie);
}
RMApp application = this.rmContext.getRMApps().get(appId);
if (application == null) {
// ApplicationNotFoundException and let client to handle.
throw new ApplicationNotFoundException("Application with id '" + appId + "' doesn't exist in RM. Please check that the job submission " + "was successful.");
}
boolean allowAccess = checkAccess(callerUGI, application.getUser(), ApplicationAccessType.VIEW_APP, application);
GetApplicationAttemptsResponse response = null;
if (allowAccess) {
Map<ApplicationAttemptId, RMAppAttempt> attempts = application.getAppAttempts();
List<ApplicationAttemptReport> listAttempts = new ArrayList<ApplicationAttemptReport>();
Iterator<Map.Entry<ApplicationAttemptId, RMAppAttempt>> iter = attempts.entrySet().iterator();
while (iter.hasNext()) {
listAttempts.add(iter.next().getValue().createApplicationAttemptReport());
}
response = GetApplicationAttemptsResponse.newInstance(listAttempts);
} else {
throw new YarnException("User " + callerUGI.getShortUserName() + " does not have privilege to see this application " + appId);
}
return response;
}
use of org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptsResponse 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.protocolrecords.GetApplicationAttemptsResponse in project hadoop by apache.
the class YarnClientImpl method getApplicationAttempts.
@Override
public List<ApplicationAttemptReport> getApplicationAttempts(ApplicationId appId) throws YarnException, IOException {
try {
GetApplicationAttemptsRequest request = Records.newRecord(GetApplicationAttemptsRequest.class);
request.setApplicationId(appId);
GetApplicationAttemptsResponse response = rmClient.getApplicationAttempts(request);
return response.getApplicationAttemptList();
} catch (YarnException e) {
if (!historyServiceEnabled) {
// Just throw it as usual if historyService is not enabled.
throw e;
}
// except the following
if (e.getClass() != ApplicationNotFoundException.class) {
throw e;
}
return historyClient.getApplicationAttempts(appId);
}
}
use of org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptsResponse in project hadoop by apache.
the class AHSClientImpl method getApplicationAttempts.
@Override
public List<ApplicationAttemptReport> getApplicationAttempts(ApplicationId appId) throws YarnException, IOException {
GetApplicationAttemptsRequest request = GetApplicationAttemptsRequest.newInstance(appId);
GetApplicationAttemptsResponse response = ahsClient.getApplicationAttempts(request);
return response.getApplicationAttemptList();
}
Aggregations