ruanwenjun commented on code in PR #13896:
URL:
https://github.com/apache/dolphinscheduler/pull/13896#discussion_r1161403292
##########
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:
Thanks, done.
##########
dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/task/WorkerHeartBeatTask.java:
##########
@@ -90,16 +88,16 @@ public void writeHeartBeat(WorkerHeartBeat workerHeartBeat)
{
workerRegistryPath, workerHeartBeatJson);
}
- public int getServerStatus(double loadAverage,
- double maxCpuloadAvg,
+ public int getServerStatus(double cpuUsagePercentage,
+ double maxCpuUsePercentage,
double availablePhysicalMemorySize,
double reservedMemory,
int workerExecThreadCount,
int workerWaitingTaskCount) {
- if (loadAverage > maxCpuloadAvg || availablePhysicalMemorySize <
reservedMemory) {
+ if (cpuUsagePercentage > maxCpuUsePercentage ||
availablePhysicalMemorySize < reservedMemory) {
Review Comment:
Done
--
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]