本文整理汇总了Python中java.util.HashSet.size方法的典型用法代码示例。如果您正苦于以下问题:Python HashSet.size方法的具体用法?Python HashSet.size怎么用?Python HashSet.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.HashSet
的用法示例。
在下文中一共展示了HashSet.size方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: findMessages
# 需要导入模块: from java.util import HashSet [as 别名]
# 或者: from java.util.HashSet import size [as 别名]
def findMessages(mc,custid,count):
print 'findMessages() find ',count
amsm = mc.getActiveMailboxStoreManager()
ids = HashSet()
msgs = HashSet()
retries = 30
while msgs.size() < count and retries > 0:
for p in mc.getPartitionManager().listPartitions():
if p.isReadOnly():
continue
print 'searching for messages to be stored in',p
tm = amsm.findMessages([SearchConstraint(IActiveMailboxStoreManager.PROP_CUST_ID, SearchConstraintOperator.CONSTRAINT_EQUALS,int(custid))],p)
if tm.size() > 0:
msgs.addAll(filter(lambda x : not ids.contains(x.getMessageId()),tm))
ids.addAll(map(lambda x : x.getMessageId(), tm))
if msgs.size() < count:
time.sleep(10)
retries = retries - 1
print 'findMessages found',msgs.size(),'ids',ids.size()
if msgs.isEmpty():
print 'Failed to find any messages in DB'
raise Exception('Failed to find any messages in DB')
if msgs.size() < count:
print 'Warning, did not find all messages expected'
return msgs
示例2: findMessages
# 需要导入模块: from java.util import HashSet [as 别名]
# 或者: from java.util.HashSet import size [as 别名]
def findMessages(mc,custid,count, includeCategorizedRecipients=False):
print 'findMessages() should find ',count
amsm = mc.getActiveMailboxStoreManager()
msgs = HashSet()
retries = 15
while msgs.size() < count and retries > 0:
for p in mc.getPartitionManager().listPartitions():
if p.isReadOnly():
continue
print 'searching for messages to be stored in',p
tm = amsm.findMessages([SearchConstraint(IActiveMailboxStoreManager.PROP_CUST_ID, SearchConstraintOperator.CONSTRAINT_EQUALS,int(custid))],p,includeCategorizedRecipients)
if tm.size() > 0:
msgs.addAll(tm)
if msgs.size() < count:
time.sleep(10)
retries = retries - 1
print 'findMessages() found',msgs.size()
if msgs.isEmpty():
print 'Failed to find any messages in DB'
raise Exception('Failed to find any messages in DB')
if msgs.size() < count:
print 'Warning, did not find all messages expected'
return msgs
示例3: runJob
# 需要导入模块: from java.util import HashSet [as 别名]
# 或者: from java.util.HashSet import size [as 别名]
def runJob(cmdArray, hosts, sleepTime=60, maxWaits=60, interimResult=None):
finished = HashSet()
failures = HashSet()
pb = ProcessBuilder(cmdArray)
done = False
# first wait is short in case job finishes quickly
waitTime = 10
while not done:
p = pb.start()
dataOut = DataOutputStream(p.getOutputStream())
try:
for host in hosts:
dataOut.writeBytes(host + "\n")
finally:
dataOut.close()
p.waitFor()
(curFinished, curFailures) = processJobResults(p.getInputStream(), interimResult)
finished.addAll(curFinished)
failures.addAll(curFailures)
done = finished.size() == len(hosts)
if not done:
maxWaits = maxWaits - 1
done == maxWaits == 0
if not done:
time.sleep(waitTime)
waitTime = sleepTime
return failures
示例4: test_HashSet
# 需要导入模块: from java.util import HashSet [as 别名]
# 或者: from java.util.HashSet import size [as 别名]
def test_HashSet(self):
"""create HashSet in JVM (from the JavaSet)
"""
hashSet = HashSet(self.javaSet)
# print "created HashSet:", hashSet, type(hashSet)
self.assertEqual(self.javaSet.size(),
hashSet.size(),
"HashSet has same size")
elem0 = list(self.testSet)[0]
self.assertTrue(hashSet.contains(elem0))
示例5: disFreeBSD
# 需要导入模块: from java.util import HashSet [as 别名]
# 或者: from java.util.HashSet import size [as 别名]
def disFreeBSD(host_obj, client, Framework, langBund=None, host_is_virtual = False):
myVec = ObjectStateHolderVector()
cpuDescription = None
cpuCount = 0
cpuSpeed = None
vendor = ''
result = client.execCmd('sysctl hw.model hw.ncpu hw.clockrate')#[email protected]@CMD_PERMISION tty protocol execution
if result:
regexStr = 'hw\.model: (.*?)\s*\nhw\.ncpu: (\d+)\s*\nhw\.clockrate: (\d+)'
matcher = re.search(regexStr, result)
if matcher:
cpuDescription = collapseWhitespaces(matcher.group(1))
cpuCount = int(matcher.group(2))
cpuSpeed = matcher.group(3)
if re.search('Intel', cpuDescription):
vendor = 'Intel'
if cpuCount == 0:
result = client.execCmd('dmesg | grep -A 1 "CPU:"')#[email protected]@CMD_PERMISION tty protocol execution
if result:
regexStr = 'CPU:\s*([^\n]*)\((\d+)\.\d+-MHz.*?\)\s*?\n.*?Origin\s*?=\s*?"(.*?)\"'
matcher = re.search(regexStr, result)
if matcher:
cpuDescription = collapseWhitespaces(matcher.group(1))
cpuSpeed = matcher.group(2)
vendor = matcher.group(3)
cpuCount = 1
cpuCountResult = client.execCmd('dmesg | grep "cpu\|Multiprocessor"')#[email protected]@CMD_PERMISION tty protocol execution
if cpuCountResult:
cpuCountMatcher = re.search("Multiprocessor (System Detected|motherboard): (\d+) CPUs", cpuCountResult)
if cpuCountMatcher:
cpuCount = int(cpuCountMatcher.group(2))
else:
cpuEntries = re.findall("(?i)cpu\d+ \(\w+?\):\s+?APIC ID:\s+?\d+", cpuCountResult)
if cpuEntries:
#filter out duplicates from multiple sessions
set_ = HashSet()
for entry in cpuEntries:
set_.add(entry)
cpuCount = set_.size()
if cpuCount > 0:
for i in range(cpuCount):
cid = 'CPU' + str(i)
myVec.add(makeCPUOSH(host_obj, cid, vendor, cpuSpeed, '', cpuDescription, is_virtual=host_is_virtual))
return myVec