Skip to content

Commit

Permalink
feat: added index template for ElasticJobParametersDB
Browse files Browse the repository at this point in the history
  • Loading branch information
fstagni committed Jun 27, 2024
1 parent 540ce47 commit 463e597
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions src/DIRAC/WorkloadManagementSystem/DB/ElasticJobParametersDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,24 @@
from DIRAC.Core.Utilities import TimeUtilities

mapping = {
"properties": {
"JobID": {"type": "long"},
"timestamp": {"type": "date"},
"CPUNormalizationFactor": {"type": "long"},
"NormCPUTime(s)": {"type": "long"},
"Memory(kB)": {"type": "long"},
"TotalCPUTime(s)": {"type": "long"},
"MemoryUsed(kb)": {"type": "long"},
"HostName": {"type": "keyword"},
"GridCE": {"type": "keyword"},
"ModelName": {"type": "keyword"},
"Status": {"type": "keyword"},
"JobType": {"type": "keyword"},
}
"JobID": {"type": "long"},
"timestamp": {"type": "date"},
"PilotAgent": {"type": "keyword"},
"Pilot_Reference": {"type": "keyword"},
"JobGroup": {"type": "keyword"},
"CPUNormalizationFactor": {"type": "long"},
"NormCPUTime(s)": {"type": "long"},
"Memory(MB)": {"type": "long"},
"LocalAccount": {"type": "keyword"},
"TotalCPUTime(s)": {"type": "long"},
"PayloadPID": {"type": "long"},
"HostName": {"type": "text"},
"GridCE": {"type": "keyword"},
"CEQueue": {"type": "keyword"},
"BatchSystem": {"type": "keyword"},
"ModelName": {"type": "keyword"},
"Status": {"type": "keyword"},
"JobType": {"type": "keyword"},
}


Expand All @@ -42,6 +46,7 @@ def __init__(self, parentLogger=None):
super().__init__(self.fullname, self.index_name, parentLogger=parentLogger)
except Exception as ex:
raise RuntimeError("Can't connect to ElasticJobParametersDB") from ex
self.addIndexTemplate("elasticjobparametersdb", index_patterns=[f"{self.index_name}_*"], mapping=mapping)

def _indexName(self, jobID: int) -> str:
"""construct the index name
Expand All @@ -59,7 +64,7 @@ def _createIndex(self, indexName: str) -> None:
# Verifying if the index is there, and if not create it
res = self.existingIndex(indexName)
if not res["OK"] or not res["Value"]:
result = self.createIndex(indexName, mapping, period=None)
result = self.createIndex(indexName, period=None)
if not result["OK"]:
self.log.error(result["Message"])
raise RuntimeError(result["Message"])
Expand Down

0 comments on commit 463e597

Please sign in to comment.