Search in sources :

Example 11 with RMAppAttemptMetrics

use of org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptMetrics in project hadoop by apache.

the class RMAppAttemptBlock method createAttemptHeadRoomTable.

@Override
protected void createAttemptHeadRoomTable(Block html) {
    RMAppAttempt attempt = getRMAppAttempt();
    if (attempt != null) {
        if (!isApplicationInFinalState(YarnApplicationAttemptState.valueOf(attempt.getAppAttemptState().toString()))) {
            RMAppAttemptMetrics metrics = attempt.getRMAppAttemptMetrics();
            DIV<Hamlet> pdiv = html._(InfoBlock.class).div(_INFO_WRAP);
            info("Application Attempt Overview").clear();
            info("Application Attempt Metrics")._("Application Attempt Headroom : ", metrics == null ? "N/A" : metrics.getApplicationAttemptHeadroom());
            pdiv._();
        }
    }
}
Also used : InfoBlock(org.apache.hadoop.yarn.webapp.view.InfoBlock) Hamlet(org.apache.hadoop.yarn.webapp.hamlet.Hamlet) RMAppAttemptMetrics(org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptMetrics) RMAppAttempt(org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt)

Example 12 with RMAppAttemptMetrics

use of org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptMetrics in project hadoop by apache.

the class RMAppAttemptBlock method createContainerLocalityTable.

private void createContainerLocalityTable(Block html) {
    RMAppAttemptMetrics attemptMetrics = null;
    RMAppAttempt attempt = getRMAppAttempt();
    if (attempt != null) {
        attemptMetrics = attempt.getRMAppAttemptMetrics();
    }
    if (attemptMetrics == null) {
        return;
    }
    DIV<Hamlet> div = html.div(_INFO_WRAP);
    TABLE<DIV<Hamlet>> table = div.h3("Total Allocated Containers: " + attemptMetrics.getTotalAllocatedContainers()).h3("Each table cell" + " represents the number of NodeLocal/RackLocal/OffSwitch containers" + " satisfied by NodeLocal/RackLocal/OffSwitch resource requests.").table("#containerLocality");
    table.tr().th(_TH, "").th(_TH, "Node Local Request").th(_TH, "Rack Local Request").th(_TH, "Off Switch Request")._();
    String[] containersType = { "Num Node Local Containers (satisfied by)", "Num Rack Local Containers (satisfied by)", "Num Off Switch Containers (satisfied by)" };
    boolean odd = false;
    for (int i = 0; i < attemptMetrics.getLocalityStatistics().length; i++) {
        table.tr((odd = !odd) ? _ODD : _EVEN).td(containersType[i]).td(String.valueOf(attemptMetrics.getLocalityStatistics()[i][0])).td(i == 0 ? "" : String.valueOf(attemptMetrics.getLocalityStatistics()[i][1])).td(i <= 1 ? "" : String.valueOf(attemptMetrics.getLocalityStatistics()[i][2]))._();
    }
    table._();
    div._();
}
Also used : Hamlet(org.apache.hadoop.yarn.webapp.hamlet.Hamlet) DIV(org.apache.hadoop.yarn.webapp.hamlet.Hamlet.DIV) RMAppAttemptMetrics(org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptMetrics) RMAppAttempt(org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt)

Example 13 with RMAppAttemptMetrics

use of org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptMetrics in project hadoop by apache.

the class RMAppBlock method createApplicationMetricsTable.

@Override
protected void createApplicationMetricsTable(Block html) {
    RMApp rmApp = this.rm.getRMContext().getRMApps().get(appID);
    RMAppMetrics appMetrics = rmApp == null ? null : rmApp.getRMAppMetrics();
    // Get attempt metrics and fields, it is possible currentAttempt of RMApp is
    // null. In that case, we will assume resource preempted and number of Non
    // AM container preempted on that attempt is 0
    RMAppAttemptMetrics attemptMetrics;
    if (rmApp == null || null == rmApp.getCurrentAppAttempt()) {
        attemptMetrics = null;
    } else {
        attemptMetrics = rmApp.getCurrentAppAttempt().getRMAppAttemptMetrics();
    }
    Resource attemptResourcePreempted = attemptMetrics == null ? Resources.none() : attemptMetrics.getResourcePreempted();
    int attemptNumNonAMContainerPreempted = attemptMetrics == null ? 0 : attemptMetrics.getNumNonAMContainersPreempted();
    DIV<Hamlet> pdiv = html._(InfoBlock.class).div(_INFO_WRAP);
    info("Application Overview").clear();
    info("Application Metrics")._("Total Resource Preempted:", appMetrics == null ? "N/A" : appMetrics.getResourcePreempted())._("Total Number of Non-AM Containers Preempted:", appMetrics == null ? "N/A" : appMetrics.getNumNonAMContainersPreempted())._("Total Number of AM Containers Preempted:", appMetrics == null ? "N/A" : appMetrics.getNumAMContainersPreempted())._("Resource Preempted from Current Attempt:", attemptResourcePreempted)._("Number of Non-AM Containers Preempted from Current Attempt:", attemptNumNonAMContainerPreempted)._("Aggregate Resource Allocation:", String.format("%d MB-seconds, %d vcore-seconds", appMetrics == null ? "N/A" : appMetrics.getMemorySeconds(), appMetrics == null ? "N/A" : appMetrics.getVcoreSeconds()))._("Aggregate Preempted Resource Allocation:", String.format("%d MB-seconds, %d vcore-seconds", appMetrics == null ? "N/A" : appMetrics.getPreemptedMemorySeconds(), appMetrics == null ? "N/A" : appMetrics.getPreemptedVcoreSeconds()));
    pdiv._();
}
Also used : InfoBlock(org.apache.hadoop.yarn.webapp.view.InfoBlock) Hamlet(org.apache.hadoop.yarn.webapp.hamlet.Hamlet) RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) RMAppAttemptMetrics(org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptMetrics) RMAppMetrics(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppMetrics) Resource(org.apache.hadoop.yarn.api.records.Resource)

