JobDB

DIRAC JobDB class is a front-end to the main WMS database containing job definitions and status information. It is used in most of the WMS components

The following methods are provided for public usage:

getJobAttribute() getJobAttributes() getAllJobAttributes() getDistinctJobAttributes() getAttributesForJobList() getJobParameter() getJobParameters() getAllJobParameters() getInputData() getJobJDL()

selectJobs() selectJobsWithStatus()

setJobAttribute() setJobAttributes() setJobParameter() setJobParameters() setJobJDL() setJobStatus() setInputData()

insertNewJobIntoDB() removeJobFromDB()

rescheduleJob() rescheduleJobs()

getMask() setMask() allowSiteInMask() banSiteInMask()

getCounters()

class DIRAC.WorkloadManagementSystem.DB.JobDB.JobDB

Bases: DIRAC.Core.Base.DB.DB

class ConnectionPool(host, user, passwd, port=3306, graceTime=600)

Bases: object

Management of connections per thread

clean(now=False)
get(dbName, retries=10)
transactionCommit(dbName)
transactionRollback(dbName)
transactionStart(dbName)
allowSiteInMask(site, authorDN='Unknown', comment='No comment')

Forbid the given site in the Site Mask

banSiteInMask(site, authorDN='Unknown', comment='No comment')

Forbid the given site in the Site Mask

buildCondition(condDict=None, older=None, newer=None, timeStamp=None, orderAttribute=None, limit=False, greater=None, smaller=None, offset=None)

Build SQL condition statement from provided condDict and other extra check on a specified time stamp. The conditions dictionary specifies for each attribute one or a List of possible values greater and smaller are dictionaries in which the keys are the names of the fields, that are requested to be >= or < than the corresponding value. For compatibility with current usage it uses Exceptions to exit in case of invalid arguments

countEntries(table, condDict, older=None, newer=None, timeStamp=None, connection=False, greater=None, smaller=None)

Count the number of entries wit the given conditions

deleteEntries(tableName, condDict=None, limit=False, conn=None, older=None, newer=None, timeStamp=None, orderAttribute=None, greater=None, smaller=None)

Delete rows from “tableName” with N records can match the condition if limit is not False, the given limit is set String type values will be appropriately escaped, they can be single values or lists of values.

executeStoredProcedure(packageName, parameters, outputIds)
executeStoredProcedureWithCursor(packageName, parameters)
getAllSiteMaskStatus()

Get the everything from site mask status

getAtticJobParameters(jobID, paramList=None, rescheduleCounter=-1)

Get Attic Job Parameters defined for a job with jobID. Returns a dictionary with the Attic Job Parameters per each rescheduling cycle. If parameterList is empty - all the parameters are returned. If recheduleCounter = -1, all cycles are returned.

getAttributesForJobList(jobIDList, attrList=None)

Get attributes for the jobs in the the jobIDList. Returns an S_OK structure with a dictionary of dictionaries as its Value: ValueDict[jobID][attribute_name] = attribute_value

getCSOption(optionName, defaultValue=None)
getCounters(table, attrList, condDict, older=None, newer=None, timeStamp=None, connection=False, greater=None, smaller=None)

Count the number of records on each distinct combination of AttrList, selected with condition defined by condDict and time stamps

getDistinctAttributeValues(table, attribute, condDict=None, older=None, newer=None, timeStamp=None, connection=False, greater=None, smaller=None)

Get distinct values of a table attribute under specified conditions

getDistinctJobAttributes(attribute, condDict=None, older=None, newer=None, timeStamp='LastUpdateTime')

Get distinct values of the job attribute under specified conditions

getFields(tableName, outFields=None, condDict=None, limit=False, conn=None, older=None, newer=None, timeStamp=None, orderAttribute=None, greater=None, smaller=None)

Select “outFields” from “tableName” with condDict N records can match the condition return S_OK( tuple(Field,Value) ) if outFields is None all fields in “tableName” are returned if limit is not False, the given limit is set inValues are properly escaped using the _escape_string method, they can be single values or lists of values.

getHeartBeatData(jobID)

Retrieve the job’s heart beat data

getInputData(jobID)

Get input data for the given job

getJobAttribute(jobID, attribute)

Get the given attribute of a job specified by its jobID

getJobAttributes(jobID, attrList=None)

Get all Job Attributes for a given jobID. Return a dictionary with all Job Attributes, return an empty dictionary if matching job found

getJobCommand(jobID, status='Received')

Get a command to be passed to the job together with the next heart beat

getJobJDL(jobID, original=False, status='')

Get JDL for job specified by its jobID. By default the current job JDL is returned. If ‘original’ argument is True, original JDL is returned

getJobOptParameter(jobID, parameter)

Get optimizer parameters for the given job.

getJobOptParameters(jobID, paramList=None)

Get optimizer parameters for the given job. If the list of parameter names is empty, get all the parameters then

getJobParameter(jobID, parameter)

