Search in sources :

Example 1 with FSAppAttempt

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

the class FairSchedulerMetrics method trackApp.

@Override
public void trackApp(ApplicationAttemptId appAttemptId, String oldAppId) {
    super.trackApp(appAttemptId, oldAppId);
    FairScheduler fair = (FairScheduler) scheduler;
    final FSAppAttempt app = fair.getSchedulerApp(appAttemptId);
    metrics.register("variable.app." + oldAppId + ".demand.memory", new Gauge<Long>() {

        @Override
        public Long getValue() {
            return app.getDemand().getMemorySize();
        }
    });
    metrics.register("variable.app." + oldAppId + ".demand.vcores", new Gauge<Integer>() {

        @Override
        public Integer getValue() {
            return app.getDemand().getVirtualCores();
        }
    });
    metrics.register("variable.app." + oldAppId + ".usage.memory", new Gauge<Long>() {

        @Override
        public Long getValue() {
            return app.getResourceUsage().getMemorySize();
        }
    });
    metrics.register("variable.app." + oldAppId + ".usage.vcores", new Gauge<Integer>() {

        @Override
        public Integer getValue() {
            return app.getResourceUsage().getVirtualCores();
        }
    });
    metrics.register("variable.app." + oldAppId + ".minshare.memory", new Gauge<Long>() {

        @Override
        public Long getValue() {
            return app.getMinShare().getMemorySize();
        }
    });
    metrics.register("variable.app." + oldAppId + ".minshare.vcores", new Gauge<Long>() {

        @Override
        public Long getValue() {
            return app.getMinShare().getMemorySize();
        }
    });
    metrics.register("variable.app." + oldAppId + ".maxshare.memory", new Gauge<Long>() {

        @Override
        public Long getValue() {
            return Math.min(app.getMaxShare().getMemorySize(), totalMemoryMB);
        }
    });
    metrics.register("variable.app." + oldAppId + ".maxshare.vcores", new Gauge<Integer>() {

        @Override
        public Integer getValue() {
            return Math.min(app.getMaxShare().getVirtualCores(), totalVCores);
        }
    });
    metrics.register("variable.app." + oldAppId + ".fairshare.memory", new Gauge<Integer>() {

        @Override
        public Integer getValue() {
            return app.getFairShare().getVirtualCores();
        }
    });
    metrics.register("variable.app." + oldAppId + ".fairshare.vcores", new Gauge<Integer>() {

        @Override
        public Integer getValue() {
            return app.getFairShare().getVirtualCores();
        }
    });
}
Also used : FairScheduler(org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler) FSAppAttempt(org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FSAppAttempt)

Example 2 with FSAppAttempt

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

the class TestWorkPreservingRMRestart method checkFSQueue.

private void checkFSQueue(ResourceManager rm, SchedulerApplication schedulerApp, Resource usedResources, Resource availableResources) throws Exception {
    // waiting for RM's scheduling apps
    int retry = 0;
    Resource assumedFairShare = Resource.newInstance(8192, 8);
    while (true) {
        Thread.sleep(100);
        if (assumedFairShare.equals(((FairScheduler) rm.getResourceScheduler()).getQueueManager().getRootQueue().getFairShare())) {
            break;
        }
        retry++;
        if (retry > 30) {
            Assert.fail("Apps are not scheduled within assumed timeout");
        }
    }
    FairScheduler scheduler = (FairScheduler) rm.getResourceScheduler();
    FSParentQueue root = scheduler.getQueueManager().getRootQueue();
    // ************ check cluster used Resources ********
    assertTrue(root.getPolicy() instanceof DominantResourceFairnessPolicy);
    assertEquals(usedResources, root.getResourceUsage());
    // ************ check app headroom ****************
    FSAppAttempt schedulerAttempt = (FSAppAttempt) schedulerApp.getCurrentAppAttempt();
    assertEquals(availableResources, schedulerAttempt.getHeadroom());
    // ************ check queue metrics ****************
    QueueMetrics queueMetrics = scheduler.getRootQueueMetrics();
    assertMetrics(queueMetrics, 1, 0, 1, 0, 2, availableResources.getMemorySize(), availableResources.getVirtualCores(), usedResources.getMemorySize(), usedResources.getVirtualCores());
}
Also used : QueueMetrics(org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueMetrics) FairScheduler(org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler) FSAppAttempt(org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FSAppAttempt) Resource(org.apache.hadoop.yarn.api.records.Resource) DominantResourceFairnessPolicy(org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.policies.DominantResourceFairnessPolicy) FSParentQueue(org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FSParentQueue)

Aggregations

FSAppAttempt (org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FSAppAttempt)2 FairScheduler (org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler)2 Resource (org.apache.hadoop.yarn.api.records.Resource)1 QueueMetrics (org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueMetrics)1 FSParentQueue (org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FSParentQueue)1 DominantResourceFairnessPolicy (org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.policies.DominantResourceFairnessPolicy)1