YARN-4895. Add subtractFrom method to ResourceUtilization class. Contributed by Konstantinos Karanasos.
This commit is contained in:
parent
256c82fe29
commit
82621e38a0
|
@ -44,6 +44,14 @@ public abstract class ResourceUtilization implements
|
||||||
return utilization;
|
return utilization;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Public
|
||||||
|
@Unstable
|
||||||
|
public static ResourceUtilization newInstance(
|
||||||
|
ResourceUtilization resourceUtil) {
|
||||||
|
return newInstance(resourceUtil.getPhysicalMemory(),
|
||||||
|
resourceUtil.getVirtualMemory(), resourceUtil.getCPU());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get used <em>virtual memory</em>.
|
* Get used <em>virtual memory</em>.
|
||||||
*
|
*
|
||||||
|
@ -147,4 +155,18 @@ public abstract class ResourceUtilization implements
|
||||||
this.setVirtualMemory(this.getVirtualMemory() + vmem);
|
this.setVirtualMemory(this.getVirtualMemory() + vmem);
|
||||||
this.setCPU(this.getCPU() + cpu);
|
this.setCPU(this.getCPU() + cpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subtract utilization from the current one.
|
||||||
|
* @param pmem Physical memory to be subtracted.
|
||||||
|
* @param vmem Virtual memory to be subtracted.
|
||||||
|
* @param cpu CPU utilization to be subtracted.
|
||||||
|
*/
|
||||||
|
@Public
|
||||||
|
@Unstable
|
||||||
|
public void subtractFrom(int pmem, int vmem, float cpu) {
|
||||||
|
this.setPhysicalMemory(this.getPhysicalMemory() - pmem);
|
||||||
|
this.setVirtualMemory(this.getVirtualMemory() - vmem);
|
||||||
|
this.setCPU(this.getCPU() - cpu);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue