本文整理汇总了Python中DIRAC.WorkloadManagementSystem.DB.JobDB.JobDB.rescheduleJobs方法的典型用法代码示例。如果您正苦于以下问题:Python JobDB.rescheduleJobs方法的具体用法?Python JobDB.rescheduleJobs怎么用?Python JobDB.rescheduleJobs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DIRAC.WorkloadManagementSystem.DB.JobDB.JobDB
的用法示例。
在下文中一共展示了JobDB.rescheduleJobs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: StalledJobAgent
# 需要导入模块: from DIRAC.WorkloadManagementSystem.DB.JobDB import JobDB [as 别名]
# 或者: from DIRAC.WorkloadManagementSystem.DB.JobDB.JobDB import rescheduleJobs [as 别名]
#.........这里部分代码省略.........
for items in logList:
if items[0] == 'Running':
startTime = items[3]
break
if not startTime or startTime == 'None':
startTime = jobDict['SubmissionTime']
if type( startTime ) in types.StringTypes:
startTime = fromString( startTime )
if startTime == None:
self.log.error( 'Wrong timestamp in DB', items[3] )
startTime = dateTime()
endTime = dateTime()
# status, minor, app, stime, source
for items in logList:
if items[0] == 'Stalled':
endTime = fromString( items[3] )
if endTime == None:
self.log.error( 'Wrong timestamp in DB', items[3] )
endTime = dateTime()
return startTime, endTime
def __kickStuckJobs( self ):
""" Reschedule jobs stuck in initialization status Rescheduled, Matched
"""
message = ''
checkTime = str( dateTime() - self.matchedTime * second )
result = self.jobDB.selectJobs( {'Status':'Matched'}, older = checkTime )
if not result['OK']:
self.log.error( 'Failed to select jobs', result['Message'] )
return result
jobIDs = result['Value']
if jobIDs:
self.log.info( 'Rescheduling %d jobs stuck in Matched status' % len( jobIDs ) )
result = self.jobDB.rescheduleJobs( jobIDs )
if 'FailedJobs' in result:
message = 'Failed to reschedule %d jobs stuck in Matched status' % len( result['FailedJobs'] )
checkTime = str( dateTime() - self.rescheduledTime * second )
result = self.jobDB.selectJobs( {'Status':'Rescheduled'}, older = checkTime )
if not result['OK']:
self.log.error( 'Failed to select jobs', result['Message'] )
return result
jobIDs = result['Value']
if jobIDs:
self.log.info( 'Rescheduling %d jobs stuck in Rescheduled status' % len( jobIDs ) )
result = self.jobDB.rescheduleJobs( jobIDs )
if 'FailedJobs' in result:
if message:
message += '\n'
message += 'Failed to reschedule %d jobs stuck in Rescheduled status' % len( result['FailedJobs'] )
if message:
return S_ERROR( message )
else:
return S_OK()
def __failCompletedJobs( self ):
""" Failed Jobs stuck in Completed Status for a long time.
They are due to pilots being killed during the
finalization of the job execution.
"""
# Get old Completed Jobs
checkTime = str( dateTime() - self.completedTime * second )
result = self.jobDB.selectJobs( {'Status':'Completed'}, older = checkTime )
if not result['OK']:
self.log.error( 'Failed to select jobs', result['Message'] )
return result
jobIDs = result['Value']
if not jobIDs:
return S_OK()
# Remove those with Minor Status "Pending Requests"
for jobID in jobIDs:
result = self.jobDB.getJobAttributes( jobID, ['Status','MinorStatus'] )
if not result['OK']:
self.log.error( 'Failed to get job attributes', result['Message'] )
continue
if result['Value']['Status'] != "Completed":
continue
if result['Value']['MinorStatus'] == "Pending Requests":
continue
result = self.__updateJobStatus( jobID, 'Failed',
"Job died during finalization" )
result = self.__sendAccounting( jobID )
if not result['OK']:
self.log.error( 'Failed to send accounting', result['Message'] )
continue
return S_OK()
示例2: StalledJobAgent
# 需要导入模块: from DIRAC.WorkloadManagementSystem.DB.JobDB import JobDB [as 别名]
# 或者: from DIRAC.WorkloadManagementSystem.DB.JobDB.JobDB import rescheduleJobs [as 别名]
#.........这里部分代码省略.........
if not startTime or startTime == "None":
# status, minor, app, stime, source
for items in logList:
if items[0] == "Running":
startTime = items[3]
break
if not startTime or startTime == "None":
startTime = jobDict["SubmissionTime"]
if type(startTime) in types.StringTypes:
startTime = fromString(startTime)
if startTime == None:
self.log.error("Wrong timestamp in DB", items[3])
startTime = dateTime()
endTime = dateTime()
# status, minor, app, stime, source
for items in logList:
if items[0] == "Stalled":
endTime = fromString(items[3])
if endTime == None:
self.log.error("Wrong timestamp in DB", items[3])
endTime = dateTime()
return startTime, endTime
def __kickStuckJobs(self):
""" Reschedule jobs stuck in initialization status Rescheduled, Matched
"""
message = ""
checkTime = str(dateTime() - self.matchedTime * second)
result = self.jobDB.selectJobs({"Status": "Matched"}, older=checkTime)
if not result["OK"]:
self.log.error("Failed to select jobs", result["Message"])
return result
jobIDs = result["Value"]
if jobIDs:
self.log.info("Rescheduling %d jobs stuck in Matched status" % len(jobIDs))
result = self.jobDB.rescheduleJobs(jobIDs)
if "FailedJobs" in result:
message = "Failed to reschedule %d jobs stuck in Matched status" % len(result["FailedJobs"])
checkTime = str(dateTime() - self.rescheduledTime * second)
result = self.jobDB.selectJobs({"Status": "Rescheduled"}, older=checkTime)
if not result["OK"]:
self.log.error("Failed to select jobs", result["Message"])
return result
jobIDs = result["Value"]
if jobIDs:
self.log.info("Rescheduling %d jobs stuck in Rescheduled status" % len(jobIDs))
result = self.jobDB.rescheduleJobs(jobIDs)
if "FailedJobs" in result:
if message:
message += "\n"
message += "Failed to reschedule %d jobs stuck in Rescheduled status" % len(result["FailedJobs"])
if message:
return S_ERROR(message)
else:
return S_OK()
def __failCompletedJobs(self):
""" Failed Jobs stuck in Completed Status for a long time.
They are due to pilots being killed during the
finalization of the job execution.
"""
# Get old Completed Jobs
checkTime = str(dateTime() - self.completedTime * second)
result = self.jobDB.selectJobs({"Status": "Completed"}, older=checkTime)
if not result["OK"]:
self.log.error("Failed to select jobs", result["Message"])
return result
jobIDs = result["Value"]
if not jobIDs:
return S_OK()
# Remove those with Minor Status "Pending Requests"
for jobID in jobIDs:
result = self.jobDB.getJobAttributes(jobID, ["Status", "MinorStatus"])
if not result["OK"]:
self.log.error("Failed to get job attributes", result["Message"])
continue
if result["Value"]["Status"] != "Completed":
continue
if result["Value"]["MinorStatus"] == "Pending Requests":
continue
result = self.__updateJobStatus(jobID, "Failed", "Job died during finalization")
result = self.__sendAccounting(jobID)
if not result["OK"]:
self.log.error("Failed to send accounting", result["Message"])
continue
return S_OK()