Radeity commented on code in PR #13896:
URL:
https://github.com/apache/dolphinscheduler/pull/13896#discussion_r1161304232
##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/OSUtils.java:
##########
@@ -466,23 +433,25 @@ public static int getProcessID() {
/**
* Check memory and cpu usage is overload the given thredshod.
*
- * @param maxCpuLoadAvg maxCpuLoadAvg
- * @param reservedMemory reservedMemory
+ * @param maxCpuLoadAvgThreshold maxCpuLoadAvg
+ * @param reservedMemoryThreshold reservedMemory
* @return True, if the cpu or memory exceed the given thredshod.
*/
- public static Boolean isOverload(double maxCpuLoadAvg, double
reservedMemory) {
+ public static Boolean isOverload(double maxCpuLoadAvgThreshold, double
reservedMemoryThreshold) {
// system load average
- double loadAverage = loadAverage();
+ double freeCPUPercentage = 1 - cpuUsagePercentage();
// system available physical memory
- double availablePhysicalMemorySize = availablePhysicalMemorySize();
- if (loadAverage > maxCpuLoadAvg) {
- log.warn("Current cpu load average {} is too high,
max.cpuLoad.avg={}", loadAverage, maxCpuLoadAvg);
+ double freeMemoryPercentage = 1 - memoryUsagePercentage();
+ if (freeCPUPercentage > maxCpuLoadAvgThreshold) {
+ log.warn("Current cpu load average {} is too high,
max.cpuLoad.avg={}", freeCPUPercentage,
+ maxCpuLoadAvgThreshold);
return true;
}
- if (availablePhysicalMemorySize < reservedMemory) {
+ if (freeMemoryPercentage < reservedMemoryThreshold) {
log.warn(
- "Current available memory {}G is too low,
reserved.memory={}G", maxCpuLoadAvg, reservedMemory);
+ "Current available memory percentage{} is too low,
reserved.memory={}", freeMemoryPercentage,
+ reservedMemoryThreshold);
Review Comment:
The unit of `reservedMemory ` is still GB, if you also want to change the
memory representation to percentage, you may have to modify the check in
`getServerStatus `.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]