mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
Bug 11860: combining 32 bit signed values into a 64 bit value had errors. This should correct that
This commit is contained in:
parent
68b6f2b1c5
commit
7fb6a695c1
@ -949,20 +949,8 @@ public class F5BigIpResource implements ServerResource {
|
|||||||
|
|
||||||
long high = stat.getValue().getHigh();
|
long high = stat.getValue().getHigh();
|
||||||
long low = stat.getValue().getLow();
|
long low = stat.getValue().getLow();
|
||||||
long full;
|
long full = getFullUsage(high, low);
|
||||||
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;
|
bytesSentAndReceived[index] += full;
|
||||||
}
|
}
|
||||||
@ -979,6 +967,32 @@ public class F5BigIpResource implements ServerResource {
|
|||||||
return answer;
|
return answer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private long getFullUsage(long high, long low) {
|
||||||
|
Double full;
|
||||||
|
Double rollOver = new Double((double) 0x7fffffff);
|
||||||
|
rollOver = new Double(rollOver.doubleValue() + 1.0);
|
||||||
|
|
||||||
|
if (high >= 0) {
|
||||||
|
// shift left 32 bits and mask off new bits to 0's
|
||||||
|
full = new Double((high << 32 & 0xffff0000));
|
||||||
|
} else {
|
||||||
|
// mask off sign bits + shift left by 32 bits then add the sign bit back
|
||||||
|
full = new Double(((high & 0x7fffffff) << 32) + (0x80000000 << 32));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (low >= 0) {
|
||||||
|
// add low to full and we're good
|
||||||
|
full = new Double(full.doubleValue() + (double) low);
|
||||||
|
} else {
|
||||||
|
// add full to low after masking off sign bits and adding 1 to the masked off low order value
|
||||||
|
full = new Double(full.doubleValue() + (double) ((low & 0x7fffffff)) + rollOver.doubleValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
return full.longValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Misc methods
|
// Misc methods
|
||||||
|
|
||||||
private String tagAddressWithRouteDomain(String address, long vlanTag) {
|
private String tagAddressWithRouteDomain(String address, long vlanTag) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user