1616
1717# # from DIRAC
1818from DIRAC import S_ERROR , S_OK
19- from DIRAC .ConfigurationSystem .Client .ConfigurationData import gConfigurationData
2019from DIRAC .ConfigurationSystem .Client .Helpers .Operations import Operations
2120from DIRAC .Core .Base .AgentModule import AgentModule
2221from DIRAC .Core .Utilities .DErrno import cmpError
2322from DIRAC .Core .Utilities .List import breakListIntoChunks
2423from DIRAC .Core .Utilities .Proxy import executeWithUserProxy
2524from DIRAC .Core .Utilities .ReturnValues import returnSingleResult
26- from DIRAC .DataManagementSystem .Client .DataManager import DataManager
2725from DIRAC .RequestManagementSystem .Client .File import File
2826from DIRAC .RequestManagementSystem .Client .Operation import Operation
2927from DIRAC .RequestManagementSystem .Client .ReqClient import ReqClient
3432from DIRAC .Resources .Storage .StorageElement import StorageElement
3533from DIRAC .TransformationSystem .Client import TransformationStatus
3634from DIRAC .TransformationSystem .Client .TransformationClient import TransformationClient
37- from DIRAC .WorkloadManagementSystem .Client .JobMonitoringClient import JobMonitoringClient
3835from DIRAC .WorkloadManagementSystem .Client .WMSClient import WMSClient
36+ from DIRAC .WorkloadManagementSystem .DB .JobDB import JobDB
3937
4038# # agent's name
4139AGENT_NAME = "Transformation/TransformationCleaningAgent"
@@ -45,7 +43,6 @@ class TransformationCleaningAgent(AgentModule):
4543 """
4644 .. class:: TransformationCleaningAgent
4745
48- :param ~DIRAC.DataManagementSystem.Client.DataManager.DataManager dm: DataManager instance
4946 :param ~TransformationClient.TransformationClient transClient: TransformationClient instance
5047 :param ~FileCatalogClient.FileCatalogClient metadataClient: FileCatalogClient instance
5148
@@ -125,8 +122,8 @@ def initialize(self):
125122 self .reqClient = ReqClient ()
126123 # # file catalog client
127124 self .metadataClient = FileCatalogClient ()
128- # # job monitoring client
129- self .jobMonitoringClient = JobMonitoringClient ()
125+ # # job DB
126+ self .jobDB = JobDB ()
130127
131128 return S_OK ()
132129
@@ -224,7 +221,8 @@ def finalize(self):
224221 So, we should just clean from time to time.
225222 What I added here is done only when the agent finalize, and it's quite light-ish operation anyway.
226223 """
227- res = self .jobMonitoringClient .getJobGroups (None , datetime .utcnow () - timedelta (days = 365 ))
224+
225+ res = self .jobDB .getDistinctJobAttributes ("JobGroup" , older = datetime .utcnow () - timedelta (days = 365 ))
228226 if not res ["OK" ]:
229227 self .log .error ("Failed to get job groups" , res ["Message" ])
230228 return res
@@ -268,7 +266,7 @@ def finalize(self):
268266
269267 # Remove JobIDs that were unknown to the TransformationSystem
270268 jobGroupsToCheck = [str (transDict ["TransformationID" ]).zfill (8 ) for transDict in toClean + toArchive ]
271- res = self .jobMonitoringClient . getJobs ({"JobGroup" : jobGroupsToCheck })
269+ res = self .jobDB . selectJobs ({"JobGroup" : jobGroupsToCheck })
272270 if not res ["OK" ]:
273271 return res
274272 jobIDsToRemove = [int (jobID ) for jobID in res ["Value" ]]
0 commit comments