YARN-7414. FairScheduler#getAppWeight() should be moved into FSAppAttempt#getWeight()

(Contributed by Soumabrata Chakraborty via Daniel Templeton)
This commit is contained in:
Daniel Templeton 2017-11-15 09:56:37 -08:00
parent e094eb74b9
commit b246c54749
2 changed files with 16 additions and 16 deletions

View File

@ -1304,7 +1304,20 @@ public Resource getResourceUsage() {
@Override @Override
public float getWeight() { public float getWeight() {
return scheduler.getAppWeight(this); double weight = 1.0;
if (scheduler.isSizeBasedWeight()) {
scheduler.getSchedulerReadLock().lock();
try {
// Set weight based on current memory demand
weight = Math.log1p(getDemand().getMemorySize()) / Math.log(2);
} finally {
scheduler.getSchedulerReadLock().unlock();
}
}
return (float)weight * this.getPriority().getPriority();
} }
@Override @Override

View File

@ -368,21 +368,8 @@ public void update() {
return rmContext.getContainerTokenSecretManager(); return rmContext.getContainerTokenSecretManager();
} }
public float getAppWeight(FSAppAttempt app) { public boolean isSizeBasedWeight() {
double weight = 1.0; return sizeBasedWeight;
if (sizeBasedWeight) {
readLock.lock();
try {
// Set weight based on current memory demand
weight = Math.log1p(app.getDemand().getMemorySize()) / Math.log(2);
} finally {
readLock.unlock();
}
}
return (float)weight * app.getPriority().getPriority();
} }
public Resource getIncrementResourceCapability() { public Resource getIncrementResourceCapability() {