YARN-2768. Avoid cloning Resource in FSAppAttempt#updateDemand. (Hong Zhiguo via kasha)
This commit is contained in:
parent
6f0a35724f
commit
5205a330b3
|
@ -378,6 +378,9 @@ Release 2.8.0 - UNRELEASED
|
|||
YARN-3259. FairScheduler: Trigger fairShare updates on node events.
|
||||
(Anubhav Dhoot via kasha)
|
||||
|
||||
YARN-2768. Avoid cloning Resource in FSAppAttempt#updateDemand.
|
||||
(Hong Zhiguo via kasha)
|
||||
|
||||
BUG FIXES
|
||||
|
||||
YARN-3197. Confusing log generated by CapacityScheduler. (Varun Saxena
|
||||
|
|
|
@ -150,7 +150,19 @@ public class Resources {
|
|||
public static Resource multiply(Resource lhs, double by) {
|
||||
return multiplyTo(clone(lhs), by);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Multiply @param rhs by @param by, and add the result to @param lhs
|
||||
* without creating any new {@link Resource} object
|
||||
*/
|
||||
public static Resource multiplyAndAddTo(
|
||||
Resource lhs, Resource rhs, double by) {
|
||||
lhs.setMemory(lhs.getMemory() + (int)(rhs.getMemory() * by));
|
||||
lhs.setVirtualCores(lhs.getVirtualCores()
|
||||
+ (int)(rhs.getVirtualCores() * by));
|
||||
return lhs;
|
||||
}
|
||||
|
||||
public static Resource multiplyAndNormalizeUp(
|
||||
ResourceCalculator calculator,Resource lhs, double by, Resource factor) {
|
||||
return calculator.multiplyAndNormalizeUp(lhs, by, factor);
|
||||
|
|
|
@ -801,8 +801,8 @@ public class FSAppAttempt extends SchedulerApplicationAttempt
|
|||
synchronized (this) {
|
||||
for (Priority p : getPriorities()) {
|
||||
for (ResourceRequest r : getResourceRequests(p).values()) {
|
||||
Resource total = Resources.multiply(r.getCapability(), r.getNumContainers());
|
||||
Resources.addTo(demand, total);
|
||||
Resources.multiplyAndAddTo(demand,
|
||||
r.getCapability(), r.getNumContainers());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue