Skip to content

Commit 3586349

Browse files
committed
fix: restored use of GridType
1 parent 4fe674d commit 3586349

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

src/DIRAC/WorkloadManagementSystem/Agent/StatesAccountingAgent.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class StatesAccountingAgent(AgentModule):
4545
__renameFieldsMapping = {"JobType": "JobSplitType"}
4646

4747
# PilotsHistory fields
48-
__pilotsMapping = ["GridSite", "GridType", "Status", "VO", "NumOfPilots"]
48+
__pilotsMapping = ["GridSite", "ComputingElement", "GridType", "Status", "VO", "NumOfPilots"]
4949

5050
def initialize(self):
5151
"""Standard initialization"""
@@ -89,7 +89,7 @@ def execute(self):
8989
# PilotsHistory to Monitoring
9090
if "Monitoring" in self.pilotMonitoringOption:
9191
self.log.info("Committing PilotsHistory to Monitoring")
92-
sql = "SELECT * FROM PilotsHistorySummary ORDER BY GridSite, DestinationSite, Status, VO;"
92+
sql = "SELECT * FROM PilotsHistorySummary ORDER BY GridSite, ComputingElement, GridType, Status, VO;"
9393
result = PilotAgentsDB()._query(sql)
9494
now = datetime.datetime.utcnow()
9595
if not result["OK"]:

src/DIRAC/WorkloadManagementSystem/DB/PilotAgentsDB.sql

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,11 @@ DROP TABLE IF EXISTS `PilotsHistorySummary`;
7474
CREATE TABLE `PilotsHistorySummary` (
7575
`GridSite` VARCHAR(128),
7676
`ComputingElement` VARCHAR(128),
77+
`GridType` VARCHAR(128),
7778
`Status` VARCHAR(32),
7879
`VO` VARCHAR(64),
7980
`PilotCount` INT,
80-
PRIMARY KEY (`GridSite`,`ComputingElement`,`Status`, `VO`)
81+
PRIMARY KEY (`GridSite`,`ComputingElement`,`GridType`,`Status`, `VO`)
8182
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
8283

8384

@@ -89,8 +90,8 @@ CREATE TRIGGER trg_PilotAgents_insert
8990
AFTER INSERT ON PilotAgents
9091
FOR EACH ROW
9192
BEGIN
92-
INSERT INTO PilotsHistorySummary (GridSite, ComputingElement, Status, VO, PilotCount)
93-
VALUES (NEW.GridSite, NEW.DestinationSite, NEW.Status, NEW.VO, 1)
93+
INSERT INTO PilotsHistorySummary (GridSite, ComputingElement, GridType, Status, VO, PilotCount)
94+
VALUES (NEW.GridSite, NEW.DestinationSite, NEW.GridType, NEW.Status, NEW.VO, 1)
9495
ON DUPLICATE KEY UPDATE PilotCount = PilotCount + 1;
9596
END;
9697
//
@@ -103,6 +104,7 @@ BEGIN
103104
SET PilotCount = PilotCount - 1
104105
WHERE GridSite = OLD.GridSite
105106
AND ComputingElement = OLD.DestinationSite
107+
AND GridType = OLD.GridType
106108
AND Status = OLD.Status
107109
AND VO = OLD.VO;
108110

@@ -111,6 +113,7 @@ BEGIN
111113
WHERE PilotCount = 0
112114
AND GridSite = OLD.GridSite
113115
AND ComputingElement = OLD.DestinationSite
116+
AND GridType = OLD.GridType
114117
AND Status = OLD.Status
115118
AND VO = OLD.VO;
116119
END;
@@ -127,15 +130,16 @@ BEGIN
127130
SET PilotCount = PilotCount - 1
128131
WHERE GridSite = OLD.GridSite
129132
AND ComputingElement = OLD.DestinationSite
133+
AND GridType = OLD.GridType
130134
AND Status = OLD.Status
131135
AND VO = OLD.VO;
132136

133137
-- Delete row if count drops to zero
134138
DELETE FROM PilotsHistorySummary WHERE PilotCount = 0;
135139

136140
-- Increase count for new status
137-
INSERT INTO PilotsHistorySummary (GridSite, ComputingElement, Status, VO, PilotCount)
138-
VALUES (NEW.GridSite, NEW.DestinationSite, NEW.Status, NEW.VO, 1)
141+
INSERT INTO PilotsHistorySummary (GridSite, ComputingElement, GridType, Status, VO, PilotCount)
142+
VALUES (NEW.GridSite, NEW.DestinationSite, NEW.GridType, NEW.Status, NEW.VO, 1)
139143
ON DUPLICATE KEY UPDATE PilotCount = PilotCount + 1;
140144

141145
END IF;

tests/Integration/WorkloadManagementSystem/Test_PilotAgentsDB.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,16 +249,16 @@ def test_summarySnapshot():
249249
sql = f"INSERT INTO PilotAgents (InitialJobID, CurrentJobID, PilotJobReference, PilotStamp, DestinationSite, Queue, GridSite, VO, GridType, BenchMark, SubmissionTime, LastUpdateTime, Status, StatusReason, AccountingSent) VALUES ({placeholders})"
250250
res = paDB._updatemany(sql, processed_data)
251251
assert res["OK"], res["Message"]
252-
sql = "SELECT * FROM PilotsHistorySummary ORDER BY GridSite, DestinationSite, Status, VO;"
252+
sql = "SELECT * FROM PilotsHistorySummary ORDER BY GridSite, ComputingElement, GridType, Status, VO;"
253253
result = PilotAgentsDB()._query(sql)
254254
assert result["OK"], result["Message"]
255255
values = result["Value"][1]
256-
assert len(values) == 5, "Expected 5 record in the summary"
256+
assert len(values) == 6, "Expected 6 record in the summary"
257257
# Check it corresponds to the basic "GROUP BY" query
258-
sql = "SELECT GridSite, DestinationSite, Status, VO, COUNT(*) FROM PilotAgents GROUP BY GridSite, DestinationSite, Status, VO ORDER BY GridSite, DestinationSite, Status, VO;"
258+
sql = "SELECT GridSite, DestinationSite, GridType, Status, VO, COUNT(*) FROM PilotAgents GROUP BY GridSite, DestinationSite, GridType, Status, VO ORDER BY GridSite, DestinationSite, GridType, Status, VO;"
259259
result_grouped = PilotAgentsDB()._query(sql)
260260
assert result_grouped["OK"], result_grouped["Message"]
261-
sql = "SELECT * FROM PilotsHistorySummary ORDER BY GridSite, DestinationSite, Status, VO;"
261+
sql = "SELECT * FROM PilotsHistorySummary ORDER BY GridSite, ComputingElement, GridType, Status, VO;"
262262
result_summary = PilotAgentsDB()._query(sql)
263263
assert result_summary["OK"], result_summary["Message"]
264264
assert result_grouped["Value"] == result_summary["Value"], "Summary and grouped query results differ"
@@ -274,10 +274,10 @@ def test_summarySnapshot():
274274
res = paDB._update(sql)
275275
assert res["OK"], res["Message"]
276276
# Check it corresponds to the basic "GROUP BY" query
277-
sql = "SELECT GridSite, DestinationSite, Status, VO, COUNT(*) FROM PilotAgents GROUP BY GridSite, DestinationSite, Status, VO ORDER BY GridSite, DestinationSite, Status, VO;"
277+
sql = "SELECT GridSite, DestinationSite, GridType, Status, VO, COUNT(*) FROM PilotAgents GROUP BY GridSite, DestinationSite, GridType, Status, VO ORDER BY GridSite, DestinationSite, GridType, Status, VO;"
278278
result_grouped = PilotAgentsDB()._query(sql)
279279
assert result_grouped["OK"], result_grouped["Message"]
280-
sql = "select * FROM PilotsHistorySummary ORDER BY GridSite, DestinationSite, Status, VO;"
280+
sql = "select * FROM PilotsHistorySummary ORDER BY GridSite, ComputingElement, GridType, Status, VO;"
281281
result_summary = PilotAgentsDB()._query(sql)
282282
assert result_summary["OK"], result_summary["Message"]
283283
assert result_grouped["Value"] == result_summary["Value"], "Summary and grouped query results differ"

0 commit comments

Comments
 (0)