Search in sources :

Example 6 with GetApplicationAttemptsRequest

use of org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptsRequest in project hadoop by apache.

the class WebServices method getAppAttempts.

public AppAttemptsInfo getAppAttempts(HttpServletRequest req, HttpServletResponse res, String appId) {
    UserGroupInformation callerUGI = getUser(req);
    final ApplicationId id = parseApplicationId(appId);
    Collection<ApplicationAttemptReport> appAttemptReports = null;
    try {
        if (callerUGI == null) {
            GetApplicationAttemptsRequest request = GetApplicationAttemptsRequest.newInstance(id);
            appAttemptReports = appBaseProt.getApplicationAttempts(request).getApplicationAttemptList();
        } else {
            appAttemptReports = callerUGI.doAs(new PrivilegedExceptionAction<Collection<ApplicationAttemptReport>>() {

                @Override
                public Collection<ApplicationAttemptReport> run() throws Exception {
                    GetApplicationAttemptsRequest request = GetApplicationAttemptsRequest.newInstance(id);
                    return appBaseProt.getApplicationAttempts(request).getApplicationAttemptList();
                }
            });
        }
    } catch (Exception e) {
        rewrapAndThrowException(e);
    }
    AppAttemptsInfo appAttemptsInfo = new AppAttemptsInfo();
    if (appAttemptReports == null) {
        return appAttemptsInfo;
    }
    for (ApplicationAttemptReport appAttemptReport : appAttemptReports) {
        AppAttemptInfo appAttemptInfo = new AppAttemptInfo(appAttemptReport);
        appAttemptsInfo.add(appAttemptInfo);
    }
    return appAttemptsInfo;
}
Also used : AppAttemptsInfo(org.apache.hadoop.yarn.server.webapp.dao.AppAttemptsInfo) AppAttemptInfo(org.apache.hadoop.yarn.server.webapp.dao.AppAttemptInfo) ApplicationAttemptReport(org.apache.hadoop.yarn.api.records.ApplicationAttemptReport) GetApplicationAttemptsRequest(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptsRequest) PrivilegedExceptionAction(java.security.PrivilegedExceptionAction) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) ForbiddenException(org.apache.hadoop.yarn.webapp.ForbiddenException) AuthorizationException(org.apache.hadoop.security.authorize.AuthorizationException) ContainerNotFoundException(org.apache.hadoop.yarn.exceptions.ContainerNotFoundException) NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException) ApplicationAttemptNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationAttemptNotFoundException) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) WebApplicationException(javax.ws.rs.WebApplicationException) ApplicationNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException) BadRequestException(org.apache.hadoop.yarn.webapp.BadRequestException) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation)

Aggregations

GetApplicationAttemptsRequest (org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptsRequest)6 GetApplicationAttemptsResponse (org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptsResponse)4 ApplicationAttemptReport (org.apache.hadoop.yarn.api.records.ApplicationAttemptReport)3 ApplicationNotFoundException (org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException)3 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)2 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)2 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)2 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)2 ContainerNotFoundException (org.apache.hadoop.yarn.exceptions.ContainerNotFoundException)2 Test (org.junit.Test)2 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 AuthenticationException (org.apache.hadoop.security.authentication.client.AuthenticationException)1 AuthorizationException (org.apache.hadoop.security.authorize.AuthorizationException)1 GetApplicationReportRequest (org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportRequest)1 ApplicationReport (org.apache.hadoop.yarn.api.records.ApplicationReport)1 ApplicationAttemptNotFoundException (org.apache.hadoop.yarn.exceptions.ApplicationAttemptNotFoundException)1 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)1 RecordFactory (org.apache.hadoop.yarn.factories.RecordFactory)1 AppAttemptInfo (org.apache.hadoop.yarn.server.webapp.dao.AppAttemptInfo)1