DaanHoogland commented on code in PR #8521:
URL: https://github.com/apache/cloudstack/pull/8521#discussion_r1454809796
##########
plugins/drs/cluster/condensed/src/main/java/org/apache/cloudstack/cluster/Condensed.java:
##########
@@ -42,15 +43,33 @@ public String getName() {
}
@Override
- public boolean needsDrs(long clusterId, List<Long> cpuList, List<Long>
memoryList) throws ConfigurationException {
- Double cpuImbalance = getClusterImbalance(cpuList);
- Double memoryImbalance = getClusterImbalance(memoryList);
+ public boolean needsDrs(long clusterId, List<Pair<Long, Long>> cpuList,
List<Pair<Long, Long>> memoryList) throws ConfigurationException {
double threshold = getThreshold(clusterId);
String metric = ClusterDrsMetric.valueIn(clusterId);
switch (metric) {
case "cpu":
+ List<Double> cpuRatioList = new ArrayList<>();
+ for (Pair<Long, Long> pair : cpuList) {
+ Double ratio = (double) pair.first() / pair.second();
+ // To ensure that we calculate imbalance in cases where a
few hosts are already condensed
+ // but other hosts aren't. This is to prevent the case
where we don't migrate VMs because
+ // imbalance > 1 but the cluster is not condensed.
+ if (pair.first() < 0.05 * pair.second()) continue;
+ cpuRatioList.add(ratio);
+ }
+ Double cpuImbalance = getClusterImbalance(cpuRatioList);
return cpuImbalance < threshold;
case "memory":
+ List<Double> memoryRatioList = new ArrayList<>();
+ for (Pair<Long, Long> pair : memoryList) {
+ Double ratio = (double) pair.first() / pair.second();
+ // To ensure that we calculate imbalance in cases where a
few hosts are already condensed
+ // but other hosts aren't. This is to prevent the case
where we don't migrate VMs because
+ // imbalance > 1 but the cluster is not condensed.
+ if (pair.first() < 0.05 * pair.second()) continue;
+ memoryRatioList.add(ratio);
+ }
+ Double memoryImbalance = getClusterImbalance(memoryRatioList);
return memoryImbalance < threshold;
Review Comment:
mybe for the two above a generic method (though I doubt much more algorithms
will be added still)
##########
plugins/drs/cluster/condensed/src/main/java/org/apache/cloudstack/cluster/Condensed.java:
##########
@@ -42,15 +43,33 @@ public String getName() {
}
@Override
- public boolean needsDrs(long clusterId, List<Long> cpuList, List<Long>
memoryList) throws ConfigurationException {
- Double cpuImbalance = getClusterImbalance(cpuList);
- Double memoryImbalance = getClusterImbalance(memoryList);
+ public boolean needsDrs(long clusterId, List<Pair<Long, Long>> cpuList,
List<Pair<Long, Long>> memoryList) throws ConfigurationException {
double threshold = getThreshold(clusterId);
String metric = ClusterDrsMetric.valueIn(clusterId);
switch (metric) {
case "cpu":
+ List<Double> cpuRatioList = new ArrayList<>();
+ for (Pair<Long, Long> pair : cpuList) {
+ Double ratio = (double) pair.first() / pair.second();
+ // To ensure that we calculate imbalance in cases where a
few hosts are already condensed
+ // but other hosts aren't. This is to prevent the case
where we don't migrate VMs because
+ // imbalance > 1 but the cluster is not condensed.
+ if (pair.first() < 0.05 * pair.second()) continue;
+ cpuRatioList.add(ratio);
+ }
+ Double cpuImbalance = getClusterImbalance(cpuRatioList);
return cpuImbalance < threshold;
Review Comment:
method?
##########
plugins/drs/cluster/condensed/src/main/java/org/apache/cloudstack/cluster/Condensed.java:
##########
@@ -42,15 +43,33 @@ public String getName() {
}
@Override
- public boolean needsDrs(long clusterId, List<Long> cpuList, List<Long>
memoryList) throws ConfigurationException {
- Double cpuImbalance = getClusterImbalance(cpuList);
- Double memoryImbalance = getClusterImbalance(memoryList);
+ public boolean needsDrs(long clusterId, List<Pair<Long, Long>> cpuList,
List<Pair<Long, Long>> memoryList) throws ConfigurationException {
double threshold = getThreshold(clusterId);
String metric = ClusterDrsMetric.valueIn(clusterId);
switch (metric) {
case "cpu":
+ List<Double> cpuRatioList = new ArrayList<>();
+ for (Pair<Long, Long> pair : cpuList) {
+ Double ratio = (double) pair.first() / pair.second();
+ // To ensure that we calculate imbalance in cases where a
few hosts are already condensed
+ // but other hosts aren't. This is to prevent the case
where we don't migrate VMs because
+ // imbalance > 1 but the cluster is not condensed.
+ if (pair.first() < 0.05 * pair.second()) continue;
+ cpuRatioList.add(ratio);
+ }
+ Double cpuImbalance = getClusterImbalance(cpuRatioList);
return cpuImbalance < threshold;
case "memory":
+ List<Double> memoryRatioList = new ArrayList<>();
+ for (Pair<Long, Long> pair : memoryList) {
+ Double ratio = (double) pair.first() / pair.second();
+ // To ensure that we calculate imbalance in cases where a
few hosts are already condensed
+ // but other hosts aren't. This is to prevent the case
where we don't migrate VMs because
+ // imbalance > 1 but the cluster is not condensed.
+ if (pair.first() < 0.05 * pair.second()) continue;
+ memoryRatioList.add(ratio);
+ }
+ Double memoryImbalance = getClusterImbalance(memoryRatioList);
return memoryImbalance < threshold;
Review Comment:
method?
--
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]