Search in sources :

Example 6 with ApplicationAttemptReport

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

the class TestYarnClient method testGetApplicationAttempt.

@Test(timeout = 10000)
public void testGetApplicationAttempt() throws YarnException, IOException {
    Configuration conf = new Configuration();
    final YarnClient client = new MockYarnClient();
    client.init(conf);
    client.start();
    List<ApplicationReport> expectedReports = ((MockYarnClient) client).getReports();
    ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
    ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(applicationId, 1);
    ApplicationAttemptReport report = client.getApplicationAttemptReport(appAttemptId);
    Assert.assertNotNull(report);
    Assert.assertEquals(report.getApplicationAttemptId().toString(), expectedReports.get(0).getCurrentApplicationAttemptId().toString());
    client.stop();
}
Also used : ApplicationReport(org.apache.hadoop.yarn.api.records.ApplicationReport) ApplicationAttemptReport(org.apache.hadoop.yarn.api.records.ApplicationAttemptReport) CapacitySchedulerConfiguration(org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration) Configuration(org.apache.hadoop.conf.Configuration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) YarnClient(org.apache.hadoop.yarn.client.api.YarnClient) Test(org.junit.Test)

Example 7 with ApplicationAttemptReport

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

the class ClientRMService method getApplicationAttempts.

@Override
public GetApplicationAttemptsResponse getApplicationAttempts(GetApplicationAttemptsRequest request) throws YarnException, IOException {
    ApplicationId appId = request.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);
    GetApplicationAttemptsResponse response = null;
    if (allowAccess) {
        Map<ApplicationAttemptId, RMAppAttempt> attempts = application.getAppAttempts();
        List<ApplicationAttemptReport> listAttempts = new ArrayList<ApplicationAttemptReport>();
        Iterator<Map.Entry<ApplicationAttemptId, RMAppAttempt>> iter = attempts.entrySet().iterator();
        while (iter.hasNext()) {
            listAttempts.add(iter.next().getValue().createApplicationAttemptReport());
        }
        response = GetApplicationAttemptsResponse.newInstance(listAttempts);
    } 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) ApplicationAttemptReport(org.apache.hadoop.yarn.api.records.ApplicationAttemptReport) ArrayList(java.util.ArrayList) IOException(java.io.IOException) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) ApplicationNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) GetApplicationAttemptsResponse(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptsResponse) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation)

Example 8 with ApplicationAttemptReport

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

the class ClientRMService method getApplicationAttemptReport.

@Override
public GetApplicationAttemptReportResponse getApplicationAttemptReport(GetApplicationAttemptReportRequest request) throws YarnException, IOException {
    ApplicationAttemptId appAttemptId = request.getApplicationAttemptId();
    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(appAttemptId.getApplicationId());
    if (application == null) {
        // ApplicationNotFoundException and let client to handle.
        throw new ApplicationNotFoundException("Application with id '" + request.getApplicationAttemptId().getApplicationId() + "' doesn't exist in RM. Please check that the job " + "submission was successful.");
    }
    boolean allowAccess = checkAccess(callerUGI, application.getUser(), ApplicationAccessType.VIEW_APP, application);
    GetApplicationAttemptReportResponse 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.");
        }
        ApplicationAttemptReport attemptReport = appAttempt.createApplicationAttemptReport();
        response = GetApplicationAttemptReportResponse.newInstance(attemptReport);
    } else {
        throw new YarnException("User " + callerUGI.getShortUserName() + " does not have privilege to see this attempt " + appAttemptId);
    }
    return response;
}
Also used : RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) RMAppAttempt(org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt) ApplicationAttemptReport(org.apache.hadoop.yarn.api.records.ApplicationAttemptReport) ApplicationNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException) GetApplicationAttemptReportResponse(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportResponse) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId) IOException(java.io.IOException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) ApplicationAttemptNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationAttemptNotFoundException)

Example 9 with ApplicationAttemptReport

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

the class RMAppBlock method generateApplicationTable.

