OptimizerModule

The Optimizer base class is an agent that polls for jobs with a specific status and minor status pair. The checkJob method is overridden for all optimizer instances and associated actions are performed there.

class DIRAC.WorkloadManagementSystem.Agent.OptimizerModule.OptimizerModule(agentName, loadName, baseAgentName=False, properties={})

Bases: DIRAC.Core.Base.AgentModule.AgentModule

The specific agents must provide the following methods:

  • initialize() for initial settings
  • beginExecution()
  • execute() - the main method called in the agent cycle
  • endExecution()
  • finalize() - the graceful exit of the method, this one is usually used
    for the agent restart
__init__(agentName, loadName, baseAgentName=False, properties={})

Common __init__ method for all Agents. All Agent modules must define: __doc__ __RCSID__ They are used to populate __codeProperties

The following Options are used from the Configuration: - /LocalSite/InstancePath - /DIRAC/Setup - Status - Enabled - PollingTime default = 120 - MaxCycles default = 500 - WatchdogTime default = 0 (disabled) - ControlDirectory control/SystemName/AgentName - WorkDirectory work/SystemName/AgentName - shifterProxy ‘’ - shifterProxyLocation WorkDirectory/SystemName/AgentName/.shifterCred

It defines the following default Options that can be set via Configuration (above): - MonitoringEnabled True - Enabled True if Status == Active - PollingTime 120 - MaxCycles 500 - ControlDirectory control/SystemName/AgentName - WorkDirectory work/SystemName/AgentName - shifterProxy False - shifterProxyLocation work/SystemName/AgentName/.shifterCred

different defaults can be set in the initialize() method of the Agent using am_setOption()

In order to get a shifter proxy in the environment during the execute() the configuration Option ‘shifterProxy’ must be set, a default may be given in the initialize() method.

am_Enabled()
am_checkStopAgentFile()
am_createStopAgentFile()
am_disableMonitoring()
am_getBasePath()
am_getControlDirectory()
am_getCyclesDone()
am_getMaxCycles()
am_getModuleParam(optionName)
am_getOption(optionName, defaultValue=None)
am_getPollingTime()
am_getShifterProxyLocation()
am_getStopAgentFile()
am_getWatchdogTime()
am_getWorkDirectory()
am_go()
am_initialize(*initArgs)
am_monitoringEnabled()
am_removeStopAgentFile()
am_secureCall(functor, args=(), name=False)
am_setModuleParam(optionName, value)
am_setOption(optionName, value)
am_stopExecution()
beginExecution()
checkJob(job, classad)

This method controls the checking of the job, should be overridden in a subclass

endExecution()
execute()

The main agent execution method

finalize()
getJobDefinition(job, jobDef=False)

Retrieve JDL of the Job and return jobDef dictionary

getOptimizerJobInfo(job, reportName)

This method gets job optimizer information that will be used for

initialize(jobDB=False, logDB=False)

Initialization of the Optimizer Agent.

initializeOptimizer()

To be overwritten by inheriting class

optimizeJob(job, classAdJob)

Call the corresponding Optimizer checkJob method

sendAccountingRecord(job, msg, classAdJob)

Send and accounting record for the failed job

setFailedJob(job, msg, classAdJob=None)

This method moves the job to the failed status

setJobParam(job, reportName, value)

This method updates a job parameter in the JobDB.

setNextOptimizer(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.

setOptimizerChain(job, value)

This method sets the job optimizer chain, in principle only needed by one of the optimizers.

setOptimizerJobInfo(job, reportName, value)

This method sets the job optimizer information that will subsequently be used for job scheduling and TURL queries on the WN.

updateJobStatus(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.