From 9f72703ad28f578cf984cd39ca0e835c707468d5 Mon Sep 17 00:00:00 2001 From: keshav Date: Tue, 1 Nov 2011 15:50:28 -0700 Subject: [PATCH] Account for high-order/low-order integers being signed. --- .../network/resource/F5BigIpResource.java | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/core/src/com/cloud/network/resource/F5BigIpResource.java b/core/src/com/cloud/network/resource/F5BigIpResource.java index 2d17d5b6532..0671e6089b4 100644 --- a/core/src/com/cloud/network/resource/F5BigIpResource.java +++ b/core/src/com/cloud/network/resource/F5BigIpResource.java @@ -923,7 +923,7 @@ public class F5BigIpResource implements ServerResource { bytesSentAndReceived = new long[]{0, 0}; } - for (CommonStatistic stat : entry.getStatistics()) { + for (CommonStatistic stat : entry.getStatistics()) { int index; if (stat.getType().equals(CommonStatisticType.STATISTIC_CLIENT_SIDE_BYTES_OUT)) { // Add to the outgoing bytes @@ -935,9 +935,23 @@ public class F5BigIpResource implements ServerResource { continue; } - long high = stat.getValue().getHigh() & 0x0000ffff; - long low = stat.getValue().getLow() & 0x0000ffff; - long full = (high << 32) | low; + long high = stat.getValue().getHigh(); + long low = stat.getValue().getLow(); + long full; + long rollOver = 0x7fffffff + 1; + + if (high >= 0) { + full = (high << 32) & 0xffff0000; + } else { + full = ((high & 0x7fffffff) << 32) + (0x80000000 << 32); + } + + if (low >= 0) { + full += low; + } else { + full += (low & 0x7fffffff) + rollOver; + } + bytesSentAndReceived[index] += full; } @@ -989,7 +1003,7 @@ public class F5BigIpResource implements ServerResource { private static String[] genStringArray(String s) { return new String[]{s}; } - + }