A class to handle ULong64 return values in Java
The ULong64 type returned in statistics calls from the iControl API is necessary to track large numbers of bytes and connections, but is difficult to deal with from within Java. Today we present ...
Published May 30, 2007
Version 1.0Don_MacVittie_1
Historic F5 Account
Joined September 25, 2004
Don_MacVittie_1
Historic F5 Account
Joined September 25, 2004
Mohamed_Lrhazi
Feb 01, 2009Altocumulus
If using iControl.jar from Python/Jython, here is the helper class ported to Python:
from iControl import CommonULong64
class UsefulU64(object):
def __init__(self,ulong=CommonULong64()):
self.ulong=ulong
self.value=0
high=ulong.getHigh()
low=ulong.getLow()
rollOver = 0x7fffffff
rollOver += 1
tmpVal=0
if(high >=0):
tmpVal = high << 32 & 0xffff0000
else:
tmpVal = ((high & 0x7fffffff) << 32) + (0x80000000 << 32)
if(low >=0):
tmpVal = tmpVal + low
else:
tmpVal = tmpVal + (low & 0x7fffffff) + rollOver
self.value=tmpVal
def __str__(self):
size = ""
value=self.value
if(value / 1024 >= 1.0):
size = "K"
value = value / 1024
if(value / 1024 >= 1.0):
size = "M"
value = value / 1024
if(value / 1024 >= 1.0):
size = "G"
value = value / 1024
return "%.2f%s"%(value,size)
if __name__ == "__main__":
import iControl
ic=iControl.Interfaces()
ic.initialize("10.1.1.245","admin","admin")
result=ic.localLBPool.get_all_statistics()
stats=result.statistics
print "Pool name: %s"%stats[0].pool_name
print "Stats type: %s"%stats[0].statistics[0].type
value=stats[0].statistics[0].value
print "Stat value: %s"%UsefulU64(value)