FIX3: Consider overcommit ratios with total/threshold values

Consider the CPU and memory overcommit ratios with total cpu/ram values
or thresholds for host and cluster metrics. This will fix incorrect
notification (cells turning yellow/red) in the metrics view.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Rohit Yadav 2017-07-06 15:30:07 +05:30 committed by Rohit Yadav
parent 2590c2521a
commit 9c82452b82
2 changed files with 8 additions and 8 deletions

View File

@ -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 * overCommitRatio / cpuUsed) > threshold;
this.cpuAllocatedThresholdExceeded = (1.0 * cpuAllocated / cpuUsed) > (threshold * overCommitRatio);
}
}
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 * overCommitRatio / cpuUsed) > threshold;
this.cpuAllocatedDisableThresholdExceeded = (1.0 * cpuAllocated / cpuUsed) > (threshold * overCommitRatio);
}
}
@ -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 * overCommitRatio / memTotal) > threshold;
this.memoryAllocatedThresholdExceeded = (1.0 * memAllocated / memTotal) > (threshold * overCommitRatio);
}
}
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 * overCommitRatio / memTotal) > threshold;
this.memoryAllocatedDisableThresholdExceeded = (1.0 * memAllocated / memTotal) > (threshold * overCommitRatio);
}
}
}

View File

@ -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("%", "")) * overCommitRatio) > (100.0 * threshold);
this.cpuAllocatedThresholdExceeded = Double.valueOf(cpuAllocated.replace("%", "")) > (100.0 * threshold * overCommitRatio);
}
}
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("%", "")) * overCommitRatio) > (100.0 * threshold);
this.cpuAllocatedDisableThresholdExceeded = Double.valueOf(cpuAllocated.replace("%", "")) > (100.0 * threshold * overCommitRatio);
}
}
@ -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 * overCommitRatio) > (memTotal * threshold);
this.memoryAllocatedThresholdExceeded = memAllocated > (memTotal * threshold * overCommitRatio);
}
}
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 * overCommitRatio) > (memTotal * threshold);
this.memoryAllocatedDisableThresholdExceeded = memAllocated > (memTotal * threshold * overCommitRatio);
}
}