Skip to content

Commit

Permalink
feat: PilotManager can interact with ElasticPilotParameters
Browse files Browse the repository at this point in the history
  • Loading branch information
fstagni committed Aug 8, 2023
1 parent c53cd0d commit a48f466
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/DIRAC/WorkloadManagementSystem/Service/PilotManagerHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

from DIRAC.Core.DISET.RequestHandler import RequestHandler
from DIRAC.Core.Utilities.ObjectLoader import ObjectLoader
from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
from DIRAC.ConfigurationSystem.Client.Helpers.Registry import getUsernameForDN, getDNForUsername
from DIRAC.WorkloadManagementSystem.DB.ElasticPilotParametersDB import ElasticPilotParametersDB
from DIRAC.WorkloadManagementSystem.Client import PilotStatus
from DIRAC.WorkloadManagementSystem.Service.WMSUtilities import (
getPilotCE,
Expand All @@ -33,6 +35,18 @@ def initializeHandler(cls, serviceInfoDict):
except RuntimeError as excp:
return S_ERROR(f"Can't connect to DB: {excp}")

cls.elasticPilotParametersDB = None
if Operations().getValue("/Services/JobMonitoring/useESForPilotParametersFlag", False):
try:
result = ObjectLoader().loadObject(
"WorkloadManagementSystem.DB.ElasticPilotParametersDB", "ElasticPilotParametersDB"
)
if not result["OK"]:
return result
cls.elasticPilotParametersDB = result["Value"]()
except RuntimeError as excp:
return S_ERROR(f"Can't connect to DB: {excp}")

return S_OK()

##############################################################################
Expand Down Expand Up @@ -483,3 +497,15 @@ def export_deletePilots(cls, pilotIDs):
@classmethod
def export_clearPilots(cls, interval=30, aborted_interval=7):
return cls.pilotAgentsDB.clearPilots(interval, aborted_interval)

#### ElasticPilotParameters

types_setPilotParameters = [int, str, str]

@classmethod
def export_setPilotParameter(cls, pilotID, key, value):
"""Set Pilot parameters"""
if cls.elasticPilotParametersDB:
return cls.elasticPilotParametersDB.setPilotParameter(pilotID, key, value)

return S_OK()

0 comments on commit a48f466

Please sign in to comment.