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();
}
});
}
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());
}
Aggregations