Search in sources :

Example 6 with GetContainerReportResponse

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

the class ClientRMService method getContainerReport.

/*
   * (non-Javadoc)
   * 
   * we're going to fix the issue of showing non-running containers of the
   * running application in YARN-1794
   */
@Override
public GetContainerReportResponse getContainerReport(GetContainerReportRequest request) throws YarnException, IOException {
    ContainerId containerId = request.getContainerId();
    ApplicationAttemptId appAttemptId = containerId.getApplicationAttemptId();
    ApplicationId appId = appAttemptId.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);
    GetContainerReportResponse 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.");
        }
        RMContainer rmConatiner = this.rmContext.getScheduler().getRMContainer(containerId);
        if (rmConatiner == null) {
            throw new ContainerNotFoundException("Container with id '" + containerId + "' doesn't exist in RM.");
        }
        response = GetContainerReportResponse.newInstance(rmConatiner.createContainerReport());
    } else {
        throw new YarnException("User " + callerUGI.getShortUserName() + " does not have privilege to see this application " + appId);
    }
    return response;
}
Also used : RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) RMAppAttempt(org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId) IOException(java.io.IOException) RMContainer(org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) ApplicationAttemptNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationAttemptNotFoundException) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) ApplicationNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException) GetContainerReportResponse(org.apache.hadoop.yarn.api.protocolrecords.GetContainerReportResponse) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) ContainerNotFoundException(org.apache.hadoop.yarn.exceptions.ContainerNotFoundException) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation)

Aggregations

GetContainerReportResponse (org.apache.hadoop.yarn.api.protocolrecords.GetContainerReportResponse)6 GetContainerReportRequest (org.apache.hadoop.yarn.api.protocolrecords.GetContainerReportRequest)5 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)4 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)4 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)3 ApplicationNotFoundException (org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException)3 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)3 Test (org.junit.Test)3 IOException (java.io.IOException)2 ApplicationAttemptNotFoundException (org.apache.hadoop.yarn.exceptions.ApplicationAttemptNotFoundException)2 ContainerNotFoundException (org.apache.hadoop.yarn.exceptions.ContainerNotFoundException)2 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)1 ContainerReport (org.apache.hadoop.yarn.api.records.ContainerReport)1 RecordFactory (org.apache.hadoop.yarn.factories.RecordFactory)1 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)1 RMAppAttempt (org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt)1 RMContainer (org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer)1