本文整理汇总了Python中DIRAC.WorkloadManagementSystem.DB.JobLoggingDB.JobLoggingDB.addLoggingRecord方法的典型用法代码示例。如果您正苦于以下问题:Python JobLoggingDB.addLoggingRecord方法的具体用法?Python JobLoggingDB.addLoggingRecord怎么用?Python JobLoggingDB.addLoggingRecord使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DIRAC.WorkloadManagementSystem.DB.JobLoggingDB.JobLoggingDB
的用法示例。
在下文中一共展示了JobLoggingDB.addLoggingRecord方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Matcher
# 需要导入模块: from DIRAC.WorkloadManagementSystem.DB.JobLoggingDB import JobLoggingDB [as 别名]
# 或者: from DIRAC.WorkloadManagementSystem.DB.JobLoggingDB.JobLoggingDB import addLoggingRecord [as 别名]
#.........这里部分代码省略.........
for name in singleValueDefFields:
if resourceDescription.has_key( name ):
resourceDict[name] = resourceDescription[name]
for name in multiValueMatchFields:
if resourceDescription.has_key( name ):
resourceDict[name] = resourceDescription[name]
if resourceDescription.has_key( 'JobID' ):
resourceDict['JobID'] = resourceDescription['JobID']
for k in ( 'DIRACVersion', 'ReleaseVersion', 'ReleaseProject', 'VirtualOrganization',
'PilotReference', 'PilotBenchmark', 'PilotInfoReportedFlag' ):
if k in resourceDescription:
resourceDict[ k ] = resourceDescription[ k ]
return resourceDict
def _reportStatus( self, resourceDict, jobID ):
""" Reports the status of the matched job in jobDB and jobLoggingDB
Do not fail if errors happen here
"""
attNames = ['Status', 'MinorStatus', 'ApplicationStatus', 'Site']
attValues = ['Matched', 'Assigned', 'Unknown', resourceDict['Site']]
result = self.jobDB.setJobAttributes( jobID, attNames, attValues )
if not result['OK']:
self.log.error( "Problem reporting job status", "setJobAttributes, jobID = %s: %s" % ( jobID, result['Message'] ) )
else:
self.log.verbose( "Set job attributes for jobID %s" % jobID )
result = self.jlDB.addLoggingRecord( jobID,
status = 'Matched',
minor = 'Assigned',
source = 'Matcher' )
if not result['OK']:
self.log.error( "Problem reporting job status", "addLoggingRecord, jobID = %s: %s" % ( jobID, result['Message'] ) )
else:
self.log.verbose( "Added logging record for jobID %s" % jobID )
def _checkMask( self, resourceDict ):
""" Check the mask: are we allowed to run normal jobs?
FIXME: should we move to site OR SE?
"""
if not 'Site' in resourceDict:
self.log.error( "Missing Site Name in Resource JDL" )
raise RuntimeError( "Missing Site Name in Resource JDL" )
# Get common site mask and check the agent site
result = self.jobDB.getSiteMask( siteState = 'Active' )
if not result['OK']:
self.log.error( "Internal error", "getSiteMask: %s" % result['Message'] )
raise RuntimeError( "Internal error" )
maskList = result['Value']
if resourceDict['Site'] not in maskList:
return False
return True
def _updatePilotInfo( self, resourceDict ):
""" Update pilot information - do not fail if we don't manage to do it
示例2: StalledJobAgent
# 需要导入模块: from DIRAC.WorkloadManagementSystem.DB.JobLoggingDB import JobLoggingDB [as 别名]
# 或者: from DIRAC.WorkloadManagementSystem.DB.JobLoggingDB.JobLoggingDB import addLoggingRecord [as 别名]
#.........这里部分代码省略.........
lastUpdate = toEpoch( fromString( result['Value']['LastUpdateTime'] ) )
if latestUpdate < lastUpdate:
latestUpdate = lastUpdate
if not latestUpdate:
return S_ERROR( 'LastUpdate and HeartBeat times are null for job %s' % job )
else:
self.log.verbose( 'Latest update time from epoch for job %s is %s' % ( job, latestUpdate ) )
return S_OK( latestUpdate )
#############################################################################
def __updateJobStatus( self, job, status, minorstatus = None ):
""" This method updates the job status in the JobDB, this should only be
used to fail jobs due to the optimizer chain.
"""
self.log.verbose( "self.jobDB.setJobAttribute(%s,'Status','%s',update=True)" % ( job, status ) )
if self.am_getOption( 'Enable', True ):
result = self.jobDB.setJobAttribute( job, 'Status', status, update = True )
else:
result = S_OK( 'DisabledMode' )
if result['OK']:
if minorstatus:
self.log.verbose( "self.jobDB.setJobAttribute(%s,'MinorStatus','%s',update=True)" % ( job, minorstatus ) )
result = self.jobDB.setJobAttribute( job, 'MinorStatus', minorstatus, update = True )
if not minorstatus: #Retain last minor status for stalled jobs
result = self.jobDB.getJobAttributes( job, ['MinorStatus'] )
if result['OK']:
minorstatus = result['Value']['MinorStatus']
logStatus = status
result = self.logDB.addLoggingRecord( job, status = logStatus, minor = minorstatus, source = 'StalledJobAgent' )
if not result['OK']:
self.log.warn( result )
return result
def __getProcessingType( self, jobID ):
""" Get the Processing Type from the JDL, until it is promoted to a real Attribute
"""
processingType = 'unknown'
result = self.jobDB.getJobJDL( jobID, original = True )
if not result['OK']:
return processingType
classAdJob = ClassAd( result['Value'] )
if classAdJob.lookupAttribute( 'ProcessingType' ):
processingType = classAdJob.getAttributeString( 'ProcessingType' )
return processingType
#############################################################################
def __sendAccounting( self, jobID ):
""" Send WMS accounting data for the given job
"""
try:
accountingReport = Job()
endTime = 'Unknown'
lastHeartBeatTime = 'Unknown'
result = self.jobDB.getJobAttributes( jobID )
if not result['OK']:
return result
jobDict = result['Value']
示例3: OptimizerModule
# 需要导入模块: from DIRAC.WorkloadManagementSystem.DB.JobLoggingDB import JobLoggingDB [as 别名]
# 或者: from DIRAC.WorkloadManagementSystem.DB.JobLoggingDB.JobLoggingDB import addLoggingRecord [as 别名]
#.........这里部分代码省略.........
return S_OK(eval(value))
except BaseException as x:
return S_ERROR('Could not evaluate optimizer parameters: %s' % repr(x))
return result
#############################################################################
def setOptimizerJobInfo(self, job, reportName, value):
"""This method sets the job optimizer information that will subsequently
be used for job scheduling and TURL queries on the WN.
"""
self.log.verbose("self.jobDB.setJobOptParameter(%s,'%s','%s')" % (job, reportName, value))
if not self.am_Enabled():
return S_OK()
return self.jobDB.setJobOptParameter(job, reportName, str(value))
#############################################################################
def setOptimizerChain(self, job, value):
"""This method sets the job optimizer chain, in principle only needed by
one of the optimizers.
"""
self.log.verbose("self.jobDB.setOptimizerChain(%s,%s)" % (job, value))
if not self.am_Enabled():
return S_OK()
return self.jobDB.setOptimizerChain(job, value)
#############################################################################
def setNextOptimizer(self, job):
"""This method is executed when the optimizer instance has successfully
processed the job. The next optimizer in the chain will subsequently
start to work on the job.
"""
result = self.logDB.addLoggingRecord(job, status=self.startingMajorStatus,
minor=self.startingMinorStatus,
source=self.am_getModuleParam("optimizerName"))
if not result['OK']:
self.log.warn(result['Message'])
self.log.verbose("self.jobDB.setNextOptimizer(%s,'%s')" % (job, self.am_getModuleParam("optimizerName")))
return self.jobDB.setNextOptimizer(job, self.am_getModuleParam("optimizerName"))
#############################################################################
def updateJobStatus(self, job, status, minorStatus=None, appStatus=None):
"""This method updates the job status in the JobDB, this should only be
used to fail jobs due to the optimizer chain.
"""
self.log.verbose("self.jobDB.setJobStatus(%s,'Status/Minor/Application','%s'/'%s'/'%s',update=True)" %
(job, status, str(minorStatus), str(appStatus)))
if not self.am_Enabled():
return S_OK()
result = self.jobDB.setJobStatus(job, status, minorStatus, appStatus)
if not result['OK']:
return result
result = self.logDB.addLoggingRecord(job, status=status, minor=minorStatus, application=appStatus,
source=self.am_getModuleParam('optimizerName'))
if not result['OK']:
self.log.warn(result['Message'])
return S_OK()
#############################################################################
def setJobParam(self, job, reportName, value):
"""This method updates a job parameter in the JobDB.
示例4: StalledJobAgent
# 需要导入模块: from DIRAC.WorkloadManagementSystem.DB.JobLoggingDB import JobLoggingDB [as 别名]
# 或者: from DIRAC.WorkloadManagementSystem.DB.JobLoggingDB.JobLoggingDB import addLoggingRecord [as 别名]
#.........这里部分代码省略.........
lastUpdate = toEpoch(fromString(result["Value"]["LastUpdateTime"]))
if latestUpdate < lastUpdate:
latestUpdate = lastUpdate
if not latestUpdate:
return S_ERROR("LastUpdate and HeartBeat times are null for job %s" % job)
else:
self.log.verbose("Latest update time from epoch for job %s is %s" % (job, latestUpdate))
return S_OK(latestUpdate)
#############################################################################
def __updateJobStatus(self, job, status, minorstatus=None):
""" This method updates the job status in the JobDB, this should only be
used to fail jobs due to the optimizer chain.
"""
self.log.verbose("self.jobDB.setJobAttribute(%s,'Status','%s',update=True)" % (job, status))
if self.am_getOption("Enable", True):
result = self.jobDB.setJobAttribute(job, "Status", status, update=True)
else:
result = S_OK("DisabledMode")
if result["OK"]:
if minorstatus:
self.log.verbose("self.jobDB.setJobAttribute(%s,'MinorStatus','%s',update=True)" % (job, minorstatus))
result = self.jobDB.setJobAttribute(job, "MinorStatus", minorstatus, update=True)
if not minorstatus: # Retain last minor status for stalled jobs
result = self.jobDB.getJobAttributes(job, ["MinorStatus"])
if result["OK"]:
minorstatus = result["Value"]["MinorStatus"]
logStatus = status
result = self.logDB.addLoggingRecord(job, status=logStatus, minor=minorstatus, source="StalledJobAgent")
if not result["OK"]:
self.log.warn(result)
return result
def __getProcessingType(self, jobID):
""" Get the Processing Type from the JDL, until it is promoted to a real Attribute
"""
processingType = "unknown"
result = self.jobDB.getJobJDL(jobID, original=True)
if not result["OK"]:
return processingType
classAdJob = ClassAd(result["Value"])
if classAdJob.lookupAttribute("ProcessingType"):
processingType = classAdJob.getAttributeString("ProcessingType")
return processingType
#############################################################################
def __sendAccounting(self, jobID):
""" Send WMS accounting data for the given job
"""
try:
accountingReport = Job()
endTime = "Unknown"
lastHeartBeatTime = "Unknown"
result = self.jobDB.getJobAttributes(jobID)
if not result["OK"]:
return result
jobDict = result["Value"]
startTime, endTime = self.__checkLoggingInfo(jobID, jobDict)