本文整理汇总了Python中DIRAC.WorkloadManagementSystem.DB.JobDB.JobDB.getJobAttribute方法的典型用法代码示例。如果您正苦于以下问题:Python JobDB.getJobAttribute方法的具体用法?Python JobDB.getJobAttribute怎么用?Python JobDB.getJobAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DIRAC.WorkloadManagementSystem.DB.JobDB.JobDB
的用法示例。
在下文中一共展示了JobDB.getJobAttribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: StalledJobAgent
# 需要导入模块: from DIRAC.WorkloadManagementSystem.DB.JobDB import JobDB [as 别名]
# 或者: from DIRAC.WorkloadManagementSystem.DB.JobDB.JobDB import getJobAttribute [as 别名]
#.........这里部分代码省略.........
if not result['OK']:
self.log.error( 'Failed to process stalled jobs', result['Message'] )
result = self.__failCompletedJobs()
if not result['OK']:
self.log.error( 'Failed to process completed jobs', result['Message'] )
result = self.__failSubmittingJobs()
if not result['OK']:
self.log.error('Failed to process jobs being submitted', result['Message'])
result = self.__kickStuckJobs()
if not result['OK']:
self.log.error( 'Failed to kick stuck jobs', result['Message'] )
return S_OK( 'Stalled Job Agent cycle complete' )
#############################################################################
def __markStalledJobs( self, stalledTime ):
""" Identifies stalled jobs running without update longer than stalledTime.
"""
stalledCounter = 0
runningCounter = 0
result = self.jobDB.selectJobs( {'Status':'Running'} )
if not result['OK']:
return result
if not result['Value']:
return S_OK()
jobs = result['Value']
self.log.info( '%s Running jobs will be checked for being stalled' % ( len( jobs ) ) )
jobs.sort()
# jobs = jobs[:10] #for debugging
for job in jobs:
site = self.jobDB.getJobAttribute( job, 'site' )['Value']
if site in self.stalledJobsTolerantSites:
result = self.__getStalledJob( job, stalledTime + self.stalledJobsToleranceTime )
else:
result = self.__getStalledJob( job, stalledTime )
if result['OK']:
self.log.verbose( 'Updating status to Stalled for job %s' % ( job ) )
self.__updateJobStatus( job, 'Stalled' )
stalledCounter += 1
else:
self.log.verbose( result['Message'] )
runningCounter += 1
self.log.info( 'Total jobs: %s, Stalled job count: %s, Running job count: %s' %
( len( jobs ), stalledCounter, runningCounter ) )
return S_OK()
#############################################################################
def __failStalledJobs( self, failedTime ):
""" Changes the Stalled status to Failed for jobs long in the Stalled status
"""
result = self.jobDB.selectJobs( {'Status':'Stalled'} )
if not result['OK']:
return result
jobs = result['Value']
failedCounter = 0
minorStalledStatuses = ( "Job stalled: pilot not running", 'Stalling for more than %d sec' % failedTime )
if jobs:
self.log.info( '%s Stalled jobs will be checked for failure' % ( len( jobs ) ) )
示例2: JobDB
# 需要导入模块: from DIRAC.WorkloadManagementSystem.DB.JobDB import JobDB [as 别名]
# 或者: from DIRAC.WorkloadManagementSystem.DB.JobDB.JobDB import getJobAttribute [as 别名]
import sys
import DIRAC
from DIRAC.Core.Base import Script
Script.parseCommandLine( ignoreErrors = True )
args = Script.getPositionalArgs()
from DIRAC.WorkloadManagementSystem.DB.TaskQueueDB import TaskQueueDB
from DIRAC.WorkloadManagementSystem.DB.JobDB import JobDB
jobdb = JobDB()
tqdb = TaskQueueDB()
result = jobdb.selectJobs( { 'Status' : [ 'Received', 'Checking', 'Waiting' ] } )
if not result[ 'OK' ]:
print result[ 'Message' ]
sys.exit( 1 )
jobList = result[ 'Value' ]
print tqdb.forceRecreationOfTables()
for job in jobList:
result = jobdb.getJobAttribute( job, 'RescheduleCounter' )
if not result[ 'OK' ]:
print "Cannot get reschedule counter for job %s" % job
rC = 0
rC = result[ 'Value' ]
if rC >= jobdb.maxRescheduling:
jobdb.setJobAttribute( job, "RescheduleCounter", "0" )
jobdb.rescheduleJob( job )
jobdb.setJobAttribute( job, "RescheduleCounter", rC )
sys.exit( 0 )