Get the given parameter of a job specified by its jobID

getJobParameters(jobID, paramList=None)

Get Job Parameters defined for jobID. Returns a dictionary with the Job Parameters. If parameterList is empty - all the parameters are returned.

getSiteMask(siteState='Active')

Get the currently active site list

getSiteMaskLogging(siteList)

Get the site mask logging history for the list if site names

getSiteMaskStatus(sites=None)

Get the current site mask status :param:sites - A string for a single site to check, or a list

to check multiple sites.
:returns:If input was a list, a dictionary of sites, keys are site
names and values are the site statuses. Unknown sites are not included in the output dictionary. If input was a string, then a single value with that site’s status, or S_ERROR if the site does not exist in the DB.
getSiteSummary()

Get the summary of jobs in a given status on all the sites

getSiteSummaryWeb(selectDict, sortList, startItem, maxItems)

Get the summary of jobs in a given status on all the sites in the standard Web form

getSummarySnapshot(requestedFields=False)

Get the summary snapshot for a given combination

getUserSitesTuple(sites)

Returns tuple of active/banned/invalid sties from a user provided list.

insertFields(tableName, inFields=None, inValues=None, conn=None, inDict=None)

Insert a new row in “tableName” assigning the values “inValues” to the fields “inFields”. String type values will be appropriately escaped.

insertNewJobIntoDB(jdl, owner, ownerDN, ownerGroup, diracSetup)

Insert the initial JDL into the Job database, Do initial JDL crosscheck, Set Initial job Attributes and Status

removeJobFromDB(jobIDs)

Remove job from DB

Remove job from the Job DB and clean up all the job related data in various tables

removeJobOptParameter(jobID, name)

Remove the specified optimizer parameter for jobID

removeSiteFromMask(site=None)

Remove the given site from the mask

rescheduleJob(jobID)

Reschedule the given job to run again from scratch. Retain the already defined parameters in the parameter Attic

rescheduleJobs(jobIDs)

Reschedule all the jobs in the given list

selectJobs(condDict, older=None, newer=None, timeStamp='LastUpdateTime', orderAttribute=None, limit=None)

Select jobs matching the following conditions: - condDict dictionary of required Key = Value pairs; - with the last update date older and/or newer than given dates;

The result is ordered by JobID if requested, the result is limited to a given number of jobs if requested.

setAtticJobParameter(jobID, key, value, rescheduleCounter)

Set attic parameter for job specified by its jobID when job rescheduling for later debugging

setEndExecTime(jobID, endDate=None)

Set EndExecTime time stamp

setHeartBeatData(jobID, staticDataDict, dynamicDataDict)

Add the job’s heart beat data to the database

setInputData(jobID, inputData)

Inserts input data for the given job

setJobAttribute(jobID, attrName, attrValue, update=False, myDate=None)

Set an attribute value for job specified by jobID. The LastUpdate time stamp is refreshed if explicitly requested

setJobAttributes(jobID, attrNames, attrValues, update=False, myDate=None)

Set an attribute value for job specified by jobID. The LastUpdate time stamp is refreshed if explicitely requested

setJobCommand(jobID, command, arguments=None)

Store a command to be passed to the job together with the next heart beat

setJobCommandStatus(jobID, command, status)

Set the command status

setJobJDL(jobID, jdl=None, originalJDL=None)

Insert JDL’s for job specified by jobID

setJobOptParameter(jobID, name, value)

Set an optimzer parameter specified by name,value pair for the job JobID

setJobParameter(jobID, key, value)

Set a parameter specified by name,value pair for the job JobID

setJobParameters(jobID, parameters)

Set parameters specified by a list of name/value pairs for the job JobID

setJobStatus(jobID, status='', minor='', application='', appCounter=None)

Set status of the job specified by its jobID

setNextOptimizer(jobID, currentOptimizer)

Set the job status to be processed by the next optimizer in the chain

setOptimizerChain(jobID, optimizerList)

Set the optimizer chain for the given job. The ‘TaskQueue’ optimizer should be the last one in the chain, it is added if not present in the optimizerList

setSiteMask(siteMaskList, authorDN='Unknown', comment='No comment')

Set the Site Mask to the given mask in a form of a list of tuples (site,status)

setStartExecTime(jobID, startDate=None)

Set StartExecTime time stamp

traceJobParameter(site, localID, parameter, date=None, until=None)
traceJobParameters(site, localIDs, paramList=None, attributeList=None, date=None, until=None)
transactionCommit()
transactionRollback()
transactionStart()
updateFields(tableName, updateFields=None, updateValues=None, condDict=None, limit=False, conn=None, updateDict=None, older=None, newer=None, timeStamp=None, orderAttribute=None, greater=None, smaller=None)

Update “updateFields” from “tableName” with “updateValues”. updateDict alternative way to provide the updateFields and updateValues N records can match the condition return S_OK( number of updated rows ) if limit is not False, the given limit is set String type values will be appropriately escaped.