|
@@ -71,20 +71,17 @@ public class SystemMetrics implements OmsSerializable, Comparable<SystemMetrics>
|
|
|
* @return score
|
|
|
*/
|
|
|
public int calculateScore() {
|
|
|
-
|
|
|
- if (score > 0) {
|
|
|
- return score;
|
|
|
- }
|
|
|
-
|
|
|
- // Memory is vital to TaskTracker, so we set the multiplier factor as 2.
|
|
|
- double memScore = (jvmMaxMemory - jvmUsedMemory) * 2;
|
|
|
- // Calculate the remaining load of CPU. Multiplier is set as 1.
|
|
|
- double cpuScore = cpuProcessors - cpuLoad;
|
|
|
- // Windows can not fetch CPU load, set cpuScore as 1.
|
|
|
- if (cpuScore > cpuProcessors) {
|
|
|
- cpuScore = 1;
|
|
|
+ if (score > 0) {
|
|
|
+ return score;
|
|
|
+ }
|
|
|
+ // Memory is vital to TaskTracker, so we set the multiplier factor as 2.
|
|
|
+ double memScore = (jvmMaxMemory - jvmUsedMemory) * 2;
|
|
|
+ // Calculate the remaining load of CPU. Multiplier is set as 1.
|
|
|
+ double cpuScore = cpuProcessors - cpuLoad;
|
|
|
+ // Windows can not fetch CPU load, set cpuScore as 1.
|
|
|
+ if (cpuScore > cpuProcessors) {
|
|
|
+ cpuScore = 1;
|
|
|
}
|
|
|
-
|
|
|
score = (int) (memScore + cpuScore);
|
|
|
return score;
|
|
|
}
|
|
@@ -93,8 +90,8 @@ public class SystemMetrics implements OmsSerializable, Comparable<SystemMetrics>
|
|
|
* Judge if the machine is available.
|
|
|
*
|
|
|
* @param minCPUCores Minimum available CPU cores.
|
|
|
- * @param minMemorySpace 判断标准之最低可用内存
|
|
|
- * @param minDiskSpace Minimum disk space 判断标准之最低可用磁盘空间
|
|
|
+ * @param minMemorySpace Minimum available memory size
|
|
|
+ * @param minDiskSpace Minimum disk space
|
|
|
* @return {@code boolean} whether the machine is available.
|
|
|
*/
|
|
|
public boolean available(double minCPUCores, double minMemorySpace, double minDiskSpace) {
|
|
@@ -106,8 +103,8 @@ public class SystemMetrics implements OmsSerializable, Comparable<SystemMetrics>
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- // Negative number means being unable to fetch CPU info, return true.
|
|
|
// 0 indicates the CPU is free, which is the optimal condition.
|
|
|
+ // Negative number means being unable to fetch CPU info, return true.
|
|
|
if (cpuLoad <= 0 || minCPUCores <= 0) {
|
|
|
return true;
|
|
|
}
|