本文整理汇总了Python中DIRAC.ResourceStatusSystem.Client.ResourceManagementClient.ResourceManagementClient.selectJobCache方法的典型用法代码示例。如果您正苦于以下问题:Python ResourceManagementClient.selectJobCache方法的具体用法?Python ResourceManagementClient.selectJobCache怎么用?Python ResourceManagementClient.selectJobCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DIRAC.ResourceStatusSystem.Client.ResourceManagementClient.ResourceManagementClient
的用法示例。
在下文中一共展示了ResourceManagementClient.selectJobCache方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: JobCommand
# 需要导入模块: from DIRAC.ResourceStatusSystem.Client.ResourceManagementClient import ResourceManagementClient [as 别名]
# 或者: from DIRAC.ResourceStatusSystem.Client.ResourceManagementClient.ResourceManagementClient import selectJobCache [as 别名]
#.........这里部分代码省略.........
"""
JobCommand requires one arguments:
- name : <str>
"""
if 'name' not in self.args:
return S_ERROR( '"name" not found in self.args' )
name = self.args[ 'name' ]
return S_OK( name )
def doNew( self, masterParams = None ):
"""
Gets the parameters to run, either from the master method or from its
own arguments.
It contacts the WMSAdministrator with a list of site names, or a single
site.
If there are jobs, are recorded and then returned.
"""
if masterParams is not None:
name = masterParams
else:
params = self._prepareCommand()
if not params[ 'OK' ]:
return params
name = params[ 'Value' ]
# selectDict, sortList, startItem, maxItems
# Returns statistics of Last day !
results = self.wmsAdmin.getSiteSummaryWeb( { 'Site' : name }, [], 0, 0 )
if not results[ 'OK' ]:
return results
results = results[ 'Value' ]
if not 'ParameterNames' in results:
return S_ERROR( 'Wrong result dictionary, missing "ParameterNames"' )
params = results[ 'ParameterNames' ]
if not 'Records' in results:
return S_ERROR( 'Wrong formed result dictionary, missing "Records"' )
records = results[ 'Records' ]
uniformResult = []
for record in records:
# This returns a dictionary with the following keys
# 'Site', 'GridType', 'Country', 'Tier', 'MaskStatus', 'Received',
# 'Checking', 'Staging', 'Waiting', 'Matched', 'Running', 'Stalled',
# 'Done', 'Completed', 'Failed', 'Efficiency', 'Status'
jobDict = dict( zip( params , record ))
# We cast efficiency to a float
jobDict[ 'Efficiency' ] = float( jobDict[ 'Efficiency' ] )
uniformResult.append( jobDict )
storeRes = self._storeCommand( uniformResult )
if not storeRes[ 'OK' ]:
return storeRes
return S_OK( uniformResult )
def doCache( self ):
"""
Method that reads the cache table and tries to read from it. It will
return a list of dictionaries if there are results.
"""
params = self._prepareCommand()
if not params[ 'OK' ]:
return params
name = params[ 'Value' ]
result = self.rmClient.selectJobCache( name )
if result[ 'OK' ]:
result = S_OK( [ dict( zip( result[ 'Columns' ], res ) ) for res in result[ 'Value' ] ] )
return result
def doMaster( self ):
"""
Master method.
Gets all sites and calls doNew method.
"""
siteNames = CSHelpers.getSites()
if not siteNames[ 'OK' ]:
return siteNames
siteNames = siteNames[ 'Value' ]
jobsResults = self.doNew( siteNames )
if not jobsResults[ 'OK' ]:
self.metrics[ 'failed' ].append( jobsResults[ 'Message' ] )
return S_OK( self.metrics )
示例2: JobCommand
# 需要导入模块: from DIRAC.ResourceStatusSystem.Client.ResourceManagementClient import ResourceManagementClient [as 别名]
# 或者: from DIRAC.ResourceStatusSystem.Client.ResourceManagementClient.ResourceManagementClient import selectJobCache [as 别名]
#.........这里部分代码省略.........
for resultTuple in results[ 'Value' ]:
selectionDict, numberOfJobs = resultTuple
siteName = selectionDict[ 'Site' ]
if siteName in ( 'ANY', 'Multiple' ):
continue
if not siteName in uniformResult:
uniformResult[ siteName ] = dict.fromkeys( jobStatuses, 0 )
uniformResult[ siteName ][ selectionDict[ 'Status' ] ] = numberOfJobs
# Store results
storeRes = self._storeCommand( uniformResult )
if not storeRes[ 'OK' ]:
return storeRes
return S_OK( uniformResult )
def doCache( self ):
'''
Method that reads the cache table and tries to read from it. It will
return a list of dictionaries if there are results.
'''
params = self._prepareCommand()
if not params[ 'OK' ]:
return params
name = params[ 'Value' ]
result = self.rmClient.selectJobCache( name )
if result[ 'OK' ]:
result = S_OK( [ dict( zip( result[ 'Columns' ], res ) ) for res in result[ 'Value' ] ] )
return result
def doMaster( self ):
'''
Master method.
Gets all sites and calls doNew method.
'''
jobsResults = self.doNew( True )
if not jobsResults[ 'OK' ]:
self.metrics[ 'failed' ].append( jobsResults[ 'Message' ] )
return S_OK( self.metrics )
################################################################################
################################################################################
################################################################################
################################################################################
################################################################################
################################################################################
################################################################################
################################################################################
#class JobsStatsCommand( Command ):
#
# def __init__( self, args = None, clients = None ):
#
# super( JobsStatsCommand, self ).__init__( args, clients )