@Override
protected void generateApplicationTable(Block html, UserGroupInformation callerUGI, Collection<ApplicationAttemptReport> attempts) {
    // Application Attempt Table
    Hamlet.TBODY<Hamlet.TABLE<Hamlet>> tbody = html.table("#attempts").thead().tr().th(".id", "Attempt ID").th(".started", "Started").th(".node", "Node").th(".logs", "Logs").th(".appBlacklistednodes", "Nodes blacklisted by the application", "Nodes blacklisted by the app").th(".rmBlacklistednodes", "Nodes blacklisted by the RM for the" + " app", "Nodes blacklisted by the system")._()._().tbody();
    RMApp rmApp = this.rm.getRMContext().getRMApps().get(this.appID);
    if (rmApp == null) {
        return;
    }
    StringBuilder attemptsTableData = new StringBuilder("[\n");
    for (final ApplicationAttemptReport appAttemptReport : attempts) {
        RMAppAttempt rmAppAttempt = rmApp.getRMAppAttempt(appAttemptReport.getApplicationAttemptId());
        if (rmAppAttempt == null) {
            continue;
        }
        AppAttemptInfo attemptInfo = new AppAttemptInfo(this.rm, rmAppAttempt, rmApp.getUser(), WebAppUtils.getHttpSchemePrefix(conf));
        Set<String> nodes = rmAppAttempt.getBlacklistedNodes();
        // nodes which are blacklisted by the application
        String appBlacklistedNodesCount = String.valueOf(nodes.size());
        // nodes which are blacklisted by the RM for AM launches
        String rmBlacklistedNodesCount = String.valueOf(rmAppAttempt.getAMBlacklistManager().getBlacklistUpdates().getBlacklistAdditions().size());
        String nodeLink = attemptInfo.getNodeHttpAddress();
        if (nodeLink != null) {
            nodeLink = WebAppUtils.getHttpSchemePrefix(conf) + nodeLink;
        }
        String logsLink = attemptInfo.getLogsLink();
        attemptsTableData.append("[\"<a href='").append(url("appattempt", rmAppAttempt.getAppAttemptId().toString())).append("'>").append(String.valueOf(rmAppAttempt.getAppAttemptId())).append("</a>\",\"").append(attemptInfo.getStartTime()).append("\",\"<a ").append(nodeLink == null ? "#" : "href='" + nodeLink).append("'>").append(nodeLink == null ? "N/A" : StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(nodeLink))).append("</a>\",\"<a ").append(logsLink == null ? "#" : "href='" + logsLink).append("'>").append(logsLink == null ? "N/A" : "Logs").append("</a>\",").append("\"").append(appBlacklistedNodesCount).append("\",").append("\"").append(rmBlacklistedNodesCount).append("\"],\n");
    }
    if (attemptsTableData.charAt(attemptsTableData.length() - 2) == ',') {
        attemptsTableData.delete(attemptsTableData.length() - 2, attemptsTableData.length() - 1);
    }
    attemptsTableData.append("]");
    html.script().$type("text/javascript")._("var attemptsTableData=" + attemptsTableData)._();
    tbody._()._();
}
Also used : Hamlet(org.apache.hadoop.yarn.webapp.hamlet.Hamlet) RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) AppAttemptInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppAttemptInfo) ApplicationAttemptReport(org.apache.hadoop.yarn.api.records.ApplicationAttemptReport) RMAppAttempt(org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt)

Example 10 with ApplicationAttemptReport

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

the class TestApplicationHistoryClientService method testApplicationAttemptReport.

@Test
public void testApplicationAttemptReport() throws IOException, YarnException {
    ApplicationId appId = ApplicationId.newInstance(0, 1);
    ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 1);
    GetApplicationAttemptReportRequest request = GetApplicationAttemptReportRequest.newInstance(appAttemptId);
    GetApplicationAttemptReportResponse response = clientService.getApplicationAttemptReport(request);
    ApplicationAttemptReport attemptReport = response.getApplicationAttemptReport();
    Assert.assertNotNull(attemptReport);
    Assert.assertEquals("appattempt_0_0001_000001", attemptReport.getApplicationAttemptId().toString());
}
Also used : ApplicationAttemptReport(org.apache.hadoop.yarn.api.records.ApplicationAttemptReport) GetApplicationAttemptReportRequest(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportRequest) GetApplicationAttemptReportResponse(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportResponse) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) Test(org.junit.Test)

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