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 Apr 23, 2024
1 parent 764ae22 commit efa723a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
- setPilotParameter()
- deletePilotParameters()
"""
from DIRAC import S_OK, S_ERROR, gConfig
from DIRAC.Core.Utilities import TimeUtilities
from DIRAC.ConfigurationSystem.Client.PathFinder import getDatabaseSection
from DIRAC import S_ERROR, S_OK, gConfig
from DIRAC.ConfigurationSystem.Client.Helpers import CSGlobals
from DIRAC.ConfigurationSystem.Client.PathFinder import getDatabaseSection
from DIRAC.Core.Base.ElasticDB import ElasticDB

from DIRAC.Core.Utilities import TimeUtilities

mapping = {
"properties": {
Expand Down
23 changes: 23 additions & 0 deletions src/DIRAC/WorkloadManagementSystem/Service/PilotManagerHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ def initializeHandler(cls, serviceInfoDict):
defaultOption, defaultClass = "DownloadPlugin", "FileCacheDownloadPlugin"
cls.configValue = getServiceOption(serviceInfoDict, defaultOption, defaultClass)
cls.loggingPlugin = None
cls.elasticPilotParametersDB = None
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 @@ -479,3 +490,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()
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,6 @@ def test_setAndGetPilotFromDB():
assert len(res["Value"][1010000]) == 0

# delete the indexes
res = elasticPilotParametersDB.deleteIndex(elasticPilotParametersDB.indexName_base)
assert res["OK"]
assert res["Value"] == "Nothing to delete"
res = elasticPilotParametersDB.deleteIndex(elasticPilotParametersDB._indexName(100))
assert res["OK"]
res = elasticPilotParametersDB.deleteIndex(elasticPilotParametersDB._indexName(1010000))
Expand Down

0 comments on commit efa723a

Please sign in to comment.