Search in sources :

Example 26 with ApplicationAttemptReport

use of org.apache.hadoop.yarn.api.records.ApplicationAttemptReport in project hadoop by apache.

the class WebServices method getAppAttempt.

public AppAttemptInfo getAppAttempt(HttpServletRequest req, HttpServletResponse res, String appId, String appAttemptId) {
    UserGroupInformation callerUGI = getUser(req);
    ApplicationId aid = parseApplicationId(appId);
    final ApplicationAttemptId aaid = parseApplicationAttemptId(appAttemptId);
    validateIds(aid, aaid, null);
    ApplicationAttemptReport appAttempt = null;
    try {
        if (callerUGI == null) {
            GetApplicationAttemptReportRequest request = GetApplicationAttemptReportRequest.newInstance(aaid);
            appAttempt = appBaseProt.getApplicationAttemptReport(request).getApplicationAttemptReport();
        } else {
            appAttempt = callerUGI.doAs(new PrivilegedExceptionAction<ApplicationAttemptReport>() {

                @Override
                public ApplicationAttemptReport run() throws Exception {
                    GetApplicationAttemptReportRequest request = GetApplicationAttemptReportRequest.newInstance(aaid);
                    return appBaseProt.getApplicationAttemptReport(request).getApplicationAttemptReport();
                }
            });
        }
    } catch (Exception e) {
        rewrapAndThrowException(e);
    }
    if (appAttempt == null) {
        throw new NotFoundException("app attempt with id: " + appAttemptId + " not found");
    }
    return new AppAttemptInfo(appAttempt);
}
Also used : AppAttemptInfo(org.apache.hadoop.yarn.server.webapp.dao.AppAttemptInfo) ApplicationAttemptReport(org.apache.hadoop.yarn.api.records.ApplicationAttemptReport) GetApplicationAttemptReportRequest(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportRequest) ContainerNotFoundException(org.apache.hadoop.yarn.exceptions.ContainerNotFoundException) NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException) ApplicationAttemptNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationAttemptNotFoundException) ApplicationNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId) 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)

Example 27 with ApplicationAttemptReport

use of org.apache.hadoop.yarn.api.records.ApplicationAttemptReport 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)

Example 28 with ApplicationAttemptReport

use of org.apache.hadoop.yarn.api.records.ApplicationAttemptReport in project hadoop by apache.

the class MockResourceManagerFacade method getApplicationAttemptReport.

@Override
public GetApplicationAttemptReportResponse getApplicationAttemptReport(GetApplicationAttemptReportRequest request) throws YarnException, IOException {
    GetApplicationAttemptReportResponse response = Records.newRecord(GetApplicationAttemptReportResponse.class);
    ApplicationAttemptReport report = Records.newRecord(ApplicationAttemptReport.class);
    report.setApplicationAttemptId(request.getApplicationAttemptId());
    report.setYarnApplicationAttemptState(YarnApplicationAttemptState.LAUNCHED);
    response.setApplicationAttemptReport(report);
    return response;
}
Also used : ApplicationAttemptReport(org.apache.hadoop.yarn.api.records.ApplicationAttemptReport) GetApplicationAttemptReportResponse(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportResponse)

Example 29 with ApplicationAttemptReport

use of org.apache.hadoop.yarn.api.records.ApplicationAttemptReport in project hadoop by apache.

the class RMAppAttemptImpl method createApplicationAttemptReport.

@Override
public ApplicationAttemptReport createApplicationAttemptReport() {
    this.readLock.lock();
    ApplicationAttemptReport attemptReport = null;
    try {
        // AM container maybe not yet allocated. and also unmangedAM doesn't have
        // am container.
        ContainerId amId = masterContainer == null ? null : masterContainer.getId();
        attemptReport = ApplicationAttemptReport.newInstance(this.getAppAttemptId(), this.getHost(), this.getRpcPort(), this.getTrackingUrl(), this.getOriginalTrackingUrl(), this.getDiagnostics(), createApplicationAttemptState(), amId, this.startTime, this.finishTime);
    } finally {
        this.readLock.unlock();
    }
    return attemptReport;
}
Also used : ApplicationAttemptReport(org.apache.hadoop.yarn.api.records.ApplicationAttemptReport) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId)

Example 30 with ApplicationAttemptReport

use of org.apache.hadoop.yarn.api.records.ApplicationAttemptReport in project hadoop by apache.

the class LogsCLI method getContainerReportsFromRunningApplication.

private List<ContainerReport> getContainerReportsFromRunningApplication(ContainerLogsRequest options) throws YarnException, IOException {
    List<ContainerReport> reports = new ArrayList<ContainerReport>();
    List<ApplicationAttemptReport> attempts = yarnClient.getApplicationAttempts(options.getAppId());
    Map<ContainerId, ContainerReport> containerMap = new TreeMap<ContainerId, ContainerReport>();
    for (ApplicationAttemptReport attempt : attempts) {
        List<ContainerReport> containers = yarnClient.getContainers(attempt.getApplicationAttemptId());
        for (ContainerReport container : containers) {
            if (!containerMap.containsKey(container.getContainerId())) {
                containerMap.put(container.getContainerId(), container);
            }
        }
    }
    reports.addAll(containerMap.values());
    return reports;
}
Also used : ApplicationAttemptReport(org.apache.hadoop.yarn.api.records.ApplicationAttemptReport) ContainerReport(org.apache.hadoop.yarn.api.records.ContainerReport) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) ArrayList(java.util.ArrayList) TreeMap(java.util.TreeMap)

Aggregations

ApplicationAttemptReport (org.apache.hadoop.yarn.api.records.ApplicationAttemptReport)35 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)18 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)17 Test (org.junit.Test)15 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)8 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)7 Configuration (org.apache.hadoop.conf.Configuration)6 ApplicationReport (org.apache.hadoop.yarn.api.records.ApplicationReport)6 AuthorizationException (org.apache.hadoop.security.authorize.AuthorizationException)5 ContainerReport (org.apache.hadoop.yarn.api.records.ContainerReport)5 YarnClient (org.apache.hadoop.yarn.client.api.YarnClient)5 ApplicationAttemptNotFoundException (org.apache.hadoop.yarn.exceptions.ApplicationAttemptNotFoundException)5 ApplicationNotFoundException (org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException)5 PrintWriter (java.io.PrintWriter)4 ArrayList (java.util.ArrayList)4 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)4 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)4 ContainerNotFoundException (org.apache.hadoop.yarn.exceptions.ContainerNotFoundException)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 GetApplicationAttemptReportRequest (org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportRequest)3