Example 14 with RMAppAttemptMetrics

use of org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptMetrics in project hadoop by apache.

the class RMAppImpl method getRMAppMetrics.

@Override
public RMAppMetrics getRMAppMetrics() {
    Resource resourcePreempted = Resource.newInstance(0, 0);
    int numAMContainerPreempted = 0;
    int numNonAMContainerPreempted = 0;
    long memorySeconds = 0;
    long vcoreSeconds = 0;
    long preemptedMemorySeconds = 0;
    long preemptedVcoreSeconds = 0;
    for (RMAppAttempt attempt : attempts.values()) {
        if (null != attempt) {
            RMAppAttemptMetrics attemptMetrics = attempt.getRMAppAttemptMetrics();
            Resources.addTo(resourcePreempted, attemptMetrics.getResourcePreempted());
            numAMContainerPreempted += attemptMetrics.getIsPreempted() ? 1 : 0;
            numNonAMContainerPreempted += attemptMetrics.getNumNonAMContainersPreempted();
            // getAggregateAppResourceUsage() will calculate resource usage stats
            // for both running and finished containers.
            AggregateAppResourceUsage resUsage = attempt.getRMAppAttemptMetrics().getAggregateAppResourceUsage();
            memorySeconds += resUsage.getMemorySeconds();
            vcoreSeconds += resUsage.getVcoreSeconds();
            preemptedMemorySeconds += attemptMetrics.getPreemptedMemory();
            preemptedVcoreSeconds += attemptMetrics.getPreemptedVcore();
        }
    }
    return new RMAppMetrics(resourcePreempted, numNonAMContainerPreempted, numAMContainerPreempted, memorySeconds, vcoreSeconds, preemptedMemorySeconds, preemptedVcoreSeconds);
}
Also used : RMAppAttemptMetrics(org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptMetrics) RMAppAttempt(org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt) Resource(org.apache.hadoop.yarn.api.records.Resource) AggregateAppResourceUsage(org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.AggregateAppResourceUsage)

Example 15 with RMAppAttemptMetrics

use of org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptMetrics in project hadoop by apache.

the class FairSchedulerTestBase method createSchedulingRequest.

protected ApplicationAttemptId createSchedulingRequest(int memory, int vcores, String queueId, String userId, int numContainers, int priority) {
    ApplicationAttemptId id = createAppAttemptId(this.APP_ID++, this.ATTEMPT_ID++);
    scheduler.addApplication(id.getApplicationId(), queueId, userId, false);
    // and no app is added.
    if (scheduler.getSchedulerApplications().containsKey(id.getApplicationId())) {
        scheduler.addApplicationAttempt(id, false, false);
    }
    List<ResourceRequest> ask = new ArrayList<ResourceRequest>();
    ResourceRequest request = createResourceRequest(memory, vcores, ResourceRequest.ANY, priority, numContainers, true);
    ask.add(request);
    RMApp rmApp = mock(RMApp.class);
    RMAppAttempt rmAppAttempt = mock(RMAppAttempt.class);
    when(rmApp.getCurrentAppAttempt()).thenReturn(rmAppAttempt);
    when(rmAppAttempt.getRMAppAttemptMetrics()).thenReturn(new RMAppAttemptMetrics(id, resourceManager.getRMContext()));
    ApplicationSubmissionContext submissionContext = mock(ApplicationSubmissionContext.class);
    when(submissionContext.getUnmanagedAM()).thenReturn(false);
    when(rmAppAttempt.getSubmissionContext()).thenReturn(submissionContext);
    Container container = mock(Container.class);
    when(rmAppAttempt.getMasterContainer()).thenReturn(container);
    resourceManager.getRMContext().getRMApps().put(id.getApplicationId(), rmApp);
    scheduler.allocate(id, ask, new ArrayList<ContainerId>(), null, null, NULL_UPDATE_REQUESTS);
    scheduler.update();
    return id;
}
Also used : RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) RMAppAttemptMetrics(org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptMetrics) Container(org.apache.hadoop.yarn.api.records.Container) RMAppAttempt(org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) ArrayList(java.util.ArrayList) ApplicationSubmissionContext(org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId) ResourceRequest(org.apache.hadoop.yarn.api.records.ResourceRequest)

Aggregations

RMAppAttemptMetrics (org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptMetrics)22 ApplicationSubmissionContext (org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext)13 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)12 Container (org.apache.hadoop.yarn.api.records.Container)10 RMAppAttemptImpl (org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptImpl)10 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)9 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)9 RMAppImpl (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppImpl)9 Test (org.junit.Test)9 MockRM (org.apache.hadoop.yarn.server.resourcemanager.MockRM)8 RMAppAttempt (org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt)8 AppAddedSchedulerEvent (org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppAddedSchedulerEvent)8 AppAttemptAddedSchedulerEvent (org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppAttemptAddedSchedulerEvent)8 AppAttemptRemovedSchedulerEvent (org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppAttemptRemovedSchedulerEvent)8 NodeAddedSchedulerEvent (org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeAddedSchedulerEvent)8 SchedulerEvent (org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.SchedulerEvent)8 Configuration (org.apache.hadoop.conf.Configuration)7 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)7 RMContainer (org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer)7 ContainerExpiredSchedulerEvent (org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.ContainerExpiredSchedulerEvent)7