本文整理汇总了Python中java.util.Collections.singletonList方法的典型用法代码示例。如果您正苦于以下问题:Python Collections.singletonList方法的具体用法?Python Collections.singletonList怎么用?Python Collections.singletonList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Collections
的用法示例。
在下文中一共展示了Collections.singletonList方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: checkForJob
# 需要导入模块: from java.util import Collections [as 别名]
# 或者: from java.util.Collections import singletonList [as 别名]
def checkForJob(self,workDir):
jobFile = os.path.join(workDir,'sentinel')
if os.path.exists(jobFile):
partId = int(os.path.basename(workDir))
mc = ManagementContainer.getInstance()
pm = mc.getPartitionManager()
partition = pm.getPartition(partId)
log('Found a purge job for partition',partId)
if self.processJob(partition,workDir,jobFile):
log('Purge succeeded. Clearing jobs directory (',workDir,')to signal dispatcher that a partition is completed')
self.clearJobDirectory(workDir)
pm.refreshFreeSpaceInfo(Collections.singletonList(partition))
else:
log('Purge failed. Not clearing job directory(',workDir,'). Will retry with current batch later')
count = 1
if partId in self.failuresByPartId:
count = self.failuresByPartId[partId]
count = count + 1
if count >= self.maxFailures:
log('Purge: failed purge',count,'times for partition',partId,'. Clearing job')
self.clearJobDirectory(workDir)
count = 0
self.failuresByPartId[partId] = count
return True
return False
示例2: refeedMessage
# 需要导入模块: from java.util import Collections [as 别名]
# 或者: from java.util.Collections import singletonList [as 别名]
def refeedMessage(mc,clusLocId,partId,messageId,customerId,senderId,recipIds):
mm = mc.getMessageMatchStoreManager()
rmmd = RemoteMatchDescriptor(customerId)
rmmd.setPartitionID(int(partId))
rmmd.setStorageID(long(messageId))
rmmd.setSenderId(int(senderId))
rmmd.setRecipientIds(recipIds)
msgData = Collections.singletonList(rmmd)
mm.addFastUpdateReference(msgData,int(clusLocId),1)
示例3: setupExportCustomer
# 需要导入模块: from java.util import Collections [as 别名]
# 或者: from java.util.Collections import singletonList [as 别名]
def setupExportCustomer(numMessages, islandId, cloudDomain, stage1Mta):
print time.asctime(), 'Start setting '
userMsgs = [0] * len(users)
mc = ManagementContainer.getInstance()
custId = setupCustomer(mc, str(islandId),domain=domainName, name=custname, isCloud=True,userAccounts=users, recvDate="now")
print time.asctime(), 'customerID', custId
propagateMtaConfig()
custList = mc.getCustomerManager().findCustomers([SearchConstraint(ICustomerManager.PROP_NAME, SearchConstraintOperator.CONSTRAINT_EQUALS, custname)])
cust = custList[0]
office365Guid = cust.getGuids(CloudService.OFFICE365)[0].getGuid()
# stage cloud messages
for i in range(numMessages):
if (i % 5) == 0:
sendJournalMessage(office365Guid, users[0], ["invaliduser"], None, None, domainName, cloudDomain, stage1Mta)
userMsgs[0] += 1
elif (i % 4) == 0:
sendJournalMessage(office365Guid, "invaliduser", [users[1]], None, None, domainName, cloudDomain, stage1Mta)
userMsgs[1] += 1
elif (i % 3) == 0:
sendJournalMessage(office365Guid, "invaliduser", None, [users[2]], None, domainName, cloudDomain, stage1Mta)
userMsgs[2] += 1
elif (i % 2) == 0:
sendJournalMessage(office365Guid, "invaliduser", None, None, [users[3]], domainName, cloudDomain, stage1Mta)
userMsgs[3] += 1
else :
sendJournalMessage(office365Guid, users[0], [users[1]], [users[2]], [users[3]], domainName, cloudDomain, stage1Mta)
for j in range(len(users)):
userMsgs[j] += 1
sleep(1)
# create reviewer group
print time.asctime(), 'creating reviewer group...'
allUsers = InternalUserSets.getAllUsersSet(cust.getCustID())
mc.getUserManager().saveUserSet(allUsers)
reviewer = mc.getUserManager().findUserForEmail(users[0] + '@' + domainName)
reviewerSet = SavedUserSet(cust.getCustID())
reviewerSet.addUsers(Collections.singletonList(SearchConstraint(IUserManager.PROP_USERID, SearchConstraintOperator.CONSTRAINT_EQUALS, reviewer.getUserID())))
mc.getUserManager().saveUserSet(reviewerSet)
mc.getReviewerGroupManager().createReviewerGroup(cust.getCustID(), REVIEWER_GROUP_NAME, reviewerSet, allUsers, None)
sys.exit(0)
示例4: init
# 需要导入模块: from java.util import Collections [as 别名]
# 或者: from java.util.Collections import singletonList [as 别名]
def init(self, configurationAttributes):
print "Casa. init called"
self.authenticators = {}
self.configFileLocation = "/etc/gluu/conf/casa.json"
self.uid_attr = self.getLocalPrimaryKey()
custScriptService = CdiUtil.bean(CustomScriptService)
self.scriptsList = custScriptService.findCustomScripts(Collections.singletonList(CustomScriptType.PERSON_AUTHENTICATION), "oxConfigurationProperty", "displayName", "gluuStatus", "oxLevel")
dynamicMethods = self.computeMethods(self.scriptsList)
if len(dynamicMethods) > 0:
print "Casa. init. Loading scripts for dynamic modules: %s" % dynamicMethods
for acr in dynamicMethods:
moduleName = self.modulePrefix + acr
try:
external = __import__(moduleName, globals(), locals(), ["PersonAuthentication"], -1)
module = external.PersonAuthentication(self.currentTimeMillis)
print "Casa. init. Got dynamic module for acr %s" % acr
configAttrs = self.getConfigurationAttributes(acr, self.scriptsList)
if acr == self.ACR_U2F:
u2f_application_id = configurationAttributes.get("u2f_app_id").getValue2()
configAttrs.put("u2f_application_id", SimpleCustomProperty("u2f_application_id", u2f_application_id))
elif acr == self.ACR_SG:
client_redirect_uri = configurationAttributes.get("supergluu_app_id").getValue2()
configAttrs.put("client_redirect_uri", SimpleCustomProperty("client_redirect_uri", client_redirect_uri))
if module.init(configAttrs):
module.configAttrs = configAttrs
self.authenticators[acr] = module
else:
print "Casa. init. Call to init in module '%s' returned False" % moduleName
except:
print "Casa. init. Failed to load module %s" % moduleName
print "Exception: ", sys.exc_info()[1]
mobile_methods = configurationAttributes.get("mobile_methods")
self.mobile_methods = [] if mobile_methods == None else StringHelper.split(mobile_methods.getValue2(), ",")
print "Casa. init. Initialized successfully"
return True
示例5: getFunctionAddedChildren
# 需要导入模块: from java.util import Collections [as 别名]
# 或者: from java.util.Collections import singletonList [as 别名]
#.........这里部分代码省略.........
# Map is from potential set of dependencies to function indices
# Create this map...
while i < len(self.functionalSentencesInfo):
# Variables already in varOrdering don't go in dependents list
producibleVars.removeAll(self.varOrdering)
allVars.removeAll(self.varOrdering)
for producibleVar in producibleVars:
dependencies.addAll(allVars)
dependencies.remove(producibleVar)
if not functionsHavingDependencies.containsKey(dependencies):
functionsHavingDependencies.put(dependencies, HashSet())
functionsHavingDependencies.get(dependencies).add(i)
i += 1
# Now, we can keep creating functions to generate the remaining variables
while len(self.varOrdering) < len(self.varsToAssign):
if functionsHavingDependencies.isEmpty():
raise RuntimeException("We should not run out of functions we could use")
# Find the smallest set of dependencies
if functionsHavingDependencies.containsKey(Collections.emptySet()):
dependencySetToUse = Collections.emptySet()
else:
for dependencySet in functionsHavingDependencies.keySet():
if len(dependencySet) < smallestSize:
smallestSize = len(dependencySet)
dependencySetToUse = dependencySet
# See if any of the functions are applicable
for function_ in functions:
producibleVars.removeAll(dependencySetToUse)
producibleVars.removeAll(self.varOrdering)
if not producibleVars.isEmpty():
functionToUse = function_
varProduced = producibleVars.iterator().next()
break
if functionToUse == -1:
# None of these functions were actually useful now?
# Dump the dependency set
functionsHavingDependencies.remove(dependencySetToUse)
else:
# Apply the function
# 1) Add the remaining dependencies as iterated variables
for var in dependencySetToUse:
self.varOrdering.add(var)
self.functionalConjunctIndices.add(-1)
self.varSources.add(-1)
# 2) Add the function's produced variable (varProduced)
self.varOrdering.add(varProduced)
self.functionalConjunctIndices.add(functionToUse)
self.varSources.add(-1)
# 3) Remove all vars added this way from all dependency sets
addedVars.addAll(dependencySetToUse)
addedVars.add(varProduced)
# Tricky, because we have to merge sets
# Easier to use a new map
for entry in functionsHavingDependencies.entrySet():
newKey.removeAll(addedVars)
if not newFunctionsHavingDependencies.containsKey(newKey):
newFunctionsHavingDependencies.put(newKey, HashSet())
newFunctionsHavingDependencies.get(newKey).addAll(entry.getValue())
functionsHavingDependencies = newFunctionsHavingDependencies
# 4) Remove this function from the lists?
for functionSet in functionsHavingDependencies.values():
functionSet.remove(functionToUse)
# Now we need to actually return the ordering in a list
# Here's the quick way to do that...
# (since we've added all the new stuff to ourself already)
return Collections.singletonList(IterationOrderCandidate(self))
else:
# Let's try a new technique for restricting the space of possibilities...
# We already have an ordering on the functions
# Let's try to constrain things to that order
# Namely, if i<j and constant form j is already used as a function,
# we cannot use constant form i UNLESS constant form j supplies
# as its variable something used by constant form i.
# We might also try requiring that c.f. i NOT provide a variable
# used by c.f. j, though there may be multiple possibilities as
# to what it could provide.
if not self.functionalConjunctIndices.isEmpty():
lastFunctionUsedIndex = Collections.max(self.functionalConjunctIndices)
while i < len(self.functionalConjunctIndices):
if self.functionalConjunctIndices.get(i) != -1:
varsProducedByFunctions.add(self.varOrdering.get(i))
i += 1
while i < len(self.functionalSentencesInfo):
if i < lastFunctionUsedIndex:
# We need to figure out whether i could use any of the
# vars we're producing with functions
# TODO: Try this with a finer grain
# i.e., see if i needs a var from a function that is after
# it, not one that might be before it
if Collections.disjoint(varsInSentence, varsProducedByFunctions):
continue
# What is the best variable to grab from this form, if there are any?
if bestVariable == None:
continue
children.add(newCandidate)
i += 1
# If there are no more functions to add, add the completed version
if children.isEmpty():
children.add(IterationOrderCandidate(self))
return children