Skip to content

Commit c5253ad

Browse files
committed
fix: removed endpoint from SpaceTokenOccupancyCache
1 parent c379267 commit c5253ad

4 files changed

Lines changed: 23 additions & 40 deletions

File tree

src/DIRAC/ResourceStatusSystem/Client/ResourceManagementClient.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -725,13 +725,11 @@ def addOrModifyPolicyResult(
725725
# SpaceTokenOccupancyCache Methods ...........................................
726726

727727
def selectSpaceTokenOccupancyCache(
728-
self, endpoint=None, token=None, total=None, guaranteed=None, free=None, lastCheckTime=None, meta=None
728+
self, token=None, total=None, guaranteed=None, free=None, lastCheckTime=None, meta=None
729729
):
730730
"""
731731
Gets from SpaceTokenOccupancyCache all rows that match the parameters given.
732732
733-
:param endpoint: endpoint
734-
:type endpoint: string, list
735733
:param token: name of the token
736734
:type token: string, list
737735
:param total: total terabytes
@@ -746,19 +744,15 @@ def selectSpaceTokenOccupancyCache(
746744
For example: meta={'columns': ['Name']} will return only the 'Name' column.
747745
:return: S_OK() || S_ERROR()
748746
"""
749-
columnNames = ["Endpoint", "Token", "Total", "Guaranteed", "Free", "LastCheckTime", "Meta"]
750-
columnValues = [endpoint, token, total, guaranteed, free, lastCheckTime, meta]
747+
columnNames = ["Token", "Total", "Guaranteed", "Free", "LastCheckTime", "Meta"]
748+
columnValues = [token, total, guaranteed, free, lastCheckTime, meta]
751749

752750
return self._getRPC().select("SpaceTokenOccupancyCache", prepareDict(columnNames, columnValues))
753751

754-
def deleteSpaceTokenOccupancyCache(
755-
self, endpoint=None, token=None, total=None, guaranteed=None, free=None, lastCheckTime=None
756-
):
752+
def deleteSpaceTokenOccupancyCache(self, token=None, total=None, guaranteed=None, free=None, lastCheckTime=None):
757753
"""
758754
Deletes from SpaceTokenOccupancyCache all rows that match the parameters given.
759755
760-
:param endpoint: endpoint
761-
:type endpoint: string, list
762756
:param token: name of the token
763757
:type token: string, list
764758
:param total: total terabytes
@@ -771,29 +765,27 @@ def deleteSpaceTokenOccupancyCache(
771765
:type lastCheckTime: datetime, list
772766
:return: S_OK() || S_ERROR()
773767
"""
774-
columnNames = ["Endpoint", "Token", "Total", "Guaranteed", "Free", "LastCheckTime"]
775-
columnValues = [endpoint, token, total, guaranteed, free, lastCheckTime]
768+
columnNames = ["Token", "Total", "Guaranteed", "Free", "LastCheckTime"]
769+
columnValues = [token, total, guaranteed, free, lastCheckTime]
776770

777771
return self._getRPC().delete("SpaceTokenOccupancyCache", prepareDict(columnNames, columnValues))
778772

779773
def addOrModifySpaceTokenOccupancyCache(
780-
self, endpoint=None, token=None, total=None, guaranteed=None, free=None, lastCheckTime=None
774+
self, token=None, total=None, guaranteed=None, free=None, lastCheckTime=None
781775
):
782776
"""
783777
Adds or updates-if-duplicated to SpaceTokenOccupancyCache. Using `site` and `token`
784778
to query the database, decides whether to insert or update the table.
785779
786-
:param endpoint: endpoint
787-
:type endpoint: string, list
788780
:param str token: name of the token
789781
:param int total: total terabytes
790782
:param int guaranteed: guaranteed terabytes
791783
:param int free: free terabytes
792784
:param datetime lastCheckTime: time-stamp from which the result is effective
793785
:return: S_OK() || S_ERROR()
794786
"""
795-
columnNames = ["Endpoint", "Token", "Total", "Guaranteed", "Free", "LastCheckTime"]
796-
columnValues = [endpoint, token, total, guaranteed, free, lastCheckTime]
787+
columnNames = ["Token", "Total", "Guaranteed", "Free", "LastCheckTime"]
788+
columnValues = [token, total, guaranteed, free, lastCheckTime]
797789

798790
return self._getRPC().addOrModify("SpaceTokenOccupancyCache", prepareDict(columnNames, columnValues))
799791

src/DIRAC/ResourceStatusSystem/Command/FreeDiskSpaceCommand.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def doNew(self, masterParams=None):
7979
free = occupancy["Free"]
8080
total = occupancy["Total"]
8181

82-
results = {"Endpoint": "Deprecated", "Free": free, "Total": total, "ElementName": elementName}
82+
results = {"Free": free, "Total": total, "ElementName": elementName}
8383
result = self._storeCommand(results)
8484
if not result["OK"]:
8585
return result
@@ -92,15 +92,13 @@ def _storeCommand(self, results):
9292
and adds records to the StorageOccupancy accounting.
9393
9494
:param dict results: something like {'ElementName': 'CERN-HIST-EOS',
95-
'Endpoint': 'httpg://srm-eoslhcb-bis.cern.ch:8443/srm/v2/server',
9695
'Free': 3264963586.10073,
9796
'Total': 8000000000.0}
9897
:returns: S_OK/S_ERROR dict
9998
"""
10099

101100
# Stores in cache
102101
res = self.rmClient.addOrModifySpaceTokenOccupancyCache(
103-
endpoint=results["Endpoint"],
104102
lastCheckTime=datetime.utcnow(),
105103
free=results["Free"],
106104
total=results["Total"],
@@ -116,8 +114,6 @@ def _storeCommand(self, results):
116114
return siteRes
117115

118116
accountingDict = {
119-
"StorageElement": results["ElementName"],
120-
"Endpoint": results["Endpoint"],
121117
"Site": siteRes["Value"] if siteRes["Value"] else "unassigned",
122118
}
123119

@@ -191,10 +187,9 @@ def doMaster(self):
191187
return self._cleanCommand()
192188

193189
def _cleanCommand(self, toDelete=None):
194-
"""Clean the spaceTokenOccupancy table from old endpoints
190+
"""Clean the spaceTokenOccupancy table from old SEs
195191
196-
:param tuple toDelete: endpoint to remove (endpoint, storage_element_name),
197-
e.g. ('httpg://srm-lhcb.cern.ch:8443/srm/managerv2', CERN-RAW)
192+
:param tuple toDelete: storage_element_name
198193
"""
199194
if not toDelete:
200195
toDelete = []
@@ -222,7 +217,7 @@ def _cleanCommand(self, toDelete=None):
222217
toDelete = [toDelete]
223218

224219
for ep in toDelete:
225-
res = self.rmClient.deleteSpaceTokenOccupancyCache(ep[0], ep[1])
220+
res = self.rmClient.deleteSpaceTokenOccupancyCache(ep)
226221
if not res["OK"]:
227222
self.log.warn("Could not delete entry from SpaceTokenOccupancyCache", res["Message"])
228223

src/DIRAC/ResourceStatusSystem/DB/ResourceManagementDB.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ class SpaceTokenOccupancyCache(rmsBase):
322322
__tablename__ = "SpaceTokenOccupancyCache"
323323
__table_args__ = {"mysql_engine": "InnoDB", "mysql_charset": "utf8mb4"}
324324

325-
endpoint = Column("Endpoint", String(128), nullable=False, primary_key=True)
326325
token = Column("Token", String(64), nullable=False, primary_key=True)
327326
guaranteed = Column("Guaranteed", Float(asdecimal=False), nullable=False, server_default="0")
328327
free = Column("Free", Float(asdecimal=False), nullable=False, server_default="0")
@@ -337,7 +336,6 @@ def fromDict(self, dictionary):
337336
:type arguments: dict
338337
"""
339338

340-
self.endpoint = dictionary.get("Endpoint", self.endpoint)
341339
self.token = dictionary.get("Token", self.token)
342340
self.guaranteed = dictionary.get("Guaranteed", self.guaranteed)
343341
self.free = dictionary.get("Free", self.free)
@@ -351,7 +349,7 @@ def fromDict(self, dictionary):
351349

352350
def toList(self):
353351
"""Simply returns a list of column values"""
354-
return [self.endpoint, self.token, self.guaranteed, self.free, self.total, self.lastchecktime]
352+
return [self.token, self.guaranteed, self.free, self.total, self.lastchecktime]
355353

356354

357355
class TransferCache(rmsBase):

tests/Integration/ResourceStatusSystem/Test_ResourceManagement.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -266,33 +266,31 @@ def test_SpaceTokenOccupancy(rmClient):
266266
SpaceTokenOccupancy table
267267
"""
268268

269-
res = rmClient.deleteSpaceTokenOccupancyCache("endpoint", "token") # just making sure it's not there (yet)
269+
res = rmClient.deleteSpaceTokenOccupancyCache("token") # just making sure it's not there (yet)
270270
assert res["OK"] is True, res["Message"]
271271

272272
# TEST addOrModifySpaceTokenOccupancy
273-
res = rmClient.addOrModifySpaceTokenOccupancyCache(
274-
"endpoint", "token", 500.0, 1000.0, 200.0, datetime.datetime.now()
275-
)
273+
res = rmClient.addOrModifySpaceTokenOccupancyCache("token", 500.0, 1000.0, 200.0, datetime.datetime.now())
276274
assert res["OK"] is True, res["Message"]
277275

278-
res = rmClient.selectSpaceTokenOccupancyCache("endpoint", "token")
276+
res = rmClient.selectSpaceTokenOccupancyCache("token")
279277
assert res["OK"] is True, res["Message"]
280278
# check if the name that we got is equal to the previously added 'token'
281-
assert res["Value"][0][1] == "token"
279+
assert res["Value"][0][0] == "token"
282280

283-
res = rmClient.addOrModifySpaceTokenOccupancyCache("endpoint", "token", free=100.0)
281+
res = rmClient.addOrModifySpaceTokenOccupancyCache("token", free=100.0)
284282
assert res["OK"] is True, res["Message"]
285283

286-
res = rmClient.selectSpaceTokenOccupancyCache("endpoint", "token")
284+
res = rmClient.selectSpaceTokenOccupancyCache("token")
287285
# check if the result has changed
288-
assert res["Value"][0][3] == 100.0
286+
assert res["Value"][0][2] == 100.0
289287

290288
# TEST deleteSpaceTokenOccupancy
291289
# ...............................................................................
292-
res = rmClient.deleteSpaceTokenOccupancyCache("endpoint", "token")
290+
res = rmClient.deleteSpaceTokenOccupancyCache("token")
293291
assert res["OK"] is True, res["Message"]
294292

295-
res = rmClient.selectSpaceTokenOccupancyCache("endpoint", "token")
293+
res = rmClient.selectSpaceTokenOccupancyCache("token")
296294
assert res["OK"] is True, res["Message"]
297295
assert not res["Value"], res["Value"]
298296

0 commit comments

Comments
 (0)