Search in sources :

Example 11 with SchedulerAppReport

use of org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerAppReport in project hadoop by apache.

the class ClientRMService method getContainers.

/*
   * (non-Javadoc)
   * 
   * we're going to fix the issue of showing non-running containers of the
   * running application in YARN-1794"
   */
@Override
public GetContainersResponse getContainers(GetContainersRequest request) throws YarnException, IOException {
    ApplicationAttemptId appAttemptId = request.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);
    GetContainersResponse 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.");
        }
        Collection<RMContainer> rmContainers = Collections.emptyList();
        SchedulerAppReport schedulerAppReport = this.rmContext.getScheduler().getSchedulerAppInfo(appAttemptId);
        if (schedulerAppReport != null) {
            rmContainers = schedulerAppReport.getLiveContainers();
        }
        List<ContainerReport> listContainers = new ArrayList<ContainerReport>();
        for (RMContainer rmContainer : rmContainers) {
            listContainers.add(rmContainer.createContainerReport());
        }
        response = GetContainersResponse.newInstance(listContainers);
    } 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) ArrayList(java.util.ArrayList) GetContainersResponse(org.apache.hadoop.yarn.api.protocolrecords.GetContainersResponse) 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) ApplicationNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException) ContainerReport(org.apache.hadoop.yarn.api.records.ContainerReport) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) SchedulerAppReport(org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerAppReport) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation)

Aggregations

SchedulerAppReport (org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerAppReport)11 RMContainer (org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer)9 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)7 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)6 Resource (org.apache.hadoop.yarn.api.records.Resource)5 ArrayList (java.util.ArrayList)4 ResourceRequest (org.apache.hadoop.yarn.api.records.ResourceRequest)4 Container (org.apache.hadoop.yarn.api.records.Container)3 ContainerStatus (org.apache.hadoop.yarn.api.records.ContainerStatus)3 AppAddedSchedulerEvent (org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppAddedSchedulerEvent)3 AppAttemptAddedSchedulerEvent (org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppAttemptAddedSchedulerEvent)3 NodeUpdateSchedulerEvent (org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeUpdateSchedulerEvent)3 Counter (com.codahale.metrics.Counter)2 Timer (com.codahale.metrics.Timer)2 HashSet (java.util.HashSet)2 Configuration (org.apache.hadoop.conf.Configuration)2 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)2 AsyncDispatcher (org.apache.hadoop.yarn.event.AsyncDispatcher)2 InlineDispatcher (org.apache.hadoop.yarn.event.InlineDispatcher)2 UpdateNodeResourceRequest (org.apache.hadoop.yarn.server.api.protocolrecords.UpdateNodeResourceRequest)2