Commit 3dd171ca authored by Rafael Vieira Falcão's avatar Rafael Vieira Falcão
Browse files

Implement exception treatment

parent 605759e9
......@@ -135,7 +135,10 @@ public final class HostStateHistoryEntry {
*/
public double getIopsUsage() {
return ((double) requestedIops)/allocatedIops;
if (allocatedIops == 0)
throw new ArithmeticException("Division by 0");
else
return ((double) requestedIops)/allocatedIops;
}
/**
......@@ -149,6 +152,6 @@ public final class HostStateHistoryEntry {
@Override
public String toString() {
return String.format("Time: %6.0f | Requested: %10.0f MIPS | Allocated: %10.0f MIPS | Requested IOPS: %d iops | Allocated IOPS: %d iops | IOPS usage: %f | Host Active: %s\n", time, requestedMips, allocatedMips, requestedIops, allocatedIops, getIopsUsage(), active);
return String.format("Time: %6.0f | Requested: %10.0f MIPS | Allocated: %10.0f MIPS | Host Active: %s\n", time, requestedMips, allocatedMips, active);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment