use of org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptsRequest 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.GetApplicationAttemptsRequest 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.GetApplicationAttemptsRequest 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.GetApplicationAttemptsRequest 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();
}
use of org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptsRequest in project hadoop by apache.
the class AppBlock method render.
@Override
protected void render(Block html) {
String webUiType = $(WEB_UI_TYPE);
String aid = $(APPLICATION_ID);
if (aid.isEmpty()) {
puts("Bad request: requires Application ID");
return;
}
try {
appID = Apps.toAppID(aid);
} catch (Exception e) {
puts("Invalid Application ID: " + aid);
return;
}
UserGroupInformation callerUGI = getCallerUGI();
ApplicationReport appReport;
try {
final GetApplicationReportRequest request = GetApplicationReportRequest.newInstance(appID);
if (callerUGI == null) {
throw new AuthenticationException("Failed to get user name from request");
} else {
appReport = callerUGI.doAs(new PrivilegedExceptionAction<ApplicationReport>() {
@Override
public ApplicationReport run() throws Exception {
return appBaseProt.getApplicationReport(request).getApplicationReport();
}
});
}
} catch (Exception e) {
String message = "Failed to read the application " + appID + ".";
LOG.error(message, e);
html.p()._(message)._();
return;
}
if (appReport == null) {
puts("Application not found: " + aid);
return;
}
AppInfo app = new AppInfo(appReport);
setTitle(join("Application ", aid));
if (webUiType != null && webUiType.equals(YarnWebParams.RM_WEB_UI) && conf.getBoolean(YarnConfiguration.RM_WEBAPP_UI_ACTIONS_ENABLED, YarnConfiguration.DEFAULT_RM_WEBAPP_UI_ACTIONS_ENABLED)) {
// Application Kill
html.div().button().$onclick("confirmAction()").b("Kill Application")._()._();
StringBuilder script = new StringBuilder();
script.append("function confirmAction() {").append(" b = confirm(\"Are you sure?\");").append(" if (b == true) {").append(" $.ajax({").append(" type: 'PUT',").append(" url: '/ws/v1/cluster/apps/").append(aid).append("/state',").append(" contentType: 'application/json',").append(getCSRFHeaderString(conf)).append(" data: '{\"state\":\"KILLED\"}',").append(" dataType: 'json'").append(" }).done(function(data){").append(" setTimeout(function(){").append(" location.href = '/cluster/app/").append(aid).append("';").append(" }, 1000);").append(" }).fail(function(data){").append(" console.log(data);").append(" });").append(" }").append("}");
html.script().$type("text/javascript")._(script.toString())._();
}
String schedulerPath = WebAppUtils.getResolvedRMWebAppURLWithScheme(conf) + "/cluster/scheduler?openQueues=" + app.getQueue();
generateOverviewTable(app, schedulerPath, webUiType, appReport);
Collection<ApplicationAttemptReport> attempts;
try {
final GetApplicationAttemptsRequest request = GetApplicationAttemptsRequest.newInstance(appID);
attempts = callerUGI.doAs(new PrivilegedExceptionAction<Collection<ApplicationAttemptReport>>() {
@Override
public Collection<ApplicationAttemptReport> run() throws Exception {
return appBaseProt.getApplicationAttempts(request).getApplicationAttemptList();
}
});
} catch (Exception e) {
String message = "Failed to read the attempts of the application " + appID + ".";
LOG.error(message, e);
html.p()._(message)._();
return;
}
createApplicationMetricsTable(html);
html._(InfoBlock.class);
generateApplicationTable(html, callerUGI, attempts);
}
Aggregations