YARN-7414. FairScheduler#getAppWeight() should be moved into FSAppAttempt#getWeight()
(Contributed by Soumabrata Chakraborty via Daniel Templeton)
This commit is contained in:
parent
e094eb74b9
commit
b246c54749
|
@ -1304,7 +1304,20 @@ public class FSAppAttempt extends SchedulerApplicationAttempt
|
|||
|
||||
@Override
|
||||
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
|
||||
|
|
|
@ -368,21 +368,8 @@ public class FairScheduler extends
|
|||
return rmContext.getContainerTokenSecretManager();
|
||||
}
|
||||
|
||||
public float getAppWeight(FSAppAttempt app) {
|
||||
double weight = 1.0;
|
||||
|
||||
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 boolean isSizeBasedWeight() {
|
||||
return sizeBasedWeight;
|
||||
}
|
||||
|
||||
public Resource getIncrementResourceCapability() {
|
||||
|
|
Loading…
Reference in New Issue