use of org.apache.hadoop.yarn.exceptions.ApplicationAttemptNotFoundException in project hadoop by apache.
the class ApplicationCLI method printApplicationAttemptReport.
/**
* Prints the application attempt report for an application attempt id.
*
* @param applicationAttemptId
* @return exitCode
* @throws YarnException
*/
private int printApplicationAttemptReport(String applicationAttemptId) throws YarnException, IOException {
ApplicationAttemptReport appAttemptReport = null;
try {
appAttemptReport = client.getApplicationAttemptReport(ApplicationAttemptId.fromString(applicationAttemptId));
} catch (ApplicationNotFoundException e) {
sysout.println("Application for AppAttempt with id '" + applicationAttemptId + "' doesn't exist in RM or Timeline Server.");
return -1;
} catch (ApplicationAttemptNotFoundException e) {
sysout.println("Application Attempt with id '" + applicationAttemptId + "' doesn't exist in RM or Timeline Server.");
return -1;
}
// Use PrintWriter.println, which uses correct platform line ending.
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintWriter appAttemptReportStr = new PrintWriter(new OutputStreamWriter(baos, Charset.forName("UTF-8")));
if (appAttemptReport != null) {
appAttemptReportStr.println("Application Attempt Report : ");
appAttemptReportStr.print("\tApplicationAttempt-Id : ");
appAttemptReportStr.println(appAttemptReport.getApplicationAttemptId());
appAttemptReportStr.print("\tState : ");
appAttemptReportStr.println(appAttemptReport.getYarnApplicationAttemptState());
appAttemptReportStr.print("\tAMContainer : ");
appAttemptReportStr.println(appAttemptReport.getAMContainerId() == null ? "N/A" : appAttemptReport.getAMContainerId().toString());
appAttemptReportStr.print("\tTracking-URL : ");
appAttemptReportStr.println(appAttemptReport.getTrackingUrl());
appAttemptReportStr.print("\tRPC Port : ");
appAttemptReportStr.println(appAttemptReport.getRpcPort());
appAttemptReportStr.print("\tAM Host : ");
appAttemptReportStr.println(appAttemptReport.getHost());
appAttemptReportStr.print("\tDiagnostics : ");
appAttemptReportStr.print(appAttemptReport.getDiagnostics());
} else {
appAttemptReportStr.print("Application Attempt with id '" + applicationAttemptId + "' doesn't exist in Timeline Server.");
appAttemptReportStr.close();
sysout.println(baos.toString("UTF-8"));
return -1;
}
appAttemptReportStr.close();
sysout.println(baos.toString("UTF-8"));
return 0;
}
use of org.apache.hadoop.yarn.exceptions.ApplicationAttemptNotFoundException in project hadoop by apache.
the class TestAMRMClientAsync method testAMRMClientAsyncShutDownWithWaitFor.
@Test(timeout = 10000)
public void testAMRMClientAsyncShutDownWithWaitFor() throws Exception {
Configuration conf = new Configuration();
final TestCallbackHandler callbackHandler = new TestCallbackHandler();
@SuppressWarnings("unchecked") AMRMClient<ContainerRequest> client = mock(AMRMClientImpl.class);
when(client.allocate(anyFloat())).thenThrow(new ApplicationAttemptNotFoundException("app not found, shut down"));
AMRMClientAsync<ContainerRequest> asyncClient = AMRMClientAsync.createAMRMClientAsync(client, 10, callbackHandler);
asyncClient.init(conf);
asyncClient.start();
Supplier<Boolean> checker = new Supplier<Boolean>() {
@Override
public Boolean get() {
return callbackHandler.reboot;
}
};
asyncClient.registerApplicationMaster("localhost", 1234, null);
asyncClient.waitFor(checker);
asyncClient.stop();
// stopping should have joined all threads and completed all callbacks
Assert.assertTrue(callbackHandler.callbackCount == 0);
verify(client, times(1)).allocate(anyFloat());
asyncClient.stop();
}
use of org.apache.hadoop.yarn.exceptions.ApplicationAttemptNotFoundException in project hadoop by apache.
the class TestAMRMClientAsync method testAMRMClientAsyncShutDown.
@Test(timeout = 10000)
public void testAMRMClientAsyncShutDown() throws Exception {
Configuration conf = new Configuration();
TestCallbackHandler callbackHandler = new TestCallbackHandler();
@SuppressWarnings("unchecked") AMRMClient<ContainerRequest> client = mock(AMRMClientImpl.class);
createAllocateResponse(new ArrayList<ContainerStatus>(), new ArrayList<Container>(), null);
when(client.allocate(anyFloat())).thenThrow(new ApplicationAttemptNotFoundException("app not found, shut down"));
AMRMClientAsync<ContainerRequest> asyncClient = AMRMClientAsync.createAMRMClientAsync(client, 10, callbackHandler);
asyncClient.init(conf);
asyncClient.start();
asyncClient.registerApplicationMaster("localhost", 1234, null);
Thread.sleep(50);
verify(client, times(1)).allocate(anyFloat());
asyncClient.stop();
}
use of org.apache.hadoop.yarn.exceptions.ApplicationAttemptNotFoundException in project hadoop by apache.
the class ClientRMService method getApplicationAttemptReport.
@Override
public GetApplicationAttemptReportResponse getApplicationAttemptReport(GetApplicationAttemptReportRequest request) throws YarnException, IOException {
ApplicationAttemptId appAttemptId = request.getApplicationAttemptId();
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(appAttemptId.getApplicationId());
if (application == null) {
// ApplicationNotFoundException and let client to handle.
throw new ApplicationNotFoundException("Application with id '" + request.getApplicationAttemptId().getApplicationId() + "' doesn't exist in RM. Please check that the job " + "submission was successful.");
}
boolean allowAccess = checkAccess(callerUGI, application.getUser(), ApplicationAccessType.VIEW_APP, application);
GetApplicationAttemptReportResponse response = null;
if (allowAccess) {
RMAppAttempt appAttempt = application.getAppAttempts().get(appAttemptId);
if (appAttempt == null) {
throw new ApplicationAttemptNotFoundException("ApplicationAttempt with id '" + appAttemptId + "' doesn't exist in RM.");
}
ApplicationAttemptReport attemptReport = appAttempt.createApplicationAttemptReport();
response = GetApplicationAttemptReportResponse.newInstance(attemptReport);
} else {
throw new YarnException("User " + callerUGI.getShortUserName() + " does not have privilege to see this attempt " + appAttemptId);
}
return response;
}
use of org.apache.hadoop.yarn.exceptions.ApplicationAttemptNotFoundException in project hadoop by apache.
the class TestYarnCLI method testGetApplicationAttemptReportException.
@Test
public void testGetApplicationAttemptReportException() throws Exception {
ApplicationCLI cli = createAndGetAppCLI();
ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
ApplicationAttemptId attemptId1 = ApplicationAttemptId.newInstance(applicationId, 1);
when(client.getApplicationAttemptReport(attemptId1)).thenThrow(new ApplicationNotFoundException("History file for application" + applicationId + " is not found"));
int exitCode = cli.run(new String[] { "applicationattempt", "-status", attemptId1.toString() });
verify(sysOut).println("Application for AppAttempt with id '" + attemptId1 + "' doesn't exist in RM or Timeline Server.");
Assert.assertNotSame("should return non-zero exit code.", 0, exitCode);
ApplicationAttemptId attemptId2 = ApplicationAttemptId.newInstance(applicationId, 2);
when(client.getApplicationAttemptReport(attemptId2)).thenThrow(new ApplicationAttemptNotFoundException("History file for application attempt" + attemptId2 + " is not found"));
exitCode = cli.run(new String[] { "applicationattempt", "-status", attemptId2.toString() });
verify(sysOut).println("Application Attempt with id '" + attemptId2 + "' doesn't exist in RM or Timeline Server.");
Assert.assertNotSame("should return non-zero exit code.", 0, exitCode);
}
Aggregations