From fe88eecfd69a5ac0950014d36fcad4ee8c651b26 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Sat, 22 Jul 2017 13:13:25 +0200 Subject: [PATCH] Revert "FIX3: Consider overcommit ratios with total/threshold values" This reverts commit 9c82452b8252fbae754d208c0d2bedbe3a9505a2. --- .../cloudstack/response/ClusterMetricsResponse.java | 8 ++++---- .../apache/cloudstack/response/HostMetricsResponse.java | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/metrics/src/org/apache/cloudstack/response/ClusterMetricsResponse.java b/plugins/metrics/src/org/apache/cloudstack/response/ClusterMetricsResponse.java index d1046f92924..1ee2184d7a6 100644 --- a/plugins/metrics/src/org/apache/cloudstack/response/ClusterMetricsResponse.java +++ b/plugins/metrics/src/org/apache/cloudstack/response/ClusterMetricsResponse.java @@ -174,13 +174,13 @@ public class ClusterMetricsResponse extends ClusterResponse { public void setCpuAllocatedThreshold(final Long cpuAllocated, final Long cpuUsed, final Double overCommitRatio, final Double threshold) { if (cpuAllocated != null && cpuUsed != null && overCommitRatio != null && threshold != null && cpuUsed != 0) { - this.cpuAllocatedThresholdExceeded = (1.0 * cpuAllocated / cpuUsed) > (threshold * overCommitRatio); + this.cpuAllocatedThresholdExceeded = (1.0 * cpuAllocated * overCommitRatio / cpuUsed) > threshold; } } public void setCpuAllocatedDisableThreshold(final Long cpuAllocated, final Long cpuUsed, final Double overCommitRatio, final Float threshold) { if (cpuAllocated != null && cpuUsed != null && overCommitRatio != null && threshold != null && cpuUsed != 0) { - this.cpuAllocatedDisableThresholdExceeded = (1.0 * cpuAllocated / cpuUsed) > (threshold * overCommitRatio); + this.cpuAllocatedDisableThresholdExceeded = (1.0 * cpuAllocated * overCommitRatio / cpuUsed) > threshold; } } @@ -199,13 +199,13 @@ public class ClusterMetricsResponse extends ClusterResponse { public void setMemoryAllocatedThreshold(final Long memAllocated, final Long memTotal, final Double overCommitRatio, final Double threshold) { if (memAllocated != null && memTotal != null && overCommitRatio != null && threshold != null && memTotal != 0) { - this.memoryAllocatedThresholdExceeded = (1.0 * memAllocated / memTotal) > (threshold * overCommitRatio); + this.memoryAllocatedThresholdExceeded = (1.0 * memAllocated * overCommitRatio / memTotal) > threshold; } } public void setMemoryAllocatedDisableThreshold(final Long memAllocated, final Long memTotal, final Double overCommitRatio, final Float threshold) { if (memAllocated != null && memTotal != null && overCommitRatio != null && threshold != null && memTotal != 0) { - this.memoryAllocatedDisableThresholdExceeded = (1.0 * memAllocated / memTotal) > (threshold * overCommitRatio); + this.memoryAllocatedDisableThresholdExceeded = (1.0 * memAllocated * overCommitRatio / memTotal) > threshold; } } } diff --git a/plugins/metrics/src/org/apache/cloudstack/response/HostMetricsResponse.java b/plugins/metrics/src/org/apache/cloudstack/response/HostMetricsResponse.java index 72e9f92f803..cdc9d16d845 100644 --- a/plugins/metrics/src/org/apache/cloudstack/response/HostMetricsResponse.java +++ b/plugins/metrics/src/org/apache/cloudstack/response/HostMetricsResponse.java @@ -167,13 +167,13 @@ public class HostMetricsResponse extends HostResponse { public void setCpuAllocatedThreshold(final String cpuAllocated, final Double overCommitRatio, final Double threshold) { if (cpuAllocated != null && overCommitRatio != null && threshold != null) { - this.cpuAllocatedThresholdExceeded = Double.valueOf(cpuAllocated.replace("%", "")) > (100.0 * threshold * overCommitRatio); + this.cpuAllocatedThresholdExceeded = (Double.valueOf(cpuAllocated.replace("%", "")) * overCommitRatio) > (100.0 * threshold); } } public void setCpuAllocatedDisableThreshold(final String cpuAllocated, final Double overCommitRatio, final Float threshold) { if (cpuAllocated != null && overCommitRatio != null && threshold != null) { - this.cpuAllocatedDisableThresholdExceeded = Double.valueOf(cpuAllocated.replace("%", "")) > (100.0 * threshold * overCommitRatio); + this.cpuAllocatedDisableThresholdExceeded = (Double.valueOf(cpuAllocated.replace("%", "")) * overCommitRatio) > (100.0 * threshold); } } @@ -191,13 +191,13 @@ public class HostMetricsResponse extends HostResponse { public void setMemoryAllocatedThreshold(final Long memAllocated, final Long memTotal, final Double overCommitRatio, final Double threshold) { if (memAllocated != null && memTotal != null && overCommitRatio != null && threshold != null) { - this.memoryAllocatedThresholdExceeded = memAllocated > (memTotal * threshold * overCommitRatio); + this.memoryAllocatedThresholdExceeded = (memAllocated * overCommitRatio) > (memTotal * threshold); } } public void setMemoryAllocatedDisableThreshold(final Long memAllocated, final Long memTotal, final Double overCommitRatio, final Float threshold) { if (memAllocated != null && memTotal != null && overCommitRatio != null && threshold != null) { - this.memoryAllocatedDisableThresholdExceeded = memAllocated > (memTotal * threshold * overCommitRatio); + this.memoryAllocatedDisableThresholdExceeded = (memAllocated * overCommitRatio) > (memTotal * threshold